예제 #1
0
    def test_load_credentials_encrypted_credentials(self):
        """S3Driver - Load Encrypted Credentials

        In this test we save a (more or less) real credentials payload using S3 mocking. We
        use the driver to pull the payload out and ensure the returned Credentials object is
        in a stable state, and that we can retrieve the decrypt credentials from this object."""
        descriptor = 'test_descriptor'

        bucket = self._s3_driver.get_s3_secrets_bucket()
        key = self._s3_driver.get_s3_key(descriptor)

        creds = {'url': 'http://www.foo.bar/test',
                 'token': 'token_to_encrypt'}

        # Save encrypted credentials
        put_mock_creds(key, creds, bucket, REGION, KMS_ALIAS)

        credentials = self._s3_driver.load_credentials(descriptor)

        assert_is_not_none(credentials)
        assert_true(credentials.is_encrypted())

        loaded_creds = json.loads(credentials.get_data_kms_decrypted())

        assert_equal(len(loaded_creds), 2)
        assert_equal(loaded_creds['url'], u'http://www.foo.bar/test')
        assert_equal(loaded_creds['token'], u'token_to_encrypt')
예제 #2
0
 def setup(self):
     """Setup before each method"""
     self._mock_s3 = mock_s3()
     self._mock_s3.start()
     self._mock_kms = mock_kms()
     self._mock_kms.start()
     self._dispatcher = SlackOutput(None)
     remove_temp_secrets()
     output_name = self._dispatcher.output_cred_name(self.DESCRIPTOR)
     put_mock_creds(output_name, self.CREDS, self._dispatcher.secrets_bucket, REGION, KMS_ALIAS)
예제 #3
0
 def setup(self):
     """Setup before each method"""
     self._mock_s3 = mock_s3()
     self._mock_s3.start()
     self._mock_kms = mock_kms()
     self._mock_kms.start()
     self._dispatcher = PagerDutyIncidentOutput(None)
     self._dispatcher._base_url = self.CREDS['api']
     remove_temp_secrets()
     output_name = self._dispatcher.output_cred_name(self.DESCRIPTOR)
     put_mock_creds(output_name, self.CREDS, self._dispatcher.secrets_bucket, REGION, KMS_ALIAS)
예제 #4
0
    def test_load_creds(self):
        """OutputDispatcher - Load Credentials"""
        remove_temp_secrets()
        output_name = self._dispatcher.output_cred_name(self._descriptor)

        creds = {'url': 'http://www.foo.bar/test',
                 'token': 'token_to_encrypt'}

        put_mock_creds(output_name, creds, self._dispatcher.secrets_bucket, REGION, KMS_ALIAS)

        loaded_creds = self._dispatcher._load_creds(self._descriptor)

        assert_is_not_none(loaded_creds)
        assert_equal(len(loaded_creds), 2)
        assert_equal(loaded_creds['url'], u'http://www.foo.bar/test')
        assert_equal(loaded_creds['token'], u'token_to_encrypt')
예제 #5
0
    def test_load_creds(self):
        """OutputDispatcher - Load Credentials"""
        remove_temp_secrets()
        key = get_formatted_output_credentials_name(
            'test_service',
            self._descriptor
        )

        creds = {'url': 'http://www.foo.bar/test',
                 'token': 'token_to_encrypt'}

        put_mock_creds(key, creds,
                       self._dispatcher._credentials_provider._core_driver._bucket,
                       REGION, KMS_ALIAS)

        loaded_creds = self._dispatcher._load_creds(self._descriptor)

        assert_is_not_none(loaded_creds)
        assert_equal(len(loaded_creds), 2)
        assert_equal(loaded_creds['url'], u'http://www.foo.bar/test')
        assert_equal(loaded_creds['token'], u'token_to_encrypt')