diff --git a/openlobby/core/api/types.py b/openlobby/core/api/types.py index f17f8d3923682136f28e0c68ad61fe60783cf1c3..78640dfe3934d6e250ffc0b9bb7f7e903b4e7aaa 100644 --- a/openlobby/core/api/types.py +++ b/openlobby/core/api/types.py @@ -87,6 +87,8 @@ class User(graphene.ObjectType): first_name = graphene.String() last_name = graphene.String() email = graphene.String() + is_author = graphene.Boolean() + extra = JSONString() class Meta: interfaces = (relay.Node, ) @@ -99,6 +101,8 @@ class User(graphene.ObjectType): first_name=user.first_name, last_name=user.last_name, email=user.email, + is_author=user.is_author, + extra=user.extra, ) @classmethod @@ -113,7 +117,6 @@ class User(graphene.ObjectType): class Author(graphene.ObjectType): first_name = graphene.String() last_name = graphene.String() - openid_uid = graphene.String() extra = JSONString() reports = relay.ConnectionField(ReportConnection) @@ -126,7 +129,6 @@ class Author(graphene.ObjectType): id=user.id, first_name=user.first_name, last_name=user.last_name, - openid_uid=user.openid_uid, extra=user.extra, ) diff --git a/tests/dummy.py b/tests/dummy.py index f37ab08fe1017e7b8a9240f122d624c769c8e062..dbdb7dcd6b16e1a5cda5ca745792d34787a6013a 100644 --- a/tests/dummy.py +++ b/tests/dummy.py @@ -7,7 +7,6 @@ authors = [ { 'id': 1, 'username': 'Wolf', - 'openid_uid': 'Wolf', 'first_name': 'Winston', 'last_name': 'Wolfe', 'is_author': True, @@ -16,7 +15,6 @@ authors = [ { 'id': 2, 'username': 'sponge', - 'openid_uid': 'sponge', 'first_name': 'Spongebob', 'last_name': 'Squarepants', 'is_author': True, @@ -24,7 +22,6 @@ authors = [ { 'id': 3, 'username': 'shaun', - 'openid_uid': 'shaun', 'first_name': 'Shaun', 'last_name': 'Sheep', 'is_author': True, diff --git a/tests/schema/snapshots/snap_test_authors.py b/tests/schema/snapshots/snap_test_authors.py index 6a8de11ac50b345d96bcbc182f9306ab0cdbb99d..88acda2ab25a1e728a38899b4661f6fc0c4237e7 100644 --- a/tests/schema/snapshots/snap_test_authors.py +++ b/tests/schema/snapshots/snap_test_authors.py @@ -17,8 +17,7 @@ snapshots['test_all 1'] = { 'extra': '{"movies": 1}', 'firstName': 'Winston', 'id': 'QXV0aG9yOjE=', - 'lastName': 'Wolfe', - 'openidUid': 'Wolf' + 'lastName': 'Wolfe' } }, { @@ -27,8 +26,7 @@ snapshots['test_all 1'] = { 'extra': None, 'firstName': 'Spongebob', 'id': 'QXV0aG9yOjI=', - 'lastName': 'Squarepants', - 'openidUid': 'sponge' + 'lastName': 'Squarepants' } }, { @@ -37,8 +35,7 @@ snapshots['test_all 1'] = { 'extra': None, 'firstName': 'Shaun', 'id': 'QXV0aG9yOjM=', - 'lastName': 'Sheep', - 'openidUid': 'shaun' + 'lastName': 'Sheep' } } ], @@ -60,13 +57,17 @@ snapshots['test_first 1'] = { { 'cursor': 'MQ==', 'node': { - 'openidUid': 'Wolf' + 'firstName': 'Winston', + 'id': 'QXV0aG9yOjE=', + 'lastName': 'Wolfe' } }, { 'cursor': 'Mg==', 'node': { - 'openidUid': 'sponge' + 'firstName': 'Spongebob', + 'id': 'QXV0aG9yOjI=', + 'lastName': 'Squarepants' } } ], @@ -88,7 +89,9 @@ snapshots['test_first_after 1'] = { { 'cursor': 'Mg==', 'node': { - 'openidUid': 'sponge' + 'firstName': 'Spongebob', + 'id': 'QXV0aG9yOjI=', + 'lastName': 'Squarepants' } } ], @@ -127,7 +130,9 @@ snapshots['test_last_before 1'] = { { 'cursor': 'Mg==', 'node': { - 'openidUid': 'sponge' + 'firstName': 'Spongebob', + 'id': 'QXV0aG9yOjI=', + 'lastName': 'Squarepants' } } ], diff --git a/tests/schema/snapshots/snap_test_node.py b/tests/schema/snapshots/snap_test_node.py index 706962a62b538907204564ebd567bd30903bf1ae..d2b7936a3346d1c9f3281455a745a5833b6ae853 100644 --- a/tests/schema/snapshots/snap_test_node.py +++ b/tests/schema/snapshots/snap_test_node.py @@ -22,8 +22,7 @@ snapshots['test_author 1'] = { 'extra': '{"x": 1}', 'firstName': 'Winston', 'id': 'QXV0aG9yOjU=', - 'lastName': 'Wolfe', - 'openidUid': 'TheWolf' + 'lastName': 'Wolfe' } } } @@ -72,8 +71,10 @@ snapshots['test_user__not_a_viewer 1'] = { snapshots['test_user 1'] = { 'data': { 'node': { + 'extra': '{"e": "mc2"}', 'firstName': 'Albert', 'id': 'VXNlcjo4', + 'isAuthor': False, 'lastName': 'Einstein', 'openidUid': 'albert@einstein.id' } diff --git a/tests/schema/snapshots/snap_test_search_reports.py b/tests/schema/snapshots/snap_test_search_reports.py index e8b353b2a4041dcfbaa9159e0d5f13adfc1ef063..70f33adda263e829d0e417f46a2e563d2f827ee3 100644 --- a/tests/schema/snapshots/snap_test_search_reports.py +++ b/tests/schema/snapshots/snap_test_search_reports.py @@ -36,7 +36,7 @@ snapshots['test_all 1'] = { 'cursor': 'Mg==', 'node': { 'author': { - 'extra': None, + 'extra': '{"movies": 1}', 'firstName': 'Winston', 'id': 'QXV0aG9yOjE=', 'lastName': 'Wolfe' @@ -57,7 +57,7 @@ snapshots['test_all 1'] = { 'cursor': 'Mw==', 'node': { 'author': { - 'extra': None, + 'extra': '{"movies": 1}', 'firstName': 'Winston', 'id': 'QXV0aG9yOjE=', 'lastName': 'Wolfe' @@ -125,7 +125,7 @@ snapshots['test_highlight 1'] = { 'cursor': 'MQ==', 'node': { 'author': { - 'extra': None, + 'extra': '{"movies": 1}', 'firstName': 'Winston', 'id': 'QXV0aG9yOjE=', 'lastName': 'Wolfe' @@ -146,7 +146,7 @@ snapshots['test_highlight 1'] = { 'cursor': 'Mg==', 'node': { 'author': { - 'extra': None, + 'extra': '{"movies": 1}', 'firstName': 'Winston', 'id': 'QXV0aG9yOjE=', 'lastName': 'Wolfe' diff --git a/tests/schema/snapshots/snap_test_viewer.py b/tests/schema/snapshots/snap_test_viewer.py index 5ba5fc7ffb12dced3effa32991852c7d8e6ff72d..947e074adf4a51eafab207cdbfb2dfc7672b131b 100644 --- a/tests/schema/snapshots/snap_test_viewer.py +++ b/tests/schema/snapshots/snap_test_viewer.py @@ -17,8 +17,10 @@ snapshots['test_authenticated 1'] = { 'data': { 'viewer': { 'email': 'winston@wolfe.com', + 'extra': '{"caliber": 45}', 'firstName': 'Winston', 'id': 'VXNlcjox', + 'isAuthor': True, 'lastName': 'Wolfe', 'openidUid': 'TheWolf' } diff --git a/tests/schema/test_authors.py b/tests/schema/test_authors.py index 614f82dbdb51c79f329918ae83e41fb5a32d2d4b..e81d03e9e50f0705766b85951359fe7a707ff352 100644 --- a/tests/schema/test_authors.py +++ b/tests/schema/test_authors.py @@ -21,7 +21,6 @@ def test_all(client, snapshot): id firstName lastName - openidUid extra } } @@ -46,7 +45,9 @@ def test_first(client, snapshot): edges { cursor node { - openidUid + id + firstName + lastName } } pageInfo { @@ -70,7 +71,9 @@ def test_first_after(client, snapshot): edges { cursor node { - openidUid + id + firstName + lastName } } pageInfo { @@ -94,7 +97,9 @@ def test_last(client, snapshot): edges { cursor node { - openidUid + id + firstName + lastName } } pageInfo { @@ -118,7 +123,9 @@ def test_last_before(client, snapshot): edges { cursor node { - openidUid + id + firstName + lastName } } pageInfo { diff --git a/tests/schema/test_node.py b/tests/schema/test_node.py index d2bfe8ca4f920684c819773c71304d5835520775..9b2adb7f818672f6fff5a3361e147ed1afa684b9 100644 --- a/tests/schema/test_node.py +++ b/tests/schema/test_node.py @@ -41,7 +41,6 @@ def test_author(client, snapshot): id firstName lastName - openidUid extra }} }} @@ -95,7 +94,7 @@ def test_report(client, snapshot): def test_user__unauthorized(client, snapshot): User.objects.create(id=8, username='albert', openid_uid='albert@einstein.id', - first_name='Albert', last_name='Einstein') + first_name='Albert', last_name='Einstein', extra={'e': 'mc2'}) res = client.post('/graphql', {'query': """ query {{ node (id:"{id}") {{ @@ -104,6 +103,8 @@ def test_user__unauthorized(client, snapshot): firstName lastName openidUid + isAuthor + extra }} }} }} @@ -113,9 +114,9 @@ def test_user__unauthorized(client, snapshot): def test_user__not_a_viewer(client, snapshot): User.objects.create(id=8, username='albert', openid_uid='albert@einstein.id', - first_name='Albert', last_name='Einstein') + first_name='Albert', last_name='Einstein', extra={'e': 'mc2'}) User.objects.create(id=2, username='isaac', openid_uid='isaac@newton.id', - first_name='Isaac', last_name='Newton') + first_name='Isaac', last_name='Newton', extra={'apple': 'hit'}) auth_header = 'Bearer {}'.format(create_access_token('isaac')) res = client.post('/graphql', {'query': """ query {{ @@ -125,6 +126,8 @@ def test_user__not_a_viewer(client, snapshot): firstName lastName openidUid + isAuthor + extra }} }} }} @@ -134,7 +137,7 @@ def test_user__not_a_viewer(client, snapshot): def test_user(client, snapshot): User.objects.create(id=8, username='albert', openid_uid='albert@einstein.id', - first_name='Albert', last_name='Einstein') + first_name='Albert', last_name='Einstein', extra={'e': 'mc2'}) auth_header = 'Bearer {}'.format(create_access_token('albert')) res = client.post('/graphql', {'query': """ query {{ @@ -144,6 +147,8 @@ def test_user(client, snapshot): firstName lastName openidUid + isAuthor + extra }} }} }} diff --git a/tests/schema/test_viewer.py b/tests/schema/test_viewer.py index a5015802286a0bc1a223ca9fbe4d0d45a58ed8a8..4ab66d2c54d60bf97fc47ea0d169bf855b85dd3b 100644 --- a/tests/schema/test_viewer.py +++ b/tests/schema/test_viewer.py @@ -10,7 +10,8 @@ pytestmark = pytest.mark.django_db @pytest.fixture(autouse=True) def setup(): User.objects.create(id=1, is_author=True, username='wolfe', openid_uid='TheWolf', - first_name='Winston', last_name='Wolfe', email='winston@wolfe.com') + first_name='Winston', last_name='Wolfe', email='winston@wolfe.com', + extra={'caliber': 45}) def test_unauthenticated(client, snapshot): @@ -35,6 +36,8 @@ def test_authenticated(client, snapshot): lastName email openidUid + isAuthor + extra } } """}, HTTP_AUTHORIZATION=auth_header)