import requests from tests.integration import config def test_get_subaccount_applications_orchard(bearer_token_with_vendor_star): """GET /subaccont/{subaccount_id}/applications for an Orchard Subaccount.""" response = requests.get( '{qa_base_url}/subaccount/{subaccount_id}/applications'.format( qa_base_url=config.QA_BASE_URL, subaccount_id='313edc35-853c-4a57-9cb8-c19cb265f39b' ), headers={ 'authorization': f'Bearer {bearer_token_with_vendor_star}', }, ) assert response.status_code == 200 expected_applications = [ { 'application_id': 'CUSTOMER_ACCOUNTING_APP', 'roles': ['CUSTOMER_ACCOUNTING_BASE_ROLE'], 'url': 'https://accounting.theorchard.com', }, { 'application_id': 'INSIGHTS_APP', 'roles': ['INSIGHTS_BASE_ROLE'], 'url': 'https://insights.theorchard.com', }, { 'application_id': 'WORKSTATION_ANALYTICS_APP', 'roles': ['WORKSTATION_ANALYTICS_BASE_ROLE'], 'url': 'https://workstation.theorchard.com/analytics', }, { 'application_id': 'WORKSTATION_CATALOG_APP', 'roles': ['WORKSTATION_CATALOG_ROLE'], 'url': 'https://workstation.theorchard.com/catalog', }, { 'application_id': 'SETTINGS_APP', 'roles': ['SETTINGS_BASE_ROLE', 'WORKSTATION_ADMIN_ROLE'], 'url': 'https://settings.theorchard.com', }, ] assert response.json().get('applications') == expected_applications def test_get_subaccount_applications_not_orchard(bearer_token_with_vendor_star): """GET /subaccont/{subaccount_id}/applications for a non Orchard Subaccount.""" response = requests.get( '{qa_base_url}/subaccount/{subaccount_id}/applications'.format( qa_base_url=config.QA_BASE_URL, subaccount_id='1fab3fe8-c9a6-488a-9a96-959734a93997' ), headers={ 'authorization': f'Bearer {bearer_token_with_vendor_star}', }, ) assert response.status_code == 200 expected_applications = [ { 'application_id': 'CUSTOMER_ACCOUNTING_APP', 'roles': ['CUSTOMER_ACCOUNTING_BASE_ROLE'], 'url': 'https://accounting.theorchard.com', }, { 'application_id': 'INSIGHTS_APP', 'roles': ['INSIGHTS_BASE_ROLE'], 'url': 'https://insights.theorchard.com', }, { 'application_id': 'WORKSTATION_CATALOG_APP', 'roles': ['WORKSTATION_CATALOG_ROLE'], 'url': 'https://workstation.theorchard.com/catalog', }, { 'application_id': 'SETTINGS_APP', 'roles': ['SETTINGS_BASE_ROLE', 'WORKSTATION_ADMIN_ROLE'], 'url': 'https://settings.theorchard.com', }, ] assert response.json().get('applications') == expected_applications def test_no_access(bearer_token_without_vendor_star): """GET /subaccount/{subaccount_id}/applications no access.""" response = requests.get( '{qa_base_url}/subaccount/{subaccount_id}/applications'.format( qa_base_url=config.QA_BASE_URL, subaccount_id='313edc35-853c-4a57-9cb8-c19cb265f39b' ), headers={ 'authorization': f'Bearer {bearer_token_without_vendor_star}', }, ) assert response.status_code == 403