Skip to content

Commit

Permalink
Fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
galvana committed Dec 3, 2024
1 parent f85139c commit c1c81c9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
24 changes: 9 additions & 15 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1604,36 +1604,30 @@ def load_default_data_uses(db):
DataUse.create(db=db, data=data_use.model_dump(mode="json"))


def generate_role_header_for_user(user) -> Dict[str, str]:
payload = {
JWE_PAYLOAD_ROLES: user.permissions.roles,
JWE_PAYLOAD_CLIENT_ID: user.client.id,
JWE_ISSUED_AT: datetime.now().isoformat(),
}
jwe = generate_jwe(json.dumps(payload), CONFIG.security.app_encryption_key)
return {"Authorization": "Bearer " + jwe}


@pytest.fixture
def owner_auth_header(owner_user):
return generate_role_header_for_user(owner_user)
return generate_role_header_for_user(owner_user, owner_user.client.roles)


@pytest.fixture
def contributor_auth_header(contributor_user):
return generate_role_header_for_user(contributor_user)
return generate_role_header_for_user(
contributor_user, contributor_user.client.roles
)


@pytest.fixture
def viewer_auth_header(viewer_user):
return generate_role_header_for_user(viewer_user)
return generate_role_header_for_user(viewer_user, viewer_user.client.roles)


@pytest.fixture
def approver_auth_header(approver_user):
return generate_role_header_for_user(approver_user)
return generate_role_header_for_user(approver_user, approver_user.client.roles)


@pytest.fixture
def viewer_and_approver_auth_header(viewer_and_approver_user):
return generate_role_header_for_user(viewer_and_approver_user)
return generate_role_header_for_user(
viewer_and_approver_user, viewer_and_approver_user.client.roles
)
2 changes: 2 additions & 0 deletions tests/ops/api/v1/endpoints/test_dataset_test_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ def test_dataset_reachability(
assert set(response.json().keys()) == {"reachable", "details"}


@pytest.mark.integration_external
@pytest.mark.integration_postgres
class TestDatasetTest:
@pytest.fixture(scope="function")
def default_access_policy(self, db) -> None:
Expand Down
2 changes: 2 additions & 0 deletions tests/ops/service/dataset/test_dataset_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def test_get_identities_and_references(
assert required_identities == expected_required_identities


@pytest.mark.integration_external
@pytest.mark.integration_postgres
class TestRunTestAccessRequest:
@pytest.mark.usefixtures("postgres_integration_db")
def test_run_test_access_request(
Expand Down

0 comments on commit c1c81c9

Please sign in to comment.