"""Baseline integration tests for POST /localization/product/{product_id}/language/{language_id}. These tests capture the current (pre-Permissions Platform) behavior of the endpoint across the integration test personas. The WIP rows are expected to flip once the endpoint is migrated to use PP authorization checks. """ import pytest import requests TEST_PRODUCT_ID = 2615208 TEST_LANGUAGE_ID = 12 TEST_PAYLOAD = { 'product_name': 'PP integration test product name', 'short_synopsis': 'PP integration test short synopsis', } @pytest.mark.parametrize( 'header_fixture_name,expected_status_code', [ pytest.param( 'ows_product_user_headers', 200, id='OWS product user with valid JWT can create product localization', ), pytest.param( 'ows_product_content_user_headers', 200, id='OWS product content-profile user can create product localization', ), pytest.param( 'ows_product_pp_user_headers', 200, id=( 'PP user with content_ccm_digital_audio_can_bulk_create role ' 'can create product localization' ), ), pytest.param( 'ows_product_pp_no_access_user_headers', 200, id=( 'PP-1310 WIP PP user without content_ccm_digital_audio_can_bulk_create ' 'role can currently create product localization' ), ), pytest.param( 'content_profile_headers', 200, id=( 'PP-1310 WIP ContentProfile headers (no JWT) can currently create ' 'product localization' ), ), pytest.param( 'unauthorized_headers', 200, id=( 'PP-1310 WIP Unauthorized headers (no JWT) can currently create ' 'product localization' ), ), ], ) def test_create_product_localization_authorization_matrix( header_fixture_name: str, expected_status_code: int, qa_ows_product_url: str, request: pytest.FixtureRequest, ) -> None: """Baseline auth matrix for POST /localization/product/{product_id}/language/{language_id}.""" url = ( f'{qa_ows_product_url}/localization/product/' f'{TEST_PRODUCT_ID}/language/{TEST_LANGUAGE_ID}' ) headers = request.getfixturevalue(header_fixture_name) result = requests.post(url, headers=headers, json=TEST_PAYLOAD) assert result.status_code == expected_status_code, result.text def test_create_product_localization_no_headers(qa_ows_product_url: str) -> None: """Baseline: anonymous (no headers) request currently returns 200. Once PP authorization is applied this is expected to return 401/403. """ url = ( f'{qa_ows_product_url}/localization/product/' f'{TEST_PRODUCT_ID}/language/{TEST_LANGUAGE_ID}' ) result = requests.post(url, json=TEST_PAYLOAD) assert result.status_code == 200, result.text