Class: Soar::Authentication::IdentityUuidTranslator::Test::OrchestrationProvider::Staff

Inherits:
Base
  • Object
show all
Defined in:
lib/soar/authentication/identity_uuid_translator/test/orchestration_provider/staff.rb

Instance Method Summary collapse

Methods inherited from Base

#given_identity_uuid_translator, #given_role_generator, #given_roles_directory, #request_identity_uuid

Instance Method Details

#given_authenticated_identifierObject



10
11
12
# File 'lib/soar/authentication/identity_uuid_translator/test/orchestration_provider/staff.rb', line 10

def given_authenticated_identifier
  @identifier = "#{Faker::Name.first_name.downcase}.#{Faker::Name.last_name.downcase}@hetzner.co.za"
end

#given_existing_identityObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/soar/authentication/identity_uuid_translator/test/orchestration_provider/staff.rb', line 14

def given_existing_identity
  begin
    @identity = {
      dn: "cn=John Smith,#{@identity_directory_configuration['config']['base']}",
      attributes: {
        cn: "John Smith",
        mail: @identifier,
        objectclass: ["inetOrgPerson", "top"],
        sn: "Smith"
      }
    }
    @identity_directory.provider.delete(@identity[:dn])
    @identity_directory.put(@identity)
  rescue Soar::Registry::Directory::Error::DuplicateEntryError => e
    true
  end
end

#given_existing_role_and_attributesObject



33
34
35
36
37
38
# File 'lib/soar/authentication/identity_uuid_translator/test/orchestration_provider/staff.rb', line 33

def given_existing_role_and_attributes
  @roles_directory.put({
    "identity_uuid" => @identity_registry.get_identifiers(@identifier)[0],
    "identity_role" => Soar::Authentication::IdentityUuidTranslator::Provider::Staff::ROLE
  })
end

#given_identity_registryObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/soar/authentication/identity_uuid_translator/test/orchestration_provider/staff.rb', line 40

def given_identity_registry

  @identity_directory_configuration = YAML.load_file("config/#{ENV['IDENTITY_DIRECTORY_CONFIG_FILE']}")

  @identity_directory = Soar::Registry::Directory.new(
    Soar::Registry::Directory::Provider::Ldap.new(Hashie.symbolize_keys(@identity_directory_configuration['config']))
  )

  @identity_registry = Soar::Registry::Identity.new(
    Soar::Registry::Identity::Provider::Staff::Email.new({
      directory: @identity_directory,
      fetch_index: 'entryuuid',
      search_index: 'mail'
    })
  )
end

#role?Boolean

Returns:

  • (Boolean)


57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/soar/authentication/identity_uuid_translator/test/orchestration_provider/staff.rb', line 57

def role?
  begin
    primary_key = {
      "identity_uuid" => @uuid,
      "identity_role" => Soar::Authentication::IdentityUuidTranslator::Provider::Staff::ROLE
    }
    identity = @roles_directory.fetch(primary_key)
    identity['identity_role'] == Soar::Authentication::IdentityUuidTranslator::Provider::Staff::ROLE
  rescue Soar::Registry::Directory::Error::NoEntriesFoundError => e
    return false
  end
end

#uuid?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/soar/authentication/identity_uuid_translator/test/orchestration_provider/staff.rb', line 70

def uuid?
  @uuid == @identity_registry.get_identifiers(@identifier)[0]
end