#NEWLINE# def generate_test_data( pki = False ) : #NEWLINE# #INDENT# 'Builds a set of test_data data as returned by Keystone V2.' #NEWLINE# test_data = TestDataContainer ( ) #NEWLINE# keystone_service = { #NEWLINE# #INDENT# 'type' : 'identity' , #NEWLINE# 'id' : uuid . uuid4 ( ) . hex , #NEWLINE# 'endpoints' : [ { #NEWLINE# #INDENT# 'url' : 'http://admin.localhost:35357/v3' , #NEWLINE# 'region' : 'RegionOne' , #NEWLINE# 'interface' : 'admin' , #NEWLINE# 'id' : uuid . uuid4 ( ) . hex , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'url' : 'http://internal.localhost:5000/v3' , #NEWLINE# 'region' : 'RegionOne' , #NEWLINE# 'interface' : 'internal' , #NEWLINE# 'id' : uuid . uuid4 ( ) . hex , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'url' : 'http://public.localhost:5000/v3' , #NEWLINE# 'region' : 'RegionOne' , #NEWLINE# 'interface' : 'public' , #NEWLINE# 'id' : uuid . uuid4 ( ) . hex , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } #NEWLINE# domain_dict = { #NEWLINE# #INDENT# 'id' : uuid . uuid4 ( ) . hex , #NEWLINE# 'name' : 'domain' , #NEWLINE# 'description' : '' , #NEWLINE# 'enabled' : True , #NEWLINE# #UNINDENT# } #NEWLINE# test_data . domain = domains . Domain ( domains . DomainManager ( None ) , domain_dict , loaded = True ) #NEWLINE# user_dict = { #NEWLINE# #INDENT# 'id' : uuid . uuid4 ( ) . hex , #NEWLINE# 'name' : 'gabriel' , #NEWLINE# 'email' : 'gabriel@example.com' , #NEWLINE# 'password' : 'swordfish' , #NEWLINE# 'domain_id' : domain_dict [ 'id' ] , #NEWLINE# 'token' : '' , #NEWLINE# 'enabled' : True , #NEWLINE# #UNINDENT# } #NEWLINE# test_data . user = users . User ( users . UserManager ( None ) , user_dict , loaded = True ) #NEWLINE# project_dict_1 = { #NEWLINE# #INDENT# 'id' : uuid . uuid4 ( ) . hex , #NEWLINE# 'name' : 'tenant_one' , #NEWLINE# 'description' : '' , #NEWLINE# 'domain_id' : domain_dict [ 'id' ] , #NEWLINE# 'enabled' : True , #NEWLINE# #UNINDENT# } #NEWLINE# project_dict_2 = { #NEWLINE# #INDENT# 'id' : uuid . uuid4 ( ) . hex , #NEWLINE# 'name' : 'tenant_two' , #NEWLINE# 'description' : '' , #NEWLINE# 'domain_id' : domain_dict [ 'id' ] , #NEWLINE# 'enabled' : False , #NEWLINE# #UNINDENT# } #NEWLINE# test_data . project_one = projects . Project ( projects . ProjectManager ( None ) , project_dict_1 , loaded = True ) #NEWLINE# test_data . project_two = projects . Project ( projects . ProjectManager ( None ) , project_dict_2 , loaded = True ) #NEWLINE# role_dict = { #NEWLINE# #INDENT# 'id' : uuid . uuid4 ( ) . hex , #NEWLINE# 'name' : 'Member' , #NEWLINE# #UNINDENT# } #NEWLINE# test_data . role = roles . Role ( roles . RoleManager , role_dict ) #NEWLINE# nova_service = { #NEWLINE# #INDENT# 'type' : 'compute' , #NEWLINE# 'id' : uuid . uuid4 ( ) . hex , #NEWLINE# 'endpoints' : [ { #NEWLINE# #INDENT# 'url' : ( 'http://nova-admin.localhost:8774/v2.0/%s' % project_dict_1 [ 'id' ] ) , #NEWLINE# 'region' : 'RegionOne' , #NEWLINE# 'interface' : 'admin' , #NEWLINE# 'id' : uuid . uuid4 ( ) . hex , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'url' : ( 'http://nova-internal.localhost:8774/v2.0/%s' % project_dict_1 [ 'id' ] ) , #NEWLINE# 'region' : 'RegionOne' , #NEWLINE# 'interface' : 'internal' , #NEWLINE# 'id' : uuid . uuid4 ( ) . hex , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'url' : ( 'http://nova-public.localhost:8774/v2.0/%s' % project_dict_1 [ 'id' ] ) , #NEWLINE# 'region' : 'RegionOne' , #NEWLINE# 'interface' : 'public' , #NEWLINE# 'id' : uuid . uuid4 ( ) . hex , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'url' : ( 'http://nova2-admin.localhost:8774/v2.0/%s' % project_dict_1 [ 'id' ] ) , #NEWLINE# 'region' : 'RegionTwo' , #NEWLINE# 'interface' : 'admin' , #NEWLINE# 'id' : uuid . uuid4 ( ) . hex , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'url' : ( 'http://nova2-internal.localhost:8774/v2.0/%s' % project_dict_1 [ 'id' ] ) , #NEWLINE# 'region' : 'RegionTwo' , #NEWLINE# 'interface' : 'internal' , #NEWLINE# 'id' : uuid . uuid4 ( ) . hex , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'url' : ( 'http://nova2-public.localhost:8774/v2.0/%s' % project_dict_1 [ 'id' ] ) , #NEWLINE# 'region' : 'RegionTwo' , #NEWLINE# 'interface' : 'public' , #NEWLINE# 'id' : uuid . uuid4 ( ) . hex , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } #NEWLINE# tomorrow = ( datetime_safe . datetime . now ( ) + datetime . timedelta ( days = 1 ) ) #NEWLINE# expiration = datetime_safe . datetime . isoformat ( tomorrow ) #NEWLINE# if pki : #NEWLINE# #INDENT# auth_token = ( cms . PKI_ASN1_PREFIX + uuid . uuid4 ( ) . hex ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# auth_token = uuid . uuid4 ( ) . hex #NEWLINE# #UNINDENT# auth_response_headers = { #NEWLINE# #INDENT# 'X-Subject-Token' : auth_token , #NEWLINE# #UNINDENT# } #NEWLINE# auth_response = TestResponse ( { #NEWLINE# #INDENT# 'headers' : auth_response_headers , #NEWLINE# #UNINDENT# } ) #NEWLINE# scoped_token_dict = { #NEWLINE# #INDENT# 'token' : { #NEWLINE# #INDENT# 'methods' : [ 'password' ] , #NEWLINE# 'expires_at' : expiration , #NEWLINE# 'project' : { #NEWLINE# #INDENT# 'id' : project_dict_1 [ 'id' ] , #NEWLINE# 'name' : project_dict_1 [ 'name' ] , #NEWLINE# 'domain' : { #NEWLINE# #INDENT# 'id' : domain_dict [ 'id' ] , #NEWLINE# 'name' : domain_dict [ 'name' ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'user' : { #NEWLINE# #INDENT# 'id' : user_dict [ 'id' ] , #NEWLINE# 'name' : user_dict [ 'name' ] , #NEWLINE# 'domain' : { #NEWLINE# #INDENT# 'id' : domain_dict [ 'id' ] , #NEWLINE# 'name' : domain_dict [ 'name' ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'roles' : [ role_dict ] , #NEWLINE# 'catalog' : [ keystone_service , nova_service ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# test_data . scoped_access_info = access . create ( resp = auth_response , body = scoped_token_dict ) #NEWLINE# domain_token_dict = { #NEWLINE# #INDENT# 'token' : { #NEWLINE# #INDENT# 'methods' : [ 'password' ] , #NEWLINE# 'expires_at' : expiration , #NEWLINE# 'domain' : { #NEWLINE# #INDENT# 'id' : domain_dict [ 'id' ] , #NEWLINE# 'name' : domain_dict [ 'name' ] , #NEWLINE# #UNINDENT# } , #NEWLINE# 'user' : { #NEWLINE# #INDENT# 'id' : user_dict [ 'id' ] , #NEWLINE# 'name' : user_dict [ 'name' ] , #NEWLINE# 'domain' : { #NEWLINE# #INDENT# 'id' : domain_dict [ 'id' ] , #NEWLINE# 'name' : domain_dict [ 'name' ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'roles' : [ role_dict ] , #NEWLINE# 'catalog' : [ keystone_service , nova_service ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# test_data . domain_scoped_access_info = access . create ( resp = auth_response , body = domain_token_dict ) #NEWLINE# unscoped_token_dict = { #NEWLINE# #INDENT# 'token' : { #NEWLINE# #INDENT# 'methods' : [ 'password' ] , #NEWLINE# 'expires_at' : expiration , #NEWLINE# 'user' : { #NEWLINE# #INDENT# 'id' : user_dict [ 'id' ] , #NEWLINE# 'name' : user_dict [ 'name' ] , #NEWLINE# 'domain' : { #NEWLINE# #INDENT# 'id' : domain_dict [ 'id' ] , #NEWLINE# 'name' : domain_dict [ 'name' ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'catalog' : [ keystone_service ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# test_data . unscoped_access_info = access . create ( resp = auth_response , body = unscoped_token_dict ) #NEWLINE# test_data . service_catalog = service_catalog . ServiceCatalogV3 ( [ keystone_service , nova_service ] ) #NEWLINE# federated_scoped_token_dict = { #NEWLINE# #INDENT# 'token' : { #NEWLINE# #INDENT# 'methods' : [ 'password' ] , #NEWLINE# 'expires_at' : expiration , #NEWLINE# 'project' : { #NEWLINE# #INDENT# 'id' : project_dict_1 [ 'id' ] , #NEWLINE# 'name' : project_dict_1 [ 'name' ] , #NEWLINE# 'domain' : { #NEWLINE# #INDENT# 'id' : domain_dict [ 'id' ] , #NEWLINE# 'name' : domain_dict [ 'name' ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'user' : { #NEWLINE# #INDENT# 'id' : user_dict [ 'id' ] , #NEWLINE# 'name' : user_dict [ 'name' ] , #NEWLINE# 'domain' : { #NEWLINE# #INDENT# 'id' : domain_dict [ 'id' ] , #NEWLINE# 'name' : domain_dict [ 'name' ] , #NEWLINE# #UNINDENT# } , #NEWLINE# 'OS-FEDERATION' : { #NEWLINE# #INDENT# 'identity_provider' : 'ACME' , #NEWLINE# 'protocol' : 'OIDC' , #NEWLINE# 'groups' : [ { #NEWLINE# #INDENT# 'id' : uuid . uuid4 ( ) . hex , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'id' : uuid . uuid4 ( ) . hex , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'roles' : [ role_dict ] , #NEWLINE# 'catalog' : [ keystone_service , nova_service ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# test_data . federated_scoped_access_info = access . create ( resp = auth_response , body = federated_scoped_token_dict ) #NEWLINE# federated_unscoped_token_dict = { #NEWLINE# #INDENT# 'token' : { #NEWLINE# #INDENT# 'methods' : [ 'password' ] , #NEWLINE# 'expires_at' : expiration , #NEWLINE# 'user' : { #NEWLINE# #INDENT# 'id' : user_dict [ 'id' ] , #NEWLINE# 'name' : user_dict [ 'name' ] , #NEWLINE# 'domain' : { #NEWLINE# #INDENT# 'id' : domain_dict [ 'id' ] , #NEWLINE# 'name' : domain_dict [ 'name' ] , #NEWLINE# #UNINDENT# } , #NEWLINE# 'OS-FEDERATION' : { #NEWLINE# #INDENT# 'identity_provider' : 'ACME' , #NEWLINE# 'protocol' : 'OIDC' , #NEWLINE# 'groups' : [ { #NEWLINE# #INDENT# 'id' : uuid . uuid4 ( ) . hex , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'id' : uuid . uuid4 ( ) . hex , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'catalog' : [ keystone_service ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# test_data . federated_unscoped_access_info = access . create ( resp = auth_response , body = federated_unscoped_token_dict ) #NEWLINE# return test_data