Commit dd60471b authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Merged v0.6.0.

parent 1f8bb5ae
Pipeline #62014 passed with stages
in 15 minutes and 23 seconds
......@@ -192,13 +192,8 @@ class Api {
this.onStartLoading = () => null
this.onFinishLoading = () => null
this._swaggerClient = Swagger(`${apiBase}/swagger.json`)
this.keycloak = keycloak
this.isLoggedIn = true && user
user = user || {}
this.auth_headers = {
'X-Token': user.token
this.swaggerPromise = Api.createSwaggerClient(user.token).catch(handleApiError)
// keep a list of localUploads, these are uploads that are currently uploaded through
// the browser and that therefore not yet returned by the backend
......@@ -12,13 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from flask import request
from flask_restplus import abort, Resource, fields
from flask_restplus import abort, Resource
from nomad import infrastructure, config
from .api import api
from .auth import admin_login_required
from .auth import authenticate
ns = api.namespace('admin', description='Administrative operations')
......@@ -29,7 +28,7 @@ class AdminResetResource(Resource):
@api.response(200, 'Reset performed')
@api.response(400, 'Reset not available/disabled')
def post(self):
The ``reset`` command will attempt to clear the contents of all databased and
......@@ -40,7 +39,7 @@ class AdminResetResource(Resource):
abort(400, message='Operation is disabled')
return dict(messager='Reset performed.'), 200
......@@ -50,7 +49,7 @@ class AdminRemoveResource(Resource):
@api.response(200, 'Remove performed')
@api.response(400, 'Remove not available/disabled')
def post(self):
The ``remove``command will attempt to remove all databases. Expect the
......@@ -65,28 +64,3 @@ class AdminRemoveResource(Resource):
return dict(messager='Remove performed.'), 200
pidprefix_model = api.model('PidPrefix', {
'prefix': fields.Integer(description='The prefix. All new calculations will get an id that is greater.', required=True)
# TODO remove after migration
class AdminPidPrefixResource(Resource):
@api.response(200, 'Pid prefix set')
@api.response(400, 'Bad pid prefix data')
def post(self):
The ``pidprefix``command will set the pid counter to the given value.
This might be useful while migrating data with old pids.
return dict(messager='PID prefix set.'), 200
......@@ -41,7 +41,7 @@ import uuid
from nomad import config, processing, utils, infrastructure, datamodel
from .app import api
from .api import api
# Authentication scheme definitions, for swagger
......@@ -26,7 +26,7 @@ from nomad import search, utils, datamodel
from import rfc3339DateTime
from import filterparser
from .api import api, rfc3339DateTime
from .api import api
from .auth import authenticate
from .common import pagination_model, pagination_request_parser, calc_route
......@@ -357,7 +357,7 @@ class RepoPidResource(Resource):
@api.response(404, 'Entry with PID does not exist')
@api.marshal_with(repo_calc_id_model, skip_none=True, code=200, description='Entry resolved')
def get(self, pid: int):
search_request = search.SearchRequest()
......@@ -15,7 +15,6 @@
import click
import datetime
import elasticsearch.helpers
import json
from nomad import processing as proc, search, datamodel, infrastructure, utils, config
......@@ -278,10 +278,11 @@ class Keycloak():
user_id = user.user_id
if email is not None and user_id is None:
with utils.lnr(logger, 'Could not use keycloak admin client'):
user_id = self._admin_client.get_user_id(email)
except Exception:
raise KeyError('User does not exist')
if user_id is None:
raise KeyError('User %s does not exist' % email)
assert user_id is not None, 'Could not determine user from given kwargs'
......@@ -286,7 +286,7 @@ class SearchRequest:
raise ValueError('Authentication required for owner value user')
q = Q('term', published=False) & Q('term', owners__user_id=user_id)
elif owner_type == 'admin':
if user_id is None or not coe_repo.User.from_user_id(user_id).is_admin:
if user_id is None or not datamodel.User.get(user_id=user_id).is_admin:
raise ValueError('This can only be used by the admin user.')
q = None
......@@ -25,7 +25,7 @@ from urllib.parse import urlencode
import base64
from import rfc3339DateTime
from import generate_upload_token
from import generate_upload_token
from nomad import search, parsing, files, config, utils, infrastructure
from nomad.files import UploadFiles, PublicUploadFiles
from nomad.processing import Upload, Calc, SUCCESS
......@@ -196,7 +196,7 @@ class TestUploads:
assert upload['process_running']
additional_keys = ['with_embargo']
if publish_with_metadata and 'external_id' in metadata:
if 'external_id' in metadata:
self.block_until_completed(api, upload_id, test_user_auth)
......@@ -597,18 +597,21 @@ class TestRepo():
calc_id='2', uploader=other_test_user.user_id, published=True, with_embargo=False,
upload_time=today - datetime.timedelta(days=5))
calc_id='2', uploader=other_test_user.user_id, published=True,
with_embargo=False, pid=2, upload_time=today - datetime.timedelta(days=5),
atoms=['Fe'], comment='this is a specific word', formula='AAA', basis_set='zzz')
calc_id='3', uploader=other_test_user.user_id, published=False, with_embargo=False)
calc_id='3', uploader=other_test_user.user_id, published=False,
with_embargo=False, pid=3, external_id='external_id')
calc_id='4', uploader=other_test_user.user_id, published=True, with_embargo=True)
calc_id='4', uploader=other_test_user.user_id, published=True,
with_embargo=True, pid=4, external_id='external_id')
def assert_search(self, rv: Any, number_of_calcs: int) -> dict:
......@@ -16,7 +16,7 @@ from typing import List
from elasticsearch_dsl import Q
import pytest
from nomad import datamodel, search, processing, parsing, infrastructure, config, coe_repo
from nomad import datamodel, search, processing, parsing, infrastructure, config
from import Entry, SearchRequest
......@@ -137,7 +137,7 @@ def test_search_totals(elastic, example_search_data):
assert 'quantities' not in results
def test_search_quantity(elastic, normalized: parsing.LocalBackend, test_user: coe_repo.User, other_test_user: coe_repo.User):
def test_search_quantity(elastic, normalized: parsing.LocalBackend, test_user: datamodel.User, other_test_user: datamodel.User):
calc_with_metadata = datamodel.CalcWithMetadata(upload_id='test upload id', calc_id='test id')
calc_with_metadata.uploader = test_user.user_id
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