Skip to content

[DPE-7520] Test that the charmed_read role cannot write data #945

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

Merged
merged 74 commits into from
Jun 13, 2025

Conversation

marceloneppel
Copy link
Member

@marceloneppel marceloneppel commented Jun 9, 2025

Issue

Currently, we only test that the charmed_read role can read data, and not that it can’t write data.

Solution

Add a check in the current integration test to verify that the role cannot write data.

Checklist

  • I have added or updated any relevant documentation.
  • I have cleaned any remaining cloud resources from my accounts.

shayancanonical and others added 30 commits May 6, 2025 10:58
Signed-off-by: Marcelo Henrique Neppel <[email protected]>
Signed-off-by: Marcelo Henrique Neppel <[email protected]>
Signed-off-by: Marcelo Henrique Neppel <[email protected]>
Signed-off-by: Marcelo Henrique Neppel <[email protected]>
…oles' into feature/16_predefined_catalog_roles

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
Signed-off-by: Marcelo Henrique Neppel <[email protected]>
Signed-off-by: Marcelo Henrique Neppel <[email protected]>
Signed-off-by: Marcelo Henrique Neppel <[email protected]>
Signed-off-by: Marcelo Henrique Neppel <[email protected]>
Signed-off-by: Marcelo Henrique Neppel <[email protected]>
…and create a table

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
…nup' into feature/16_predefined_catalog_roles

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
…into feature/16_predefined_roles_cleanup

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
…nup' into feature/16_predefined_catalog_roles

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
…into feature/16_predefined_roles_cleanup

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
…nup' into feature/16_predefined_catalog_roles

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
…into feature/16_predefined_roles_cleanup

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
Signed-off-by: Marcelo Henrique Neppel <[email protected]>
…nup' into feature/16_predefined_catalog_roles

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
…ned_roles_cleanup

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
…nup' into feature/16_predefined_catalog_roles

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
…ned_catalog_roles

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
@marceloneppel marceloneppel added the not bug or enhancement PR is not 'bug' or 'enhancement'. For release notes label Jun 9, 2025
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.13%. Comparing base (0523e6c) to head (d67738f).
Report is 2 commits behind head on 16/edge.

Additional details and impacted files
@@           Coverage Diff            @@
##           16/edge     #945   +/-   ##
========================================
  Coverage    70.13%   70.13%           
========================================
  Files           16       16           
  Lines         3817     3817           
  Branches       554      554           
========================================
  Hits          2677     2677           
  Misses        1002     1002           
  Partials       138      138           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Base automatically changed from feature/16_predefined_catalog_roles to 16/edge June 9, 2025 13:33
…role-write-data

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
@marceloneppel marceloneppel changed the title Test that the charmed_read role cannot write data [DPE-7520] Test that the charmed_read role cannot write data Jun 9, 2025
@marceloneppel marceloneppel marked this pull request as ready for review June 9, 2025 18:31
Copy link
Contributor

@taurus-forever taurus-forever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, can we expand the testcase here a bit (to sleep better)?

Comment on lines 121 to 124
logger.info("Checking that the charmed_read role cannot write to the database")
with pytest.raises(psycopg2.errors.InsufficientPrivilege):
cursor.execute("CREATE TABLE test_table_2 (id INTEGER);")
connection.close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM here, should we also try here to INSERT into test_table?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I'll add that scenario.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done through 99f498c and 5be6d94.

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
…role-write-data

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
@marceloneppel marceloneppel merged commit 6cf8599 into 16/edge Jun 13, 2025
218 of 228 checks passed
@marceloneppel marceloneppel deleted the test-charmed-read-role-write-data branch June 13, 2025 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not bug or enhancement PR is not 'bug' or 'enhancement'. For release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants