From c7e28570e4f445f16228e8bb4dfabf7e264105d6 Mon Sep 17 00:00:00 2001 From: vshepard Date: Fri, 15 Dec 2023 13:20:58 +0100 Subject: [PATCH] Add s3 auth test --- tests/s3_auth_test.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/s3_auth_test.py diff --git a/tests/s3_auth_test.py b/tests/s3_auth_test.py new file mode 100644 index 00000000..780f324a --- /dev/null +++ b/tests/s3_auth_test.py @@ -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')