def setup_env_vars_for_xs_uaa(): os.environ[VCAP_SERVICES] = VCAP_SERVICES_V2 os.environ[MLP_USE_XSUAA] = 'true' os.environ[MLP_MLSERVICE_XSAPPNAME] = 'myxsappname!b53' os.environ[MLP_MLSERVICE_DEFAULT_SCOPES] = 'read,write' os.environ[ MLP_UAA_PUBLIC_KEY] = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx/jN5v1mp/TVn9nTQoYVIUfCsUDHa3Upr5tDZC7mzlTrN2PnwruzyS7w1Jd+StqwW4/vn87ua2YlZzU8Ob0jR4lbOPCKaHIi0kyNtJXQvQ7LZPG8epQLbx0IIP/WLVVVtB8bL5OWuHma3pUnibbmATtbOh5LksQ2zLMngEjUF52JQyzTpjoQkahp0BNe/drlAqO253keiY63FL6belKjJGmSqdnotSXxB2ym+HQ0ShaNvTFLEvi2+ObkyjGWgFpQaoCcGq0KX0y0mPzOvdFsNT+rBFdkHiK+Jl638Sbim1z9fItFbH9hiVwY37R9rLtH1YKi3PuATMjf/DJ7mUluDQIDAQAB\n-----END PUBLIC KEY-----" mlpkitsecurity._prepare_env_vars()
def test_should_try_populate_MLP_MLP_UAA_PUBLIC_KEY_and_MLP_MLSERVICE_XSAPPNAME_from_xsuaa_master_instance(self): if os.getenv(MLP_UAA_PUBLIC_KEY): del os.environ[MLP_UAA_PUBLIC_KEY] if os.getenv(MLP_UAA_BASE_URL): del os.environ[MLP_UAA_BASE_URL] if os.getenv(MLP_MLSERVICE_XSAPPNAME): del os.environ[MLP_MLSERVICE_XSAPPNAME] _prepare_env_vars() # no XS UAA master instance is bound, public key and xsappname couldn't be populated. only logger is called self.assertIsNone(os.getenv(MLP_UAA_PUBLIC_KEY)) self.assertIsNone(os.getenv(MLP_MLSERVICE_XSAPPNAME))
def test_should_populate_MLP_MLP_UAA_PUBLIC_KEY_and_MLP_MLSERVICE_XSAPPNAME_from_xsuaa_master_instance(self): # VCAP_SERVICES contains XSUAA master instance os.environ[VCAP_SERVICES] = VCAP_SERVICES_V3 if os.getenv(MLP_UAA_PUBLIC_KEY): del os.environ[MLP_UAA_PUBLIC_KEY] if os.getenv(MLP_UAA_BASE_URL): del os.environ[MLP_UAA_BASE_URL] if os.getenv(MLP_MLSERVICE_XSAPPNAME): del os.environ[MLP_MLSERVICE_XSAPPNAME] _prepare_env_vars() self.assertIsNotNone(os.getenv(MLP_UAA_PUBLIC_KEY)) self.assertIsNotNone(os.getenv(MLP_MLSERVICE_XSAPPNAME))
def test_missing_MLP_MLP_UAA_PUBLIC_KEY_should_not_cause_error_at_classloading(self): del os.environ[MLP_MLSERVICE_DEFAULT_SCOPES] # only logger is called _prepare_env_vars()
def test_missing_MLP_MLP_UAA_PUBLIC_KEY_should_not_cause_error_at_classloading_if_MLP_UAA_BASE_URL_is_set(self): del os.environ[MLP_MLSERVICE_DEFAULT_SCOPES] os.environ[MLP_UAA_BASE_URL] = "some-url" # no logger called _prepare_env_vars()
def test_missing_MLP_MLSERVICE_XSAPPNAME_should_not_cause_error_at_classloading(self): del os.environ[MLP_MLSERVICE_XSAPPNAME] # only logger is called _prepare_env_vars()
def test_missing_VCAP_SERVICES_should_not_cause_error_at_classloading(self): del os.environ[VCAP_SERVICES] # only logger is called _prepare_env_vars()
def test_prepare_env_vars_should_not_throw_error_if_CLEA_UAA_SERVER_BASE_URL_is_not_set( self): del os.environ[CLEA_UAA_SERVER_BASE_URL] _prepare_env_vars() # only logger is called
def test_check_cf_uaa(self): _prepare_env_vars() # only logger is called