-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/integration tests dashboards (#1560)
### Feature or Bugfix <!-- please choose --> - Feature ### Detail - Add integration tests for dashboards - Remove `shareDashboard` unused API - Small update to notebook tests to now use `set_env_params` util ### Relates - #1546 ### Note For dashboard tests to run successfully the follow pre-requisite work must be complete: - QS Enterprise Account created in `session_env1` with Capacity Pricing - QS Dashboard created with `dataall` QS Group having `Owner` permissions - And `dashboardId` added to the `testdata.json` as shown in `README` ### Security Please answer the questions below briefly where applicable, or write `N/A`. Based on [OWASP 10](https://owasp.org/Top10/en/). - Does this PR introduce or modify any input fields or queries - this includes fetching data from storage outside the application (e.g. a database, an S3 bucket)? - Is the input sanitized? - What precautions are you taking before deserializing the data you consume? - Is injection prevented by parametrizing queries? - Have you ensured no `eval` or similar functions are used? - Does this PR introduce any functionality or component that requires authorization? - How have you ensured it respects the existing AuthN/AuthZ mechanisms? - Are you logging failed auth attempts? - Are you using or adding any cryptographic features? - Do you use a standard proven implementations? - Are the used keys controlled by the customer? Where are they stored? - Are you introducing any new policies/roles/users? - Have you used the least-privilege principle? How? By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
- Loading branch information
1 parent
93bd073
commit dcc3849
Showing
12 changed files
with
441 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
tests_new/integration_tests/modules/dashboards/conftest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import pytest | ||
from integration_tests.modules.dashboards.mutations import ( | ||
import_dashboard, | ||
delete_dashboard, | ||
request_dashboard_share, | ||
reject_dashboard_share, | ||
) | ||
from integration_tests.modules.dashboards.queries import get_dashboard | ||
from integration_tests.core.environment.utils import set_env_params | ||
|
||
|
||
def create_dataall_dashboard(client, session_id, dashboard_id, env): | ||
dashboard_input = { | ||
'label': session_id, | ||
'dashboardId': dashboard_id, | ||
'environmentUri': env.environmentUri, | ||
'description': 'integration test dashboard', | ||
'SamlGroupName': env.SamlGroupName, | ||
'tags': [session_id], | ||
'terms': [], | ||
} | ||
ds = import_dashboard(client, dashboard_input) | ||
return get_dashboard(client, ds.dashboardUri) | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
def dashboard1(session_id, client1, session_env1, testdata): | ||
set_env_params(client1, session_env1, dashboardsEnabled='true') | ||
dashboardId = testdata.dashboards['session_env1'].dashboardId | ||
ds = None | ||
try: | ||
ds = create_dataall_dashboard(client1, session_id, dashboardId, session_env1) | ||
yield ds | ||
finally: | ||
if ds: | ||
delete_dashboard(client1, ds.dashboardUri) | ||
|
||
|
||
@pytest.fixture(scope='function') | ||
def dashboard1_share(client1, client2, dashboard1, group2): | ||
share = None | ||
try: | ||
share = request_dashboard_share(client2, dashboard1.dashboardUri, group2) | ||
yield share | ||
finally: | ||
if share: | ||
reject_dashboard_share(client1, share.shareUri) |
108 changes: 108 additions & 0 deletions
108
tests_new/integration_tests/modules/dashboards/mutations.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# TODO: This file will be replaced by using the SDK directly | ||
|
||
# # IF MONITORING ON (TODO) | ||
# createQuicksightDataSourceSet (TODO) | ||
|
||
|
||
def import_dashboard(client, input): | ||
query = { | ||
'operationName': 'importDashboard', | ||
'variables': {'input': input}, | ||
'query': """ | ||
mutation importDashboard($input: ImportDashboardInput!) { | ||
importDashboard(input: $input) { | ||
dashboardUri | ||
name | ||
label | ||
DashboardId | ||
created | ||
} | ||
} | ||
""", | ||
} | ||
response = client.query(query=query) | ||
return response.data.importDashboard | ||
|
||
|
||
def update_dashboard(client, input): | ||
query = { | ||
'operationName': 'updateDashboard', | ||
'variables': {'input': input}, | ||
'query': """ | ||
mutation updateDashboard($input: UpdateDashboardInput!) { | ||
updateDashboard(input: $input) { | ||
dashboardUri | ||
name | ||
label | ||
created | ||
} | ||
} | ||
""", | ||
} | ||
response = client.query(query=query) | ||
return response.data.importDashboard | ||
|
||
|
||
def delete_dashboard(client, dashboardUri): | ||
query = { | ||
'operationName': 'deleteDashboard', | ||
'variables': {'dashboardUri': dashboardUri}, | ||
'query': """ | ||
mutation deleteDashboard($dashboardUri: String!) { | ||
deleteDashboard(dashboardUri: $dashboardUri) | ||
} | ||
""", | ||
} | ||
response = client.query(query=query) | ||
return response.data.deleteDashboard | ||
|
||
|
||
def request_dashboard_share(client, dashboardUri, principalId): | ||
query = { | ||
'operationName': 'requestDashboardShare', | ||
'variables': {'dashboardUri': dashboardUri, 'principalId': principalId}, | ||
'query': """ | ||
mutation requestDashboardShare($dashboardUri: String!,$principalId: String!) { | ||
requestDashboardShare(dashboardUri: $dashboardUri,principalId: $principalId) { | ||
shareUri | ||
status | ||
} | ||
} | ||
""", | ||
} | ||
response = client.query(query=query) | ||
return response.data.requestDashboardShare | ||
|
||
|
||
def approve_dashboard_share(client, shareUri): | ||
query = { | ||
'operationName': 'approveDashboardShare', | ||
'variables': {'shareUri': shareUri}, | ||
'query': """ | ||
mutation approveDashboardShare($shareUri: String!) { | ||
approveDashboardShare(shareUri: $shareUri) { | ||
shareUri | ||
status | ||
} | ||
} | ||
""", | ||
} | ||
response = client.query(query=query) | ||
return response.data.approveDashboardShare | ||
|
||
|
||
def reject_dashboard_share(client, shareUri): | ||
query = { | ||
'operationName': 'rejectDashboardShare', | ||
'variables': {'shareUri': shareUri}, | ||
'query': """ | ||
mutation rejectDashboardShare($shareUri: String!) { | ||
rejectDashboardShare(shareUri: $shareUri) { | ||
shareUri | ||
status | ||
} | ||
} | ||
""", | ||
} | ||
response = client.query(query=query) | ||
return response.data.rejectDashboardShare |
Oops, something went wrong.