Commit 48410f6c authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Fixed wrong authorization on emargo and staging entries. Added respective...

Fixed wrong authorization on emargo and staging entries. Added respective tests. Minor UI layout fixes.
parent c0248a0a
Pipeline #46709 passed with stages
in 16 minutes and 23 seconds
......@@ -515,7 +515,7 @@ class WithApiComponent extends React.Component {
if (notAuthorized) {
if (user) {
return (
<div style={{padding: 16}}>
<div>
<Typography variant="h6">Not Authorized</Typography>
<Typography>
You are not authorized to access this information. If someone send
......@@ -534,7 +534,7 @@ class WithApiComponent extends React.Component {
)
}
} else if (notFound) {
return <div style={{padding: 16}}>
return <div>
<Typography variant="h6">Not Found</Typography>
<Typography>
The information that you are trying to access does not exists.
......
......@@ -58,7 +58,9 @@ class RepoCalcResource(Resource):
is_owner = g.user.user_id == 0
if not is_owner:
for owner in calc.owners:
if owner.user_id == str(g.user.user_id):
# At somepoint ids will be emails (strings) anyways.
# Right now it is hard to make sure that both are either str or int.
if str(owner.user_id) == str(g.user.user_id):
is_owner = True
break
if not is_owner:
......
......@@ -163,7 +163,7 @@ normalize = NomadConfig(
client = NomadConfig(
user='leonard.hofstadter@nomad-fairdi.tests.de',
password='password',
url='http://localhost:8000/nomad/api'
url='http://localhost:8000/fairdi/nomad/latest/api'
)
version = '0.4.4'
......@@ -278,6 +278,7 @@ def load_config(config_file: str = os.environ.get('NOMAD_CONFIG', 'nomad.yaml'))
'config key %s value %s has wrong type: %s' % (key, str(value), str(e)))
else:
config[key] = value
logger.info('override config key %s with value %s' % (key, str(value)))
else:
logger.error('config key %s does not exist' % key)
......
......@@ -589,10 +589,18 @@ class TestRepo():
rv = client.get('/repo/0/4', headers=test_user_auth)
assert rv.status_code == 401
def test_own_embargo_calc(self, client, example_elastic_calcs, no_warn, other_test_user_auth):
rv = client.get('/repo/0/4', headers=other_test_user_auth)
assert rv.status_code == 200
def test_staging_calc(self, client, example_elastic_calcs, no_warn, test_user_auth):
rv = client.get('/repo/0/3', headers=test_user_auth)
assert rv.status_code == 401
def test_own_staging_calc(self, client, example_elastic_calcs, no_warn, other_test_user_auth):
rv = client.get('/repo/0/3', headers=other_test_user_auth)
assert rv.status_code == 200
def test_non_existing_calcs(self, client, example_elastic_calcs, test_user_auth):
rv = client.get('/repo/0/10', headers=test_user_auth)
assert rv.status_code == 404
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment