Skip to content

Commit

Permalink
Merge pull request #9 from smaht-dac/wrr_schema
Browse files Browse the repository at this point in the history
Schema updates
  • Loading branch information
willronchetti authored Aug 8, 2023
2 parents 2d78d11 + 34ae33b commit 96734ac
Show file tree
Hide file tree
Showing 13 changed files with 282 additions and 39 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ smaht-portal
Change Log
----------

0.0.6
=====

* Removes ``jsonschema_serialize_fork``, use new schema draft version
* Implement ``$merge`` referential schema fields


0.0.5
=====

Expand All @@ -15,6 +22,7 @@ Change Log
* Allow testing with ES in GA with smaht-development credentials
* Build Docker as part of GA


0.0.4
=====

Expand All @@ -23,6 +31,7 @@ Change Log
* Update to use Webpack 5
* Do some light adjustments to be more compatible with Google Analytics 4 down the line


0.0.3
=====

Expand All @@ -34,9 +43,10 @@ Change Log

* Implement base level permissioning scheme working with ``consortia`` and ``submission_center``


0.0.1
=====

* Initial version
* TODO: update base.ini, various other ini file templates once new AWS is provisioned
* TOOD: build GLOBAL_ENV_BUCKET for testing (conftest.py)
* TOOD: build GLOBAL_ENV_BUCKET for testing (conftest.py)
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ENV NGINX_USER=nginx \
NVM_VERSION=v0.39.1 \
NODE_VERSION=16.14.0

# Configure Python3.7 venv
# Configure Python3.9 venv
ENV VIRTUAL_ENV=/opt/venv
RUN python -m venv /opt/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
Expand Down
205 changes: 186 additions & 19 deletions poetry.lock

Large diffs are not rendered by default.

15 changes: 5 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "encoded"
version = "0.0.5"
version = "0.0.6"
description = "SMaHT Data Analysis Portal"
authors = ["4DN-DCIC Team <[email protected]>"]
license = "MIT"
Expand Down Expand Up @@ -42,17 +42,15 @@ certifi = ">=2021.5.30"
chardet = "3.0.4"
codeguru-profiler-agent = "^1.2.4"
colorama = "0.3.3"
dcicsnovault = "8.2.0.1b45"
dcicutils = "7.5.1.1b0"
encoded-core = "^0.0.2"
dcicsnovault = "^10.0.0"
dcicutils = "^7.7.0"
encoded-core = "^0.0.3"
elasticsearch = "7.13.4"
execnet = "1.4.1"
# html5lib = "0.9999999"
humanfriendly = "^1.44.9"
hupper = "1.5"
idna = ">=2.10,<3"
jmespath = "0.9.0"
jsonschema_serialize_fork = "^2.1.1"
loremipsum = "1.0.5"
netaddr = ">=0.8.0,<1"
openpyxl = "^3.0.7,!=3.0.8" # a version 3.0.8 appeared but then got withdrawn, for now just pin 3.0.7. try again later.
Expand All @@ -77,7 +75,6 @@ pyramid-retry = "^1.0"
pyramid-tm = "^2.4"
pyramid_translogger = "^0.1"
python-dateutil = "^2.8.2"
# python-magic is presently pinned to 0.4.15 in lockstep with dcicsnovault's requirements. See explanation there.
python_magic = ">=0.4.24,<1"
pytz = ">=2021.3"
rdflib = "^4.2.2"
Expand All @@ -88,12 +85,10 @@ requests = "^2.23.0"
rfc3986 = "^1.4.0"
rsa = "3.3"
rutter = ">=0.3,<1"
# We don't use this directly. It's part of boto3. It slows down solving to pin.
# s3transfer = ">=0.3.7,<0.4.0"
sentry-sdk = "^1.5.6"
simplejson = "^3.17.0"
SPARQLWrapper = "^1.8.5"
SQLAlchemy = "1.4.41" # Pinned because >=1.3.17 is broken for us (circular constraints prevent deletes)
SQLAlchemy = "1.4.41"
structlog = ">=19.2.0,<20"
#submit4dn = "0.9.7"
subprocess-middleware = "^0.3.0"
Expand Down
2 changes: 1 addition & 1 deletion src/encoded/project/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def login(self, context, request, *, samesite):

def namespaced_authentication_policy_authenticated_userid(self, namespaced_authentication_policy, request,
set_user_info_property):
set_user_info_property = False
set_user_info_property = True
return super().namespaced_authentication_policy_authenticated_userid(namespaced_authentication_policy, request,
set_user_info_property)

