Skip to content

Commit

Permalink
Add s3 auth test
Browse files Browse the repository at this point in the history
  • Loading branch information
vshepard committed Dec 15, 2023
1 parent 61d3ff6 commit c7e2857
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/s3_auth_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from s3.test_utils.base_test import S3BaseTest


class AuthorizationTest(S3BaseTest):
"""
Check connect to S3 via pre_start_checks() function
calling pg_probackup init --s3
test that s3 keys allow to connect to all types of storages
"""

def test_s3_authorisation(self):
console_output = self.pb.init(options=["--log-level-console=VERBOSE"])

self.assertNotIn(': 403', console_output) # Because we can have just '403' substring in timestamp
self.assertMessage(console_output, contains='S3_pre_start_check successful')
self.assertMessage(console_output, contains='HTTP response: 200')
self.assertIn(
f"INFO: Backup catalog '{self.backup_dir}' successfully initialized",
console_output)

def test_log_level_file_requires_log_directory(self):
console_output = self.pb.init(options=["--log-level-file=VERBOSE"],
skip_log_directory=True,
expect_error=True)

self.assertMessage(console_output,
contains='ERROR: Cannot save S3 logs to a file. You must specify --log-directory option when'
' running backup with --log-level-file option enabled')

0 comments on commit c7e2857

Please sign in to comment.