From 9cc7bf6c913b31805e7f7a7379020c74d1775697 Mon Sep 17 00:00:00 2001 From: dlpzx Date: Tue, 21 Nov 2023 15:17:40 +0100 Subject: [PATCH 1/2] Remove unnecessary MANAGE_ORGANIZATIONS check --- .../dataall/core/organizations/db/organization_repositories.py | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/dataall/core/organizations/db/organization_repositories.py b/backend/dataall/core/organizations/db/organization_repositories.py index 9574ea24e..83170fdae 100644 --- a/backend/dataall/core/organizations/db/organization_repositories.py +++ b/backend/dataall/core/organizations/db/organization_repositories.py @@ -151,7 +151,6 @@ def query_organization_environments(session, uri, filter) -> Query: return query @staticmethod - @has_tenant_permission(permissions.MANAGE_ORGANIZATIONS) @has_resource_permission(permissions.GET_ORGANIZATION) def paginated_organization_environments(session, uri, data=None) -> dict: return paginate( From 17b33b0e4d1ff9ddc67e07010bed4629f90eac49 Mon Sep 17 00:00:00 2001 From: dlpzx Date: Mon, 27 Nov 2023 18:03:05 +0100 Subject: [PATCH 2/2] Remove MANAGE_ORGANIZATIONS check from list organization groups and remove unused Query --- .../dataall/core/organizations/api/queries.py | 9 ----- .../core/organizations/api/resolvers.py | 13 ------- .../db/organization_repositories.py | 35 ----------------- tests/core/organizations/test_organization.py | 39 ------------------- 4 files changed, 96 deletions(-) diff --git a/backend/dataall/core/organizations/api/queries.py b/backend/dataall/core/organizations/api/queries.py index 32625e8d9..26e171879 100644 --- a/backend/dataall/core/organizations/api/queries.py +++ b/backend/dataall/core/organizations/api/queries.py @@ -23,15 +23,6 @@ test_scope='Organization', ) -listOrganizationInvitedGroups = gql.QueryField( - name='listOrganizationInvitedGroups', - type=gql.Ref('GroupSearchResult'), - args=[ - gql.Argument(name='organizationUri', type=gql.NonNullableType(gql.String)), - gql.Argument(name='filter', type=gql.Ref('GroupFilter')), - ], - resolver=list_organization_invited_groups, -) listOrganizationGroups = gql.QueryField( name='listOrganizationGroups', diff --git a/backend/dataall/core/organizations/api/resolvers.py b/backend/dataall/core/organizations/api/resolvers.py index 458a2ddb4..f866b7c72 100644 --- a/backend/dataall/core/organizations/api/resolvers.py +++ b/backend/dataall/core/organizations/api/resolvers.py @@ -107,19 +107,6 @@ def remove_group(context: Context, source, organizationUri=None, groupUri=None): return organization -def list_organization_invited_groups( - context: Context, source, organizationUri=None, filter=None -): - if filter is None: - filter = {} - with context.engine.scoped_session() as session: - return Organization.paginated_organization_invited_groups( - session=session, - uri=organizationUri, - data=filter, - ) - - def list_organization_groups( context: Context, source, organizationUri=None, filter=None ): diff --git a/backend/dataall/core/organizations/db/organization_repositories.py b/backend/dataall/core/organizations/db/organization_repositories.py index 83170fdae..057496afa 100644 --- a/backend/dataall/core/organizations/db/organization_repositories.py +++ b/backend/dataall/core/organizations/db/organization_repositories.py @@ -287,7 +287,6 @@ def query_organization_groups(session, uri, filter) -> Query: return query @staticmethod - @has_tenant_permission(permissions.MANAGE_ORGANIZATIONS) @has_resource_permission(permissions.GET_ORGANIZATION) def paginated_organization_groups(session, uri, data=None) -> dict: return paginate( @@ -296,40 +295,6 @@ def paginated_organization_groups(session, uri, data=None) -> dict: page_size=data.get('pageSize', 10), ).to_dict() - @staticmethod - def query_organization_invited_groups(session, organization, filter) -> Query: - query = ( - session.query(models.OrganizationGroup) - .join( - models.Organization, - models.OrganizationGroup.organizationUri == models.Organization.organizationUri, - ) - .filter( - and_( - models.Organization.organizationUri == organization.organizationUri, - models.OrganizationGroup.groupUri != models.Organization.SamlGroupName, - ) - ) - ) - if filter and filter.get('term'): - query = query.filter( - or_( - models.OrganizationGroup.groupUri.ilike('%' + filter.get('term') + '%'), - ) - ) - return query - - @staticmethod - @has_tenant_permission(permissions.MANAGE_ORGANIZATIONS) - @has_resource_permission(permissions.GET_ORGANIZATION) - def paginated_organization_invited_groups(session, uri, data=None) -> dict: - organization = Organization.get_organization_by_uri(session, uri) - return paginate( - query=Organization.query_organization_invited_groups(session, organization, data), - page=data.get('page', 1), - page_size=data.get('pageSize', 10), - ).to_dict() - @staticmethod def count_organization_invited_groups(session, uri, group) -> int: groups = ( diff --git a/tests/core/organizations/test_organization.py b/tests/core/organizations/test_organization.py index 40b304ff9..4f826070d 100644 --- a/tests/core/organizations/test_organization.py +++ b/tests/core/organizations/test_organization.py @@ -222,25 +222,6 @@ def test_group_invitation(db, client, org1, group2, user, group3, group, env): assert response.data.getOrganization.userRoleInOrganization == 'Invited' assert response.data.getOrganization.stats.groups == 1 - response = client.query( - """ - query listOrganizationInvitedGroups($organizationUri: String!, $filter:GroupFilter){ - listOrganizationInvitedGroups(organizationUri:$organizationUri, filter:$filter){ - count - nodes{ - groupUri - name - } - } - } - """, - username=user.username, - groups=[group.name, group2.name], - organizationUri=org1.organizationUri, - filter={}, - ) - - assert response.data.listOrganizationInvitedGroups.count == 1 response = client.query( """ @@ -303,26 +284,6 @@ def test_group_invitation(db, client, org1, group2, user, group3, group, env): print(response) assert response.data.removeGroupFromOrganization - response = client.query( - """ - query listOrganizationInvitedGroups($organizationUri: String!, $filter:GroupFilter){ - listOrganizationInvitedGroups(organizationUri:$organizationUri, filter:$filter){ - count - nodes{ - groupUri - name - } - } - } - """, - username=user.username, - groups=[group.name, group2.name], - organizationUri=org1.organizationUri, - filter={}, - ) - - assert response.data.listOrganizationInvitedGroups.count == 0 - response = client.query( """ query listOrganizationGroups($organizationUri: String!, $filter:GroupFilter){