Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary MANAGE_ORGANIZATIONS check #887

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions backend/dataall/core/organizations/api/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
13 changes: 0 additions & 13 deletions backend/dataall/core/organizations/api/resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
):
Expand Down
36 changes: 0 additions & 36 deletions backend/dataall/core/organizations/db/organization_repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -288,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(
Expand All @@ -297,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 = (
Expand Down
39 changes: 0 additions & 39 deletions tests/core/organizations/test_organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"""
Expand Down Expand Up @@ -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){
Expand Down
Loading