def test_create(self): name = "mnubo.com-sa-{0}".format(str(uuid.uuid4().hex[:5])) acct = _utils.create_service_account(name=name) if _utils.is_reachable(acct.config): acct.create() from_get = acct.get() self.assertEqual(acct, from_get)
def test_create(self): name = "mnubo.com-sa-{0}".format(str(uuid.uuid4().hex[:5])) acct = _utils.create_service_account(name=name) if _utils.is_reachable(acct.config): acct.create() from_get = acct.get() self.assertEqual(acct, from_get)
def test_list(self): name = "mnubo.com-sa-{0}".format(str(uuid.uuid4().hex[:5])) acct = _utils.create_service_account(name=name) if _utils.is_reachable(acct.config): acct.create() _list = acct.list() for x in _list: self.assertIsInstance(x, K8sServiceAccount)
def test_init_with_name(self): name = "yoname" secret = _utils.create_service_account(name=name) self.assertIsNotNone(secret) self.assertIsInstance(secret, K8sServiceAccount) self.assertEqual(secret.name, name) self.assertEqual('default', secret.config.namespace) self.assertEqual('ServiceAccount', secret.obj_type)
def test_add_api_token(self): name = "mnubo.com-sa-{0}".format(str(uuid.uuid4().hex[:5])) acct = _utils.create_service_account(name=name) if _utils.is_reachable(acct.config): acct.create() acct.add_api_token() secrets = K8sSecret.api_tokens_for_service_account(config=acct.config, name=acct.name) self.assertEqual(2, len(secrets))
def test_list(self): name = "mnubo.com-sa-{0}".format(str(uuid.uuid4().hex[:5])) acct = _utils.create_service_account(name=name) if _utils.is_reachable(acct.config): acct.create() _list = acct.list() for x in _list: self.assertIsInstance(x, K8sServiceAccount)
def test_add_api_token(self): name = "mnubo.com-sa-{0}".format(str(uuid.uuid4().hex[:5])) acct = _utils.create_service_account(name=name) if _utils.is_reachable(acct.config): acct.create() acct.add_api_token() secrets = K8sSecret.api_tokens_for_service_account(config=acct.config, name=acct.name) self.assertEqual(2, len(secrets))
def test_init_with_name(self): name = "yoname" secret = _utils.create_service_account(name=name) self.assertIsNotNone(secret) self.assertIsInstance(secret, K8sServiceAccount) self.assertEqual(secret.name, name) self.assertEqual('default', secret.config.namespace) self.assertEqual('ServiceAccount', secret.obj_type)
def test_init_with_name_and_config(self): name = "yoname" nspace = "yomama" config = K8sConfig(kubeconfig=_utils.kubeconfig_fallback, namespace=nspace) secret = _utils.create_service_account(config=config, name=name) self.assertIsNotNone(secret) self.assertIsInstance(secret, K8sServiceAccount) self.assertEqual(secret.name, name) self.assertEqual(secret.config.namespace, nspace) self.assertEqual('ServiceAccount', secret.obj_type)
def test_add_image_pull_secret(self): name = "mnubo.com-sa-{0}".format(str(uuid.uuid4().hex[:5])) acct = _utils.create_service_account(name=name) data = {"auths": {"repo:port": {"auth": "authstring", "email": "*****@*****.**"}}} if _utils.is_reachable(acct.config): acct.create() secret = K8sSecret.create_image_pull_secret(config=acct.config, name=acct.name, data=data) acct.add_image_pull_secret(secret) secrets = K8sSecret.list_image_pull_secrets() self.assertEqual(1, len(secrets))
def test_init_with_name_and_config(self): name = "yoname" nspace = "yomama" config = K8sConfig(kubeconfig=_utils.kubeconfig_fallback, namespace=nspace) secret = _utils.create_service_account(config=config, name=name) self.assertIsNotNone(secret) self.assertIsInstance(secret, K8sServiceAccount) self.assertEqual(secret.name, name) self.assertEqual(secret.config.namespace, nspace) self.assertEqual('ServiceAccount', secret.obj_type)
def test_add_image_pull_secret(self): name = "mnubo.com-sa-{0}".format(str(uuid.uuid4().hex[:5])) acct = _utils.create_service_account(name=name) data = {"auths": {"repo:port": {"auth": "authstring", "email": "*****@*****.**"}}} if _utils.is_reachable(acct.config): acct.create() secret = K8sSecret.create_image_pull_secret(config=acct.config, name=acct.name, data=data) acct.add_image_pull_secret(secret) secrets = K8sSecret.list_image_pull_secrets() self.assertEqual(1, len(secrets))
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))
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))
def test_init_with_invalid_name(self): name = object() with self.assertRaises(SyntaxError): _utils.create_service_account(name=name)
def test_init_with_invalid_name(self): name = object() with self.assertRaises(SyntaxError): _utils.create_service_account(name=name)