def get_auth_data(): """ Authenticate and return a dictionary containing the storage url and auth token. """ result = { 'storage_url': None, 'auth_token': None} endpoint_config = UserAuthConfig() user_config = UserConfig() objectstorage_config = ObjectStorageConfig() auth_provider = AuthProvider() access_data = auth_provider.get_access_data( endpoint_config, user_config) if endpoint_config.strategy.lower() == 'saio_tempauth': result['storage_url'] = access_data.storage_url result['auth_token'] = access_data.auth_token else: service = access_data.get_service( objectstorage_config.identity_service_name) endpoint = service.get_endpoint(objectstorage_config.region) result['storage_url'] = endpoint.public_url result['auth_token'] = access_data.token.id_ return result
def setUpClass(cls): super(ObjectStorageFixture, cls).setUpClass() endpoint_config = UserAuthConfig() user_config = UserConfig() objectstorage_config = ObjectStorageConfig() objectstorage_api_config = ObjectStorageAPIConfig() auth_provider = AuthProvider() access_data = auth_provider.get_access_data(endpoint_config, user_config) service = access_data.get_service( objectstorage_config.identity_service_name) endpoint = service.get_endpoint(objectstorage_config.region) storage_url = endpoint.public_url auth_token = access_data.token.id_ cls.base_container_name = objectstorage_api_config.base_container_name cls.base_object_name = objectstorage_api_config.base_object_name cls.client = ObjectStorageAPIClient(storage_url, auth_token) cls.behaviors = ObjectStorageAPI_Behaviors(client=cls.client)
def __init__(self, images_client, images_config): super(ImagesV1Behaviors, self).__init__() self.config = images_config self.client = images_client access_data = AuthProvider().get_access_data() self.tenants_client = TenantsAPI_Client(UserAuthConfig().auth_endpoint, access_data.token.id_, 'json', 'json')
def setUpClass(cls): super(ImagesV1Fixture, cls).setUpClass() access_data = AuthProvider().get_access_data() images_endpoint = '{base_url}/v1'.format(base_url=cls.config.base_url) cls.remote_image = cls.config.remote_image cls.http_image = cls.config.http_image cls.tenants_client = TenantsAPI_Client(UserAuthConfig().auth_endpoint, access_data.token.id_, 'json', 'json') cls.api_client = ImagesV1Client(images_endpoint, access_data.token.id_, 'json', 'json') cls.behaviors = ImagesV1Behaviors(cls.api_client, cls.config) cls.tenant_ids = TenantsBehaviors( cls.tenants_client).get_all_tenant_ids()