コード例 #1
0
 def test_keymgr_store_with_external(self, client_for_admin):
     self.override_config('use_external_key_manager', True)
     key = 'test_key_super_secret'
     actual_keyref = 'test_key_reference'
     secret = mock.Mock()
     secret.store = mock.Mock(return_value=actual_keyref)
     secrets_manager = mock.Mock()
     secrets_manager.create = mock.Mock(return_value=secret)
     client = mock.Mock(secrets=secrets_manager)
     client_for_admin.return_value = client
     # with external key manager, store should return a key reference
     keyref = keymgr.store(key)
     secrets_manager.create.assert_called_with(
         payload=key, payload_content_type='text/plain')
     secret.store.assert_called_once_with()
     self.assertEqual(actual_keyref, keyref)
コード例 #2
0
 def test_keymgr_store_no_external(self):
     actual_key = 'test_key_super_secret'
     # with no external key manager, store should return the argument
     keyref = keymgr.store(actual_key)
     self.assertEqual(actual_key, keyref)