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

make dashboards optional based on config #1677

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 1 addition & 7 deletions tests_new/integration_tests/core/environment/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,7 @@ def create_environment(client, name, group, organizationUri, awsAccountId, regio
'description': 'Created for integration testing',
'tags': tags,
'type': 'IntegrationTesting',
'parameters': [
{'key': 'notebooksEnabled', 'value': 'true'},
{'key': 'dashboardsEnabled', 'value': 'true'},
{'key': 'mlStudiosEnabled', 'value': 'false'},
{'key': 'pipelinesEnabled', 'value': 'true'},
{'key': 'omicsEnabled', 'value': 'true'},
],
'parameters': [],
}
},
'query': f"""
Expand Down
14 changes: 6 additions & 8 deletions tests_new/integration_tests/core/environment/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@


def set_env_params(client, env, **new_params):
should_update = False
new_params_list = []
for param in env.parameters:
new_param_value = new_params.get(param.key, param.value)
if new_param_value != param.value:
should_update = True
new_params_list.append({'key': param.key, 'value': new_param_value})
if should_update:
old_params = {param.key: param.value for param in env.parameters}
updated_params = {**old_params, **new_params}

# update env only if there are param updates
if old_params != updated_params:
new_params_list = [{'key': param[0], 'value': param[1]} for param in updated_params.items()]
env_uri = env.environmentUri
stack_uri = env.stack.stackUri
check_stack_ready(client, env_uri, stack_uri)
Expand Down
17 changes: 8 additions & 9 deletions tests_new/integration_tests/modules/dashboards/conftest.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import pytest

from integration_tests.core.environment.utils import set_env_params
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
from integration_tests.modules.dashboards.aws_clients import QuickSightClient


@pytest.fixture(scope='session')
def quicksight_account_exists(session_env1, session_env1_aws_client):
if not QuickSightClient(
session_env1_aws_client, session_env1.AwsAccountId, session_env1.region
).check_enterprise_account_exists():
pytest.skip('Skipping QuickSight tests because QuickSight account does not exist')
def dashboards(testdata):
if testdata.dashboards:
return testdata.dashboards
pytest.skip('dashboards config is missing')


def create_dataall_dashboard(client, session_id, dashboard_id, env):
Expand All @@ -33,9 +32,9 @@ def create_dataall_dashboard(client, session_id, dashboard_id, env):


@pytest.fixture(scope='session')
def dashboard1(session_id, client1, session_env1, testdata):
def dashboard1(session_id, client1, session_env1, dashboards):
set_env_params(client1, session_env1, dashboardsEnabled='true')
dashboardId = testdata.dashboards['session_env1'].dashboardId
dashboardId = dashboards['session_env1'].dashboardId
ds = None
try:
ds = create_dataall_dashboard(client1, session_id, dashboardId, session_env1)
Expand Down
37 changes: 20 additions & 17 deletions tests_new/integration_tests/modules/dashboards/test_dashboard.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pytest
from assertpy import assert_that

from integration_tests.modules.dashboards.queries import (
Expand All @@ -20,61 +21,63 @@
UPDATED_DESC = 'new description'


def test_get_author_session(quicksight_account_exists, client1, session_env1):
@pytest.mark.usefixtures('dashboards')
def test_get_author_session(client1, session_env1):
set_env_params(client1, session_env1, dashboardsEnabled='true')
assert_that(get_author_session(client1, session_env1.environmentUri)).starts_with('https://')


def test_get_author_session_unauthorized(quicksight_account_exists, client2, session_env1):
@pytest.mark.usefixtures('dashboards')
def test_get_author_session_unauthorized(client2, session_env1):
assert_that(get_author_session).raises(GqlError).when_called_with(client2, session_env1.environmentUri).contains(
'UnauthorizedOperation', 'CREATE_DASHBOARD', session_env1.environmentUri
)


def test_get_dashboard(quicksight_account_exists, session_id, dashboard1):
def test_get_dashboard(session_id, dashboard1):
assert_that(dashboard1.label).is_equal_to(session_id)


def test_list_dashboards(quicksight_account_exists, client1, client2, session_id, dashboard1):
def test_list_dashboards(client1, client2, session_id, dashboard1):
filter = {'term': session_id}
assert_that(search_dashboards(client1, filter).nodes).is_length(1)
assert_that(search_dashboards(client2, filter).nodes).is_length(0)


def test_get_dashboard_unauthorized(quicksight_account_exists, client2, dashboard1):
def test_get_dashboard_unauthorized(client2, dashboard1):
assert_that(get_dashboard).raises(GqlError).when_called_with(client2, dashboard1.dashboardUri).contains(
'UnauthorizedOperation', 'GET_DASHBOARD', dashboard1.dashboardUri
)


def test_update_dashboard(quicksight_account_exists, client1, dashboard1):
def test_update_dashboard(client1, dashboard1):
update_dashboard(client1, {'dashboardUri': dashboard1.dashboardUri, 'description': UPDATED_DESC})
ds = get_dashboard(client1, dashboard1.dashboardUri)
assert_that(ds.description).is_equal_to(UPDATED_DESC)


def test_update_dashboard_unauthorized(quicksight_account_exists, client2, dashboard1):
def test_update_dashboard_unauthorized(client2, dashboard1):
assert_that(update_dashboard).raises(GqlError).when_called_with(
client2, {'dashboardUri': dashboard1.dashboardUri, 'description': UPDATED_DESC}
).contains('UnauthorizedOperation', 'UPDATE_DASHBOARD', dashboard1.dashboardUri)


def test_request_dashboard_share(quicksight_account_exists, dashboard1_share):
def test_request_dashboard_share(dashboard1_share):
assert_that(dashboard1_share.shareUri).is_not_none()
assert_that(dashboard1_share.status).is_equal_to('REQUESTED')


def test_list_dashboard_shares(quicksight_account_exists, client1, session_id, dashboard1, dashboard1_share):
def test_list_dashboard_shares(client1, session_id, dashboard1, dashboard1_share):
assert_that(list_dashboard_shares(client1, dashboard1.dashboardUri, {'term': session_id}).nodes).is_length(1)


def test_approve_dashboard_share_unauthorized(quicksight_account_exists, client2, dashboard1, dashboard1_share):
def test_approve_dashboard_share_unauthorized(client2, dashboard1, dashboard1_share):
assert_that(approve_dashboard_share).raises(GqlError).when_called_with(client2, dashboard1_share.shareUri).contains(
'UnauthorizedOperation', 'SHARE_DASHBOARD', dashboard1.dashboardUri
)


def test_approve_dashboard_share(quicksight_account_exists, client1, client2, session_id, dashboard1, dashboard1_share):
def test_approve_dashboard_share(client1, client2, session_id, dashboard1, dashboard1_share):
filter = {'term': session_id}
assert_that(search_dashboards(client2, filter).nodes).is_length(0)
ds_share = approve_dashboard_share(client1, dashboard1_share.shareUri)
Expand All @@ -83,33 +86,33 @@ def test_approve_dashboard_share(quicksight_account_exists, client1, client2, se
assert_that(search_dashboards(client2, filter).nodes).is_length(1)


def test_reject_dashboard_share(quicksight_account_exists, client1, client2, session_id, dashboard1_share):
def test_reject_dashboard_share(client1, client2, session_id, dashboard1_share):
ds_share = reject_dashboard_share(client1, dashboard1_share.shareUri)
assert_that(ds_share.status).is_equal_to('REJECTED')
assert_that(search_dashboards(client2, {'term': session_id}).nodes).is_length(0)


def test_get_reader_session(quicksight_account_exists, client1, dashboard1):
def test_get_reader_session(client1, dashboard1):
assert_that(get_reader_session(client1, dashboard1.dashboardUri)).starts_with('https://')


def test_get_reader_session_unauthorized(quicksight_account_exists, client2, dashboard1):
def test_get_reader_session_unauthorized(client2, dashboard1):
assert_that(get_reader_session).raises(GqlError).when_called_with(client2, dashboard1.dashboardUri).contains(
'UnauthorizedOperation', 'GET_DASHBOARD', dashboard1.dashboardUri
)


def test_delete_dashboard(quicksight_account_exists, client1, session_id, session_env1, testdata):
def test_delete_dashboard(client1, session_id, session_env1, dashboards):
filter = {'term': session_id}
dashboardId = testdata.dashboards['session_env1'].dashboardId
dashboardId = dashboards['session_env1'].dashboardId
dashboard2 = create_dataall_dashboard(client1, session_id, dashboardId, session_env1)
assert_that(search_dashboards(client1, filter).nodes).is_length(2)

delete_dashboard(client1, dashboard2.dashboardUri)
assert_that(search_dashboards(client1, filter).nodes).is_length(1)


def test_delete_dashboard_unauthorized(quicksight_account_exists, client2, dashboard1):
def test_delete_dashboard_unauthorized(client2, dashboard1):
assert_that(delete_dashboard).raises(GqlError).when_called_with(client2, dashboard1.dashboardUri).contains(
'UnauthorizedOperation', 'DELETE_DASHBOARD', dashboard1.dashboardUri
)
Loading