def test_init_auth(self, create_context, get_user, impersonate_token): os.environ[ POLYAXON_KEYS_RUN_INSTANCE] = "owner.project.runs.{}".format( uuid.uuid4().hex) create_auth_context() assert impersonate_token.call_count == 1 assert create_context.call_count == 1 assert get_user.call_count == 1 del os.environ[POLYAXON_KEYS_RUN_INSTANCE]
def test_init_auth(self, create_context, get_user, impersonate_token): settings.CLIENT_CONFIG.is_managed = True os.environ[POLYAXON_KEYS_RUN_INSTANCE] = "owner.project.runs.{}".format( uuid.uuid4().hex ) create_auth_context() assert impersonate_token.call_count == 1 assert create_context.call_count == 1 assert get_user.call_count == 1 del os.environ[POLYAXON_KEYS_RUN_INSTANCE] settings.CLIENT_CONFIG.is_managed = None
def test_raise_if_env_var_not_correct(self): os.environ[POLYAXON_KEYS_RUN_INSTANCE] = "foo" with self.assertRaises(PolyaxonContainerException): create_auth_context() del os.environ[POLYAXON_KEYS_RUN_INSTANCE]
def test_raise_if_env_var_not_found(self): with self.assertRaises(PolyaxonContainerException): create_auth_context()
def auth(): """Create auth context.""" from polyaxon.init.auth import create_auth_context create_auth_context()