Expand Down
2 changes: 1 addition & 1 deletion src/encoded/schema_formats.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re
from pyramid.threadlocal import get_current_request
from jsonschema_serialize_fork import FormatChecker
from snovault.schema_validation import FormatChecker
from snovault.server_defaults import test_accession
from .server_defaults import (
ACCESSION_FACTORY,
Expand Down
4 changes: 2 additions & 2 deletions src/encoded/schemas/consortium.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "Consortium",
"id": "/profiles/consortium.json",
"$schema": "http://json-schema.org/draft-04/schema#",
"$id": "/profiles/consortium.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"required": [
"name",
"title"
Expand Down
4 changes: 2 additions & 2 deletions src/encoded/schemas/submission_center.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "SubmissionCenter",
"id": "/profiles/submission_center.json",
"$schema": "http://json-schema.org/draft-04/schema#",
"$id": "/profiles/submission_center.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"required": [
"name",
"title"
Expand Down
2 changes: 1 addition & 1 deletion src/encoded/server_defaults.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dcicutils.misc_utils import ignored
from jsonschema_serialize_fork import NO_DEFAULT
from snovault.schema_validation import NO_DEFAULT
from snovault.schema_utils import server_default
from snovault.server_defaults import get_user_resource

Expand Down
23 changes: 23 additions & 0 deletions src/encoded/tests/test_merge_schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pytest
from snovault.schema_utils import load_schema
from .testing_views import TestingLinkedSchemaField


class TestMergedSchemas:
""" Class that contains tests that validate $merge refs are correctly resolved within repo
and across repos
"""

@staticmethod
def test_merged_schemas():
""" Checks that we can resolve multiple different schema $ref types """
schema = load_schema(TestingLinkedSchemaField.schema)
props = schema['properties']
for key in ['access_key_id', 'file_format', 'title']:
assert key in props
# check access key id
assert props['access_key_id']['comment'] == 'Only admins are allowed to set this value.'
# check file_format
assert props['file_format']['linkTo'] == 'FileFormat'
# check title
assert props['title']['description'] == 'A title for the Consortium.'
14 changes: 14 additions & 0 deletions src/encoded/tests/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ def consortium_file(testapp, fastq_format, test_consortium):
return res.json['@graph'][0]


class TestAdminPermissions:
""" Tests admins can do various actions, including purging items """

@staticmethod
def test_admin_can_purge(testapp, fastq_format):
testapp.patch_json(f'/{fastq_format["uuid"]}', {'status': 'deleted'}, status=200)
testapp.delete_json(f'/{fastq_format["uuid"]}/?purge=True', {}, status=200)

@staticmethod
def test_non_admin_cannot_purge(submitter_testapp, fastq_format):
submitter_testapp.patch_json(f'/{fastq_format["uuid"]}', {'status': 'deleted'}, status=422)
submitter_testapp.delete_json(f'/{fastq_format["uuid"]}/?purge=True', {}, status=403)


class TestPermissionsHelper:

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion src/encoded/tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_load_schema(schema, master_mixins, registry, testapp):

if schema not in ['namespaces.json', 'mixins.json']:
# check that schema.id is same as /profiles/schema
idtag = loaded_schema['id']
idtag = loaded_schema['$id']
idtag = idtag.replace('/profiles/', '')
# special case for access_key.json
if schema == 'access_key.json':
Expand Down
34 changes: 34 additions & 0 deletions src/encoded/tests/testing_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,37 @@ class TestingPostPutPatch(Item):
},
}
}


@collection(
'testing-linked-schema-fields',
acl=[
(Allow, 'group.submitter', ['add', 'edit', 'view']),
],
)
class TestingLinkedSchemaField(Item):
item_type = 'testing_linked_schema_field'
schema = {
'type': 'object',
'additionalProperties': False,
'properties': {
"schema_version": {
"type": "string",
"pattern": "^\\d+(\\.\\d+)*$",
"requestMethod": [],
"default": "1",
},
# link from snovault field
'access_key_id': {
'$merge': 'snovault:schemas/access_key.json#/properties/access_key_id'
},
# link from encoded-core field
'file_format': {
'$merge': 'encoded_core:schemas/file.json#/properties/file_format'
},
# link from this repo
'title': {
'$merge': 'encoded:schemas/consortium.json#/properties/title'
}
}
}

0 comments on commit 96734ac

Please sign in to comment.