class Soar::Registry::Identity::Test::OrchestrationProvider::Customer::Uuid
Public Class Methods
new()
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 15 def initialize Faker::UniqueGenerator.clear @identity = { "ID" => Faker::Number.unique.number(4).to_i, "First_Name" => Faker::Name.unique.first_name, "Surname" => Faker::Name.unique.last_name, "Notifyemail_Invoice" => "#{Faker::Internet.unique.email}", "Client_Number" => "C#{Faker::Number.unique.number(10)}" } @identity_uuid = Soar::Authentication::IdentityUuidTranslator::UuidGenerator.generate("#{Soar::Authentication::IdentityUuidTranslator::Provider::Customer::PREFIX}#{@identity['ID']}") end
Public Instance Methods
get_identity_attributes()
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 96 def get_identity_attributes begin @result = @idr.get_attributes(@identity_uuid) rescue SoarIdm::IdentityError => e @error = e end end
get_role_attributes()
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 92 def get_role_attributes @result = @idr.get_attributes(@identity_uuid, @roles.nil? ? Faker::Company.unique.profession : @roles[0]['role']) end
get_roles()
click to toggle source
when
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 88 def get_roles @result = @idr.get_roles(@identity_uuid) end
given_identity()
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 62 def given_identity wait_for_database do create_identity_table(@identity_directory) @identity_directory.put(@identity) end end
given_identity_directory()
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 27 def given_identity_directory wait_for_database do @identity_directory_config = YAML.load_file("config/#{ENV['CUSTOMER_DIRECTORY_CONFIG_FILE']}") @identity_directory = Soar::Registry::Directory.new( Soar::Registry::Directory::Provider::Mysql.new(@identity_directory_config['config'].map { |k, v| [k.to_sym, v] }.to_h) ) end end
given_identity_registry()
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 69 def given_identity_registry identity_provider = Soar::Registry::Identity::Provider::Customer::Uuid.new({ identity_directory: Soar::Registry::Identity::Directory.new({ directory: @identity_directory, fetch_index: 'ID', search_index: 'Notifyemail_Invoice' }), role_directory: Soar::Registry::Identity::Directory.new({ directory: @roles_directory, fetch_index: ['identity_uuid', 'identity_role'], search_index: 'identity_uuid' }) }) @idr = Soar::Registry::Identity.new(identity_provider) end
given_role_with_attributes()
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 51 def given_role_with_attributes @roles = generate_roles() @roles[0]['attributes'] = { 'profiles' => [@identity['Client_Number'], "C#{Faker::Number.unique.number(10)}"] } wait_for_database { create_roles_table(@roles_directory, @roles_directory_config) populate_roles_table(@roles_directory, @roles, @identity_uuid) } end
given_roles()
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 43 def given_roles @roles = generate_roles() wait_for_database { create_roles_table(@roles_directory, @roles_directory_config) populate_roles_table(@roles_directory, @roles, @identity_uuid) } end
given_roles_directory()
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 36 def given_roles_directory @roles_directory_config = YAML.load_file("config/#{ENV['ROLES_DIRECTORY_CONFIG_FILE']}") @roles_directory = Soar::Registry::Directory.new( Soar::Registry::Directory::Provider::DynamoDb.new(@roles_directory_config['config'].map { |k, v| [k.to_sym, v]}.to_h) ) end
identity_attributes?()
click to toggle source
then
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 106 def identity_attributes? roles = {} @roles.each do |entry| roles[entry['role']] = {} end if not @roles.nil? expectation = { "identity_uuid" => @identity_uuid, "firstname" => @identity['First_Name'], "lastname" => @identity['Surname'], "email" => @identity['Notifyemail_Invoice'], "roles" => roles } @result == expectation end
identity_error?()
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 149 def identity_error? @error.is_a?(SoarIdm::IdentityError) end
nil?()
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 121 def nil? @result == nil end
no_roles?()
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 145 def no_roles? @result == [] end
role_with_attributes?()
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 131 def role_with_attributes? role_with_attributes = { @roles[0]['role'] => Hashie.stringify_keys(@roles[0]['attributes']) } @result == role_with_attributes end
role_with_empty_attributes?()
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 125 def role_with_empty_attributes? @result == { @roles[0]['role'] => {} } end
roles?()
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 138 def roles? roles = @roles.map do |entry| entry['role'] end @result.sort == roles.sort end
Private Instance Methods
create_identity_table(identity_directory)
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 183 def create_identity_table(identity_directory) identity_directory.provider.client.query("DROP TABLE IF EXISTS `Client`") identity_directory.provider.client.query("CREATE TABLE Client ( ID int(11) NOT NULL AUTO_INCREMENT, Client_Number varchar(15) NOT NULL DEFAULT '', First_Name varchar(70) DEFAULT NULL, Surname varchar(70) DEFAULT NULL, Notifyemail_Invoice text, PRIMARY KEY (ID), KEY Notifyemail_Invoice (Notifyemail_Invoice(20)), KEY Client_Number (Client_Number))") end
create_roles_table(roles_directory, roles_directory_config)
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 176 def create_roles_table(roles_directory, roles_directory_config) roles_directory.provider.recreate_table({ name: roles_directory_config['config']['table']['name'], structure: JSON.parse(File.read("lib/soar/registry/identity/test/fixtures/roles_table.json")) }) end
deep_copy(o)
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 188 def deep_copy(o) Marshal.load(Marshal.dump(o)) end
generate_roles()
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 155 def generate_roles() return [{ 'source' => "#{Soar::Authentication::IdentityUuidTranslator::Provider::Customer::PREFIX}#{@identity['ID']}", 'role' => Soar::Authentication::IdentityUuidTranslator::Provider::Customer::ROLE },{ 'role' => Faker::Company.unique.profession }] end
populate_roles_table(roles_directory, roles, identity_uuid)
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 164 def populate_roles_table(roles_directory, roles, identity_uuid) roles.each { |role| entry = { "identity_uuid" => identity_uuid, "identity_role" => role['role'] } entry['identity_source'] = role['source'] if role.key?('source') entry['identity_role_attributes'] = role['attributes'] if role.key?('attributes') roles_directory.put(entry) } end
wait_for_database() { || ... }
click to toggle source
# File lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb, line 192 def wait_for_database return 10.times do |i| begin break yield rescue Soar::Registry::Directory::Error::NetworkingError, Net::LDAP::Error => e sleep(10) end end end