soar-registry-identity 4.0.3 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +106 -11
- data/lib/soar/registry/identity/factory.rb +1 -1
- data/lib/soar/registry/identity/model.rb +6 -3
- data/lib/soar/registry/identity/provider/customer/client_number.rb +7 -2
- data/lib/soar/registry/identity/provider/customer/email.rb +5 -2
- data/lib/soar/registry/identity/provider/customer/uuid.rb +116 -3
- data/lib/soar/registry/identity/provider/staff/email.rb +5 -2
- data/lib/soar/registry/identity/provider/staff/uuid.rb +69 -32
- data/lib/soar/registry/identity/test/fixtures/client_table.sql +91 -0
- data/lib/soar/registry/identity/test/fixtures/roles_table.json +27 -0
- data/lib/soar/registry/identity/test/orchestration_provider/customer/uuid.rb +201 -0
- data/lib/soar/registry/identity/test/orchestration_provider/staff/uuid.rb +207 -0
- data/lib/soar/registry/identity/test/orchestrator.rb +86 -0
- metadata +10 -14
- data/lib/soar/registry/identity/test/fixtures/customer/identities.json +0 -18
- data/lib/soar/registry/identity/test/fixtures/roles.json +0 -52
- data/lib/soar/registry/identity/test/fixtures/staff/identities.json +0 -22
@@ -0,0 +1,91 @@
|
|
1
|
+
DROP TABLE IF EXISTS `Client`;
|
2
|
+
CREATE TABLE `Client` (
|
3
|
+
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
4
|
+
`Timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
5
|
+
`Client_Number` varchar(15) NOT NULL DEFAULT '',
|
6
|
+
`Privil` varchar(15) NOT NULL DEFAULT '',
|
7
|
+
`Active` enum('0','1') NOT NULL DEFAULT '0',
|
8
|
+
`ActiveUntil` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
9
|
+
`MaxDomains` int(11) NOT NULL DEFAULT '100',
|
10
|
+
`Title` varchar(10) DEFAULT NULL,
|
11
|
+
`First_Name` varchar(70) DEFAULT NULL,
|
12
|
+
`Surname` varchar(70) DEFAULT NULL,
|
13
|
+
`Company` varchar(70) DEFAULT NULL,
|
14
|
+
`Street` varchar(70) DEFAULT NULL,
|
15
|
+
`Postal_Code` varchar(10) DEFAULT NULL,
|
16
|
+
`Suburb` varchar(70) NOT NULL DEFAULT '',
|
17
|
+
`Country` varchar(70) NOT NULL DEFAULT '0',
|
18
|
+
`City` varchar(70) NOT NULL DEFAULT '',
|
19
|
+
`CountryGroup` enum('0','1','2') NOT NULL DEFAULT '0',
|
20
|
+
`Telephone` varchar(50) DEFAULT NULL,
|
21
|
+
`Cellphone` varchar(50) NOT NULL DEFAULT '',
|
22
|
+
`ID_Number` varchar(30) DEFAULT NULL,
|
23
|
+
`Date_Of_Birth` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
24
|
+
`Fax` varchar(50) DEFAULT NULL,
|
25
|
+
`RipeHandle` varchar(16) NOT NULL DEFAULT '',
|
26
|
+
`Login` varchar(15) DEFAULT NULL,
|
27
|
+
`Password` varchar(30) DEFAULT NULL,
|
28
|
+
`FromEmail1` varchar(40) NOT NULL DEFAULT '',
|
29
|
+
`FromEmail2` varchar(40) DEFAULT NULL,
|
30
|
+
`FromEmail3` varchar(40) DEFAULT NULL,
|
31
|
+
`PublicKey` mediumtext NOT NULL,
|
32
|
+
`Newsletter` enum('0','1') NOT NULL DEFAULT '0',
|
33
|
+
`Notice` enum('0','1') NOT NULL DEFAULT '1',
|
34
|
+
`Notifyemail` varchar(100) DEFAULT NULL,
|
35
|
+
`Notifyemail_Robot` varchar(100) NOT NULL DEFAULT '',
|
36
|
+
`Notifyemail_Traffic` varchar(100) DEFAULT NULL,
|
37
|
+
`Notifyemail_Invoice` text,
|
38
|
+
`FreeTraffic` decimal(4,2) DEFAULT NULL,
|
39
|
+
`Bank_Branch_Code` varchar(8) DEFAULT NULL,
|
40
|
+
`Bank_Account_Number` varchar(30) DEFAULT NULL,
|
41
|
+
`Bank_Account_Holder` varchar(60) DEFAULT NULL,
|
42
|
+
`Bank_Account_Type` enum('0','1','2','3','4','5') NOT NULL DEFAULT '0',
|
43
|
+
`Bank_Name` varchar(60) NOT NULL DEFAULT '',
|
44
|
+
`Bank_Branch_Location` varchar(60) NOT NULL DEFAULT '',
|
45
|
+
`Reseller` enum('0','1') NOT NULL DEFAULT '0',
|
46
|
+
`Reseller_Proof` varchar(60) NOT NULL DEFAULT '',
|
47
|
+
`CreditCardNumber` varchar(30) NOT NULL DEFAULT '',
|
48
|
+
`CreditCardExpiration` varchar(6) NOT NULL DEFAULT '',
|
49
|
+
`CreditCardName` varchar(15) NOT NULL DEFAULT '',
|
50
|
+
`payment_method` enum('Unspecified','Cash','Debit Order') NOT NULL DEFAULT 'Unspecified',
|
51
|
+
`Mother_ID` varchar(12) NOT NULL DEFAULT '',
|
52
|
+
`ChargeVAT` enum('0','1') NOT NULL DEFAULT '1',
|
53
|
+
`Summary_Invoice` enum('0','1') NOT NULL DEFAULT '0',
|
54
|
+
`Separate_Invoice` enum('0','1') NOT NULL DEFAULT '0',
|
55
|
+
`Email_Format` enum('0','1','2','3') NOT NULL DEFAULT '1',
|
56
|
+
`Dedi_Graph` enum('0','1') NOT NULL DEFAULT '1',
|
57
|
+
`TaxID` varchar(20) NOT NULL DEFAULT '',
|
58
|
+
`Discount` decimal(4,2) DEFAULT NULL,
|
59
|
+
`ChargeRobotSetup` enum('0','1','2') DEFAULT NULL,
|
60
|
+
`ClientCreated` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
61
|
+
`Comment` text,
|
62
|
+
`Advice` mediumtext NOT NULL,
|
63
|
+
`Vat_Number` varchar(30) DEFAULT NULL,
|
64
|
+
`Rejection_Counter` tinyint(11) DEFAULT '0',
|
65
|
+
`Marketing` enum('Print','Brainstorm','ComputerActive','Google','ITWeb','Mouth','Website','Search','Designer','Hetzner','Other','SA Computer Magazine','Entrepreneur Magazine','Financial Mail') DEFAULT NULL,
|
66
|
+
`Marketing_other` mediumtext,
|
67
|
+
`Billing_First_Name` varchar(70) NOT NULL DEFAULT '',
|
68
|
+
`Billing_Surname` varchar(70) NOT NULL DEFAULT '',
|
69
|
+
`Billing_Telephone` varchar(50) NOT NULL DEFAULT '',
|
70
|
+
`Billing_Cellphone` varchar(50) NOT NULL DEFAULT '',
|
71
|
+
`Tech_First_Name` varchar(70) NOT NULL DEFAULT '',
|
72
|
+
`Tech_Surname` varchar(70) NOT NULL DEFAULT '',
|
73
|
+
`Notifyemail_Tech` varchar(100) NOT NULL DEFAULT '',
|
74
|
+
`Tech_Telephone` varchar(50) NOT NULL DEFAULT '',
|
75
|
+
`Tech_Cellphone` varchar(50) NOT NULL DEFAULT '',
|
76
|
+
`Verified` enum('0','1') NOT NULL DEFAULT '1',
|
77
|
+
`mass_update_notification_sent` enum('1','2','3','more','no') NOT NULL DEFAULT 'no',
|
78
|
+
`mass_update_submission_sent` enum('yes','no') NOT NULL DEFAULT 'no',
|
79
|
+
`contact_Confirmed` enum('True','False') NOT NULL DEFAULT 'True',
|
80
|
+
`is_test_profile` enum('0','1') DEFAULT '0',
|
81
|
+
`Google` enum('None','Eligible','Emailed','Issued') NOT NULL DEFAULT 'None',
|
82
|
+
`Google_Value_ID` int(11) NOT NULL DEFAULT '0',
|
83
|
+
`Google_Expiry` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
84
|
+
`app_installer_active` tinyint(1) DEFAULT '1',
|
85
|
+
PRIMARY KEY (`ID`),
|
86
|
+
KEY `Login` (`Login`),
|
87
|
+
KEY `Password` (`Password`),
|
88
|
+
KEY `Notifyemail_Invoice` (`Notifyemail_Invoice`(20)),
|
89
|
+
KEY `Client_Number` (`Client_Number`)
|
90
|
+
) ENGINE=InnoDB AUTO_INCREMENT=185532 DEFAULT CHARSET=latin1;
|
91
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
{
|
2
|
+
"table_name": "identity_roles",
|
3
|
+
"key_schema": [
|
4
|
+
{
|
5
|
+
"attribute_name": "identity_uuid",
|
6
|
+
"key_type": "HASH"
|
7
|
+
},
|
8
|
+
{
|
9
|
+
"attribute_name": "identity_role",
|
10
|
+
"key_type": "RANGE"
|
11
|
+
}
|
12
|
+
],
|
13
|
+
"attribute_definitions": [
|
14
|
+
{
|
15
|
+
"attribute_name": "identity_uuid",
|
16
|
+
"attribute_type": "S"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"attribute_name": "identity_role",
|
20
|
+
"attribute_type": "S"
|
21
|
+
}
|
22
|
+
],
|
23
|
+
"provisioned_throughput": {
|
24
|
+
"read_capacity_units": 10,
|
25
|
+
"write_capacity_units": 10
|
26
|
+
}
|
27
|
+
}
|
@@ -0,0 +1,201 @@
|
|
1
|
+
require 'faker'
|
2
|
+
require 'soar/registry/identity'
|
3
|
+
require 'soar/registry/directory'
|
4
|
+
require 'soar/authentication/identity_uuid_translator/provider/customer'
|
5
|
+
require 'soar/authentication/identity_uuid_translator/uuid_generator'
|
6
|
+
|
7
|
+
module Soar
|
8
|
+
module Registry
|
9
|
+
module Identity
|
10
|
+
module Test
|
11
|
+
module OrchestrationProvider
|
12
|
+
module Customer
|
13
|
+
class Uuid
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
Faker::UniqueGenerator.clear
|
17
|
+
@identity = {
|
18
|
+
ID: Faker::Number.unique.number(4).to_i,
|
19
|
+
First_Name: Faker::Name.unique.first_name,
|
20
|
+
Surname: Faker::Name.unique.last_name,
|
21
|
+
Notifyemail_Invoice: "#{Faker::Internet.unique.email}",
|
22
|
+
Client_Number: "C#{Faker::Number.unique.number(10)}"
|
23
|
+
}
|
24
|
+
@identity_uuid = Soar::Authentication::IdentityUuidTranslator::UuidGenerator.generate("#{Soar::Authentication::IdentityUuidTranslator::Provider::Customer::PREFIX}#{@identity[:ID]}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def given_identity_directory
|
28
|
+
wait_for_database do
|
29
|
+
@identity_directory_config = YAML.load_file("config/#{ENV['CUSTOMER_DIRECTORY_CONFIG_FILE']}")
|
30
|
+
@identity_directory = Soar::Registry::Directory.new(
|
31
|
+
Soar::Registry::Directory::Provider::Mysql.new(@identity_directory_config['config'].map { |k, v| [k.to_sym, v] }.to_h)
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def given_roles_directory
|
37
|
+
@roles_directory_config = YAML.load_file("config/#{ENV['ROLES_DIRECTORY_CONFIG_FILE']}")
|
38
|
+
@roles_directory = Soar::Registry::Directory.new(
|
39
|
+
Soar::Registry::Directory::Provider::DynamoDb.new(@roles_directory_config['config'].map { |k, v| [k.to_sym, v]}.to_h)
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def given_roles
|
44
|
+
@roles = generate_roles()
|
45
|
+
wait_for_database {
|
46
|
+
create_roles_table(@roles_directory, @roles_directory_config)
|
47
|
+
populate_roles_table(@roles_directory, @roles, @identity_uuid)
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def given_role_with_attributes
|
52
|
+
@roles = generate_roles()
|
53
|
+
@roles[0][:attributes] = {
|
54
|
+
profiles: [@identity[:Client_Number], "C#{Faker::Number.unique.number(10)}"]
|
55
|
+
}
|
56
|
+
wait_for_database {
|
57
|
+
create_roles_table(@roles_directory, @roles_directory_config)
|
58
|
+
populate_roles_table(@roles_directory, @roles, @identity_uuid)
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
def given_identity
|
63
|
+
wait_for_database do
|
64
|
+
create_identity_table(@identity_directory)
|
65
|
+
@identity_directory.put(@identity)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def given_identity_registry
|
70
|
+
identity_provider = Soar::Registry::Identity::Provider::Customer::Uuid.new({
|
71
|
+
identity: {
|
72
|
+
directory: @identity_directory,
|
73
|
+
fetch_index: 'ID',
|
74
|
+
search_index: 'Notifyemail_Invoice'
|
75
|
+
},
|
76
|
+
roles: {
|
77
|
+
directory: @roles_directory,
|
78
|
+
fetch_index: ['identity_uuid', 'identity_role'],
|
79
|
+
search_index: 'identity_uuid'
|
80
|
+
}
|
81
|
+
})
|
82
|
+
|
83
|
+
@idr = Soar::Registry::Identity.new(identity_provider)
|
84
|
+
end
|
85
|
+
|
86
|
+
def get_roles
|
87
|
+
@result = @idr.get_roles(@identity_uuid)
|
88
|
+
end
|
89
|
+
|
90
|
+
def get_role_attributes
|
91
|
+
@result = @idr.get_attributes(@identity_uuid, @roles.nil? ? Faker::Company.unique.profession : @roles[0][:role])
|
92
|
+
end
|
93
|
+
|
94
|
+
def get_identity_attributes
|
95
|
+
@result = @idr.get_attributes(@identity_uuid)
|
96
|
+
end
|
97
|
+
|
98
|
+
def identity_attributes?
|
99
|
+
roles = {}
|
100
|
+
@roles.each do |entry|
|
101
|
+
roles[entry[:role]] = {}
|
102
|
+
end if not @roles.nil?
|
103
|
+
expectation = {
|
104
|
+
"identity_uuid" => @identity_uuid,
|
105
|
+
"firstname" => @identity[:First_Name],
|
106
|
+
"lastname" => @identity[:Surname],
|
107
|
+
"email" => @identity[:Notifyemail_Invoice],
|
108
|
+
"roles" => roles
|
109
|
+
}
|
110
|
+
@result == expectation
|
111
|
+
end
|
112
|
+
|
113
|
+
def nil?
|
114
|
+
@result == nil
|
115
|
+
end
|
116
|
+
|
117
|
+
def role_with_empty_attributes?
|
118
|
+
@result == {
|
119
|
+
@roles[0][:role] => {}
|
120
|
+
}
|
121
|
+
end
|
122
|
+
|
123
|
+
def role_with_attributes?
|
124
|
+
role_with_attributes = {
|
125
|
+
@roles[0][:role] => Hashie.stringify_keys(@roles[0][:attributes])
|
126
|
+
}
|
127
|
+
@result == role_with_attributes
|
128
|
+
end
|
129
|
+
|
130
|
+
def roles?
|
131
|
+
roles = @roles.map do |entry|
|
132
|
+
entry[:role]
|
133
|
+
end
|
134
|
+
@result.sort == roles.sort
|
135
|
+
end
|
136
|
+
|
137
|
+
def no_roles?
|
138
|
+
@result == []
|
139
|
+
end
|
140
|
+
|
141
|
+
def identity_error?
|
142
|
+
# this is not currently possible
|
143
|
+
@result == []
|
144
|
+
end
|
145
|
+
|
146
|
+
private
|
147
|
+
|
148
|
+
def generate_roles()
|
149
|
+
return [{
|
150
|
+
source: "#{Soar::Authentication::IdentityUuidTranslator::Provider::Customer::PREFIX}#{@identity[:ID]}",
|
151
|
+
role: Soar::Authentication::IdentityUuidTranslator::Provider::Customer::ROLE
|
152
|
+
},{
|
153
|
+
role: Faker::Company.unique.profession
|
154
|
+
}]
|
155
|
+
end
|
156
|
+
|
157
|
+
def populate_roles_table(roles_directory, roles, identity_uuid)
|
158
|
+
roles.each { |role|
|
159
|
+
entry = {
|
160
|
+
"identity_uuid" => identity_uuid,
|
161
|
+
"identity_role" => role[:role]
|
162
|
+
}
|
163
|
+
entry['identity_source'] = role[:source] if role.key?(:source)
|
164
|
+
entry['identity_role_attributes'] = role[:attributes] if role.key?(:attributes)
|
165
|
+
roles_directory.put(entry)
|
166
|
+
}
|
167
|
+
end
|
168
|
+
|
169
|
+
def create_roles_table(roles_directory, roles_directory_config)
|
170
|
+
roles_directory.provider.recreate_table({
|
171
|
+
name: roles_directory_config['config']['table']['name'],
|
172
|
+
structure: JSON.parse(File.read("lib/soar/registry/identity/test/fixtures/roles_table.json"))
|
173
|
+
})
|
174
|
+
end
|
175
|
+
|
176
|
+
def create_identity_table(identity_directory)
|
177
|
+
identity_directory.provider.client.query("DROP TABLE IF EXISTS `Client`")
|
178
|
+
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))")
|
179
|
+
end
|
180
|
+
|
181
|
+
def deep_copy(o)
|
182
|
+
Marshal.load(Marshal.dump(o))
|
183
|
+
end
|
184
|
+
|
185
|
+
def wait_for_database
|
186
|
+
return 10.times do |i|
|
187
|
+
begin
|
188
|
+
break yield
|
189
|
+
rescue Soar::Registry::Directory::Error::NetworkingError, Net::LDAP::Error => e
|
190
|
+
sleep(10)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
@@ -0,0 +1,207 @@
|
|
1
|
+
require 'faker'
|
2
|
+
require 'soar/registry/identity'
|
3
|
+
require 'soar/registry/directory'
|
4
|
+
require 'securerandom'
|
5
|
+
require 'soar/authentication/identity_uuid_translator'
|
6
|
+
|
7
|
+
module Soar
|
8
|
+
module Registry
|
9
|
+
module Identity
|
10
|
+
module Test
|
11
|
+
module OrchestrationProvider
|
12
|
+
module Staff
|
13
|
+
class Uuid
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
Faker::UniqueGenerator.clear
|
17
|
+
@identity_directory_config = YAML.load_file("config/#{ENV['STAFF_DIRECTORY_CONFIG_FILE']}")
|
18
|
+
firstname = Faker::Name.first_name
|
19
|
+
lastname = Faker::Name.last_name
|
20
|
+
@identity = {
|
21
|
+
dn: "cn=#{firstname} #{lastname},#{@identity_directory_config['config']['base']}",
|
22
|
+
attributes: {
|
23
|
+
cn: "#{firstname} #{lastname}",
|
24
|
+
givenName: firstname,
|
25
|
+
mail: "#{firstname.downcase}.#{lastname.downcase}@hetzner.co.za",
|
26
|
+
objectclass: ["inetOrgPerson", "top"],
|
27
|
+
sn: lastname
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
@identity_uuid = SecureRandom.uuid
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
def given_roles_directory
|
36
|
+
@roles_directory_config = YAML.load_file("config/#{ENV['ROLES_DIRECTORY_CONFIG_FILE']}")
|
37
|
+
@roles_directory = Soar::Registry::Directory.new(
|
38
|
+
Soar::Registry::Directory::Provider::DynamoDb.new(@roles_directory_config['config'].map { |k, v| [k.to_sym, v]}.to_h )
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
def given_identity_directory
|
43
|
+
@identity_directory = Soar::Registry::Directory.new(
|
44
|
+
Soar::Registry::Directory::Provider::Ldap.new(@identity_directory_config['config'].map{ |k, v| [k.to_sym, v]}.to_h)
|
45
|
+
)
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
def given_identity
|
50
|
+
wait_for_database do
|
51
|
+
@identity_directory.provider.delete(@identity[:dn])
|
52
|
+
@identity_directory.put(@identity)
|
53
|
+
@identity_uuid = @identity_directory.search('mail', @identity[:attributes][:mail])[0][:entryuuid]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def given_roles
|
58
|
+
@roles = generate_roles()
|
59
|
+
wait_for_database do
|
60
|
+
create_roles_database(@roles_directory_config, @roles_directory)
|
61
|
+
populate_roles_database(@roles_directory, @roles, @identity_uuid)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def given_role_with_attributes
|
66
|
+
@roles = generate_roles()
|
67
|
+
@roles[0][:attributes] = {
|
68
|
+
Faker::Hacker.noun => Faker::Hacker.verb
|
69
|
+
}
|
70
|
+
wait_for_database do
|
71
|
+
create_roles_database(@roles_directory_config, @roles_directory)
|
72
|
+
populate_roles_database(@roles_directory, @roles, @identity_uuid)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def given_identity_registry
|
77
|
+
identity_provider = Soar::Registry::Identity::Provider::Staff::Uuid.new({
|
78
|
+
identity: {
|
79
|
+
directory: @identity_directory,
|
80
|
+
fetch_index: 'entryuuid',
|
81
|
+
search_index: 'mail'
|
82
|
+
},
|
83
|
+
roles: {
|
84
|
+
directory: @roles_directory,
|
85
|
+
fetch_index: ['identity_uuid', 'identity_role'],
|
86
|
+
search_index: 'identity_uuid'
|
87
|
+
}
|
88
|
+
})
|
89
|
+
|
90
|
+
@idr = Soar::Registry::Identity.new(identity_provider)
|
91
|
+
end
|
92
|
+
|
93
|
+
def get_roles
|
94
|
+
begin
|
95
|
+
@result = @idr.get_roles(@identity_uuid)
|
96
|
+
rescue SoarIdm::IdentityError => e
|
97
|
+
@error = e
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def get_identity_attributes
|
102
|
+
@result = @idr.get_attributes(@identity_uuid)
|
103
|
+
end
|
104
|
+
|
105
|
+
def get_role_attributes
|
106
|
+
@result = @idr.get_attributes(@identity_uuid, @roles.nil? ? Faker::Company.unique.profession : @roles[0][:role])
|
107
|
+
end
|
108
|
+
|
109
|
+
def identity_attributes?
|
110
|
+
roles = {}
|
111
|
+
@roles.each do |entry|
|
112
|
+
roles[entry[:role]] = {}
|
113
|
+
end if not @roles.nil?
|
114
|
+
@result == {
|
115
|
+
"identity_uuid" => @identity_uuid,
|
116
|
+
"firstname" => @identity[:attributes][:givenName],
|
117
|
+
"lastname" => @identity[:attributes][:sn],
|
118
|
+
"email" => @identity[:attributes][:mail],
|
119
|
+
"roles" => roles
|
120
|
+
}
|
121
|
+
end
|
122
|
+
|
123
|
+
def role_with_attributes?
|
124
|
+
role_with_attributes = {
|
125
|
+
@roles[0][:role] => Hashie.stringify_keys(@roles[0][:attributes])
|
126
|
+
}
|
127
|
+
@result == role_with_attributes
|
128
|
+
end
|
129
|
+
|
130
|
+
def nil?
|
131
|
+
@result == nil
|
132
|
+
end
|
133
|
+
|
134
|
+
def role_with_empty_attributes?
|
135
|
+
@result == {
|
136
|
+
@roles[0][:role] => {}
|
137
|
+
}
|
138
|
+
end
|
139
|
+
|
140
|
+
def roles?
|
141
|
+
|
142
|
+
roles = @roles.map do |entry|
|
143
|
+
entry[:role]
|
144
|
+
end
|
145
|
+
@result.sort == roles.sort
|
146
|
+
end
|
147
|
+
|
148
|
+
def no_roles?
|
149
|
+
@result == []
|
150
|
+
end
|
151
|
+
|
152
|
+
def identity_error?
|
153
|
+
@error.is_a?(SoarIdm::IdentityError)
|
154
|
+
end
|
155
|
+
|
156
|
+
private
|
157
|
+
|
158
|
+
def create_roles_database(directory_config, directory)
|
159
|
+
directory.provider.recreate_table({
|
160
|
+
name: directory_config['config']['table']['name'],
|
161
|
+
structure: JSON.parse(File.read("lib/soar/registry/identity/test/fixtures/roles_table.json"))
|
162
|
+
})
|
163
|
+
end
|
164
|
+
|
165
|
+
def populate_roles_database(roles_directory, roles, identity_uuid)
|
166
|
+
roles.each do |role|
|
167
|
+
entry = {
|
168
|
+
"identity_uuid" => identity_uuid,
|
169
|
+
"identity_role" => role[:role]
|
170
|
+
}
|
171
|
+
entry['identity_source'] = role[:source] if role.key?(:source)
|
172
|
+
entry['identity_role_attributes'] = role[:attributes] if role.key?(:attributes)
|
173
|
+
roles_directory.put(entry)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def generate_roles()
|
178
|
+
roles = [{
|
179
|
+
role: Faker::Company.unique.profession
|
180
|
+
}, {
|
181
|
+
role: Faker::Company.unique.profession
|
182
|
+
}, {
|
183
|
+
role: Faker::Company.unique.profession
|
184
|
+
}, {
|
185
|
+
role: Faker::Company.unique.profession
|
186
|
+
}]
|
187
|
+
roles[0][:source] = "#{Soar::Authentication::IdentityUuidTranslator::Provider::Staff::PREFIX}#{@identity_uuid}"
|
188
|
+
return roles
|
189
|
+
end
|
190
|
+
|
191
|
+
def wait_for_database
|
192
|
+
return 10.times do |i|
|
193
|
+
begin
|
194
|
+
break yield
|
195
|
+
rescue Soar::Registry::Directory::Error::NetworkingError, Net::LDAP::Error => e
|
196
|
+
sleep(10)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|