Пример #1
0
 def test_create_service_account_api_token(self):
     sa = _utils.create_service_account(name='build-robot')
     if _utils.is_reachable(sa.config):
         sa.create()
         secret = K8sSecret.create_service_account_api_token(
             config=sa.config, name=sa.name)
         self.assertIsInstance(secret, K8sSecret)
         secrets = K8sSecret.api_tokens_for_service_account(
             config=sa.config, name=sa.name)
         self.assertEqual(2, len(secrets))
Пример #2
0
 def test_create_service_account_api_token(self):
     sa = _utils.create_service_account(name='build-robot')
     if _utils.is_reachable(sa.config):
         sa.create()
         secret = K8sSecret.create_service_account_api_token(
             config=sa.config,
             name=sa.name)
         self.assertIsInstance(secret, K8sSecret)
         secrets = K8sSecret.api_tokens_for_service_account(
             config=sa.config,
             name=sa.name)
         self.assertEqual(2, len(secrets))
Пример #3
0
 def test_init_no_args(self):
     try:
         K8sSecret()
         self.fail("Should not fail.")
     except SyntaxError:
         pass
     except IOError:
         pass
     except Exception as err:
         self.fail("Unhandled exception: [ {0} ]".format(
             err.__class__.__name__))
Пример #4
0
 def test_list_without_create(self):
     name = "yosecret-{0}".format(str(uuid.uuid4()))
     secret = utils.create_secret(name=name)
     if utils.is_reachable(secret.config.api_host):
         _list = secret.list()
         self.assertGreaterEqual(1,
                                 len(_list))  # service-account-token on GCE
         secrets = []
         for x in _list:
             s = Secret(x)
             k8s = K8sSecret(config=secret.config,
                             name=x['metadata']['name'])
             k8s.model = s
             secrets.append(k8s)
Пример #5
0
 def test_init_with_invalid_config(self):
     config = object()
     with self.assertRaises(SyntaxError):
         K8sSecret(config=config)