soar-registry-identity 5.0.1 → 5.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79231792c26830f1ef26bf12dd425bc9f5f3384b
4
- data.tar.gz: 42fa83abb9dcd2d28ee9a01f8da502273877cc69
3
+ metadata.gz: '08d1199a71caea3337960fec8dec9246ed0cd69f'
4
+ data.tar.gz: 6382f9113f1a48dec5e545a52faf5a4e09009b4e
5
5
  SHA512:
6
- metadata.gz: c6f877cfc8a01e27627c66fe27617f40d8b1b6bca76b1cf3f0eb85676a1d3f1670e5925684b77b1b046fb22ad7c3809a0f72ee278e3884ba89993afea1e8b214
7
- data.tar.gz: 6f195c1646a9178dd7c769cc124779c9d5cca769c7337bc3ea83c296945e5d6b30ea045ec5d84bdf0d243379c7f9ab320b4d1356b1639cfd1cc4451087762269
6
+ metadata.gz: 48b81c9ef2377c6ac5c700553626287681c298908385211c84fc8315a9a0594b0f09ce784294a36116b964fa77a9cc5118937a38ff337d5a36afd68012445fd5
7
+ data.tar.gz: e31db28d252fb764c18988b2cf221472f6f1081603680dcd10684925a8e3037cf1b7ceed884372f29ef7c89cf028fd9533ae3e391a51cff17ecbc9df745ce09b
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Registry of identities
2
2
 
3
+ ## Documentation
4
+ [rubydoc.info](http://www.rubydoc.info/gems/soar-registry-identity/)
5
+
3
6
  ## Quickstart
4
7
 
5
8
  ### Example data
@@ -172,13 +175,13 @@ $ docker-compose up --build --remove-orphans --force-recreate
172
175
  Soar::Registry::Identity::Provider::Customer::Uuid
173
176
 
174
177
  ```bash
175
- $ CUSTOMER_DIRECTORY_CONFIG_FILE=config.mysql.yml ROLES_DIRECTORY_CONFIG_FILE=config.dynamo_db.yml TEST_ORCHESTRATION_PROVIDER=Customer::Uuid bundle exec cucumber
178
+ $ CUSTOMER_DIRECTORY_CONFIG_FILE=config.mysql.yml ROLES_DIRECTORY_CONFIG_FILE=config.dynamo_db.yml TEST_ORCHESTRATION_PROVIDER=Customer::Uuid bundle exec cucumber --tags ~@future
176
179
  ```
177
180
 
178
181
  Soar::Registry::Identity::Provider::Staff::Uuid
179
182
 
180
183
  ```bash
181
- $ STAFF_DIRECTORY_CONFIG_FILE=config.ldap.yml ROLES_DIRECTORY_CONFIG_FILE=config.dynamo_db.yml TEST_ORCHESTRATION_PROVIDER=Staff::Uuid bundle exec cucumber
184
+ $ STAFF_DIRECTORY_CONFIG_FILE=config.ldap.yml ROLES_DIRECTORY_CONFIG_FILE=config.dynamo_db.yml TEST_ORCHESTRATION_PROVIDER=Staff::Uuid bundle exec cucumber
182
185
  ```
183
186
 
184
187
  Soar::Registry::Identity::Provider::Stub::Uuid
@@ -30,6 +30,7 @@ module Soar
30
30
  # @return [Hash{String => String, Hash, Number}]
31
31
  # if a role is specified the returned hash is keyed by role
32
32
  # else it's keyed by attribute name
33
+ # @raise [SoarIdm::IdentityError]
33
34
  ##
34
35
  def get_attributes(identifier, role = nil)
35
36
  @provider.get_attributes(identifier, role)
@@ -19,13 +19,13 @@ module Soar
19
19
  end
20
20
 
21
21
  ##
22
- # @param [String] identity_identifier
22
+ # @param [String] client_number
23
23
  # a client_number that uniquely identifies an identity
24
24
  # @return [Hash] an identity
25
25
  ##
26
- def calculate_identities(identity_identifier)
26
+ def calculate_identities(client_number)
27
27
  return @identities if not @identities.nil?
28
- entries = @directory.search(@search_index, identity_identifier)
28
+ entries = @directory.search(@search_index, client_number)
29
29
  @identities = entries.empty? ? [] : [entries[0]]
30
30
  return @identities
31
31
  end
@@ -17,13 +17,13 @@ module Soar
17
17
  end
18
18
 
19
19
  ##
20
- # @param [String] identity_identifier
20
+ # @param [String] email
21
21
  # an email address that uniquely identifies an identity
22
22
  # @return [Hash] an identity
23
23
  ##
24
- def calculate_identities(identity_identifier)
24
+ def calculate_identities(email)
25
25
  return @identities if not @identities.nil?
26
- entries = @directory.search(@search_index, identity_identifier)
26
+ entries = @directory.search(@search_index, email)
27
27
  @identities = entries.empty? ? [] : [entries[0]]
28
28
  return @identities
29
29
  end
@@ -32,11 +32,11 @@ module Soar
32
32
  end
33
33
 
34
34
  ##
35
- # @param [Hash{String => String,Number}] identity
35
+ # @param [String] identity_uuid
36
36
  # @return [Array<String>] list of roles
37
37
  ##
38
- def calculate_roles(identity)
39
- entries = @roles[:directory].search(@roles[:search_index], identity[@roles[:search_index]])
38
+ def calculate_roles(identity_uuid)
39
+ entries = @roles[:directory].search(@roles[:search_index], identity_uuid)
40
40
  roles = []
41
41
  entries.each do |entry|
42
42
  roles << entry[@roles[:fetch_index][1]]
@@ -45,10 +45,10 @@ module Soar
45
45
  end
46
46
 
47
47
  ##
48
- # @param [Hash{String => String, Number}] identity
48
+ # @param [String] identity_uuid
49
49
  # @return [Array<String,Number>] list of identifiers
50
50
  ##
51
- def calculate_identifiers(identity)
51
+ def calculate_identifiers(identity_uuid)
52
52
  indexes = @identity[:directory].index
53
53
  #indexes.delete(@identity[:directory])
54
54
  identifiers = []
@@ -60,13 +60,13 @@ module Soar
60
60
  end
61
61
 
62
62
  ##
63
- # @param [Hash{String => String, Number}] identity
63
+ # @param [identifier] identity_uuid
64
64
  # @param [String] role
65
65
  # @return [Hash{String => String, Number, Hash, Array}] A hash of attributes
66
66
  ##
67
- def calculate_attributes(identity, role)
67
+ def calculate_attributes(identity_uuid, role)
68
68
  primary_key = {
69
- @roles[:fetch_index][0] => identity[@roles[:fetch_index][0]],
69
+ @roles[:fetch_index][0] => identity_uuid,
70
70
  @roles[:fetch_index][1] => role
71
71
  }
72
72
  result = @roles[:directory].fetch(primary_key)
@@ -77,45 +77,50 @@ module Soar
77
77
  end
78
78
 
79
79
  ##
80
- # @param [Hash{String => String, Number}] identity
80
+ # @param [String] identity_uuid
81
81
  # @return [Hash{String => String, Number, Hash, Array}] A hash of attributes
82
- def calculate_all_attributes(identity)
83
- identity = Marshal.load(Marshal.dump(identity))
84
- identity_uuid = identity[@roles[:search_index]]
82
+ def calculate_all_attributes(identity_uuid)
83
+ identity = {}
85
84
  role_entries = @roles[:directory].search(@roles[:search_index], identity_uuid)
86
85
  roles = {}
87
86
  role_entries.each do |role_entry|
87
+ identity = calculate_identity(identity_uuid, role_entry['identity_source']) if role_entry.key?('identity_source')
88
88
  roles[role_entry['identity_role']] = role_entry.key?('identity_role_attributes') ? role_entry['identity_role_attributes'] : {}
89
89
  end
90
+ raise SoarIdm::IdentityError if identity.empty?
90
91
  identity[:roles] = roles
91
92
  attributes = Hashie.stringify_keys(identity)
92
93
  return attributes
93
94
  end
94
95
 
95
96
  ##
96
- # @param [String] identifier a string that uniquely identifies an identity
97
- # @return [Array<Hash{String => String, Number }>] identities
97
+ # @param [String] identity_uuid
98
+ # @param [String] identity_source
99
+ # @return [Hash{String => String, Number, Hash, Array}]
100
+ # @raise [SoarIdm::IdentityError]
98
101
  ##
99
- def calculate_identities(identifier)
100
- return @identities if not @identities.nil?
101
- identities = @roles[:directory].search(@roles[:search_index], identifier)
102
- identity = { @roles[:search_index] => identifier }
103
- return [identity] if identities.length == 0
104
- identity_source = get_identity_source(identities)
105
- identity_id = get_identity_id(identity_source) if not identity_source.nil?
102
+ def calculate_identity(identity_uuid, identity_source)
103
+ identity_id = get_identity_id(identity_source) if not identity_source.nil?
106
104
  #raise SoarIdm::IdentityError if identity_id.nil?
107
105
  begin
108
- identity = @identity[:directory].fetch(identity_id)
109
- identity = {
110
- "email" => identity[:Notifyemail_Invoice],
111
- "firstname" => identity[:First_Name],
112
- "lastname" =>identity[:Surname]
113
- }
114
- rescue Soar::Registry::Directory::Error::NoEntriesFoundError
106
+ source_identity = @identity[:directory].fetch(identity_id)
107
+ identity = {}
108
+ identity["identity_uuid"] = identity_uuid
109
+ identity["email"] = source_identity[:Notifyemail_Invoice] if source_identity.key?(:Notifyemail_Invoice)
110
+ identity["firstname"] = source_identity[:First_Name] if source_identity.key?(:First_Name)
111
+ identity["lastname"] = source_identity[:Surname] if source_identity.key?(:Surname)
112
+ return identity
113
+ rescue Soar::Registry::Directory::Error::NoEntriesFoundError => e
114
+ raise SoarIdm::IdentityError, e.message
115
115
  end
116
- identity[@roles[:search_index]] = identifier
117
- @identities = [identity]
118
- return @identities
116
+ end
117
+
118
+ ##
119
+ # @param [String] identifier a string that uniquely identifies an identity
120
+ # @return [Array<String>] identifiers
121
+ ##
122
+ def calculate_identities(identity_uuid)
123
+ return [identity_uuid]
119
124
  end
120
125
 
121
126
  private
@@ -125,13 +130,6 @@ module Soar
125
130
  return result.last.to_i if result[0] === "mysql" and result[1] === "genie" and result[2] === "client" and result[3] === "id"
126
131
  end
127
132
 
128
- def get_identity_source(identities)
129
- identity_source = identities.each { |identity|
130
- break identity["identity_source"] if identity.key?("identity_source")
131
- }
132
- return identity_source if identity_source.is_a?(String)
133
- end
134
-
135
133
  end
136
134
  end
137
135
  end
@@ -17,13 +17,13 @@ module Soar
17
17
  end
18
18
 
19
19
  ##
20
- # @param [String] identity_identifier
20
+ # @param [String] email
21
21
  # an email address that uniquely identifies an identity
22
22
  # @return [Hash] an identity
23
23
  ##
24
- def calculate_identities(identity_identifier)
24
+ def calculate_identities(email)
25
25
  return @identities if not @identities.nil?
26
- entries = @directory.search(@search_index, identity_identifier)
26
+ entries = @directory.search(@search_index, email)
27
27
  @identities = entries.empty? ? [] : [entries[0]]
28
28
  return @identities
29
29
  end
@@ -30,16 +30,16 @@ module Soar
30
30
  end
31
31
 
32
32
  ##
33
- # @param [Hash{String => String}] identity
33
+ # @param [String] identity_uuid
34
34
  # @return [Array<String>] list of roles
35
35
  ##
36
- def calculate_roles(identity)
37
- entries = @roles[:directory].search(@roles[:search_index], identity[@identity[:fetch_index]])
36
+ def calculate_roles(identity_uuid)
37
+ entries = @roles[:directory].search(@roles[:search_index], identity_uuid)
38
38
  roles = []
39
39
  entries.each do |entry|
40
+ identity_source = entry['identity_source'] if entry.key?('identity_source')
40
41
  roles << entry[@roles[:fetch_index][1]]
41
42
  end
42
- #raise SoarIdm::IdentityError if identity.nil? and roles.length == 0
43
43
  return roles
44
44
  end
45
45
 
@@ -57,13 +57,13 @@ module Soar
57
57
  end
58
58
 
59
59
  ##
60
- # @param [Hash{String => String, Number}] identity
60
+ # @param [String] identity_uuid
61
61
  # @param [String] role
62
62
  # @return [Hash{String => String, Number, Hash, Array}] A hash of attributes
63
63
  ##
64
- def calculate_attributes(identity, role)
64
+ def calculate_attributes(identity_uuid, role)
65
65
  primary_key = {
66
- @roles[:fetch_index][0] => identity[@identity[:fetch_index]],
66
+ @roles[:fetch_index][0] => identity_uuid,
67
67
  @roles[:fetch_index][1] => role
68
68
  }
69
69
  result = @roles[:directory].fetch(primary_key)
@@ -74,40 +74,36 @@ module Soar
74
74
  end
75
75
 
76
76
  ##
77
- # @param [Hash{String => String, Number}] identity
77
+ # @param [String] identity_uuid
78
78
  # @return [Hash{String => String, Number, Hash, Array}] A hash of attributes
79
79
  ##
80
- def calculate_all_attributes(identity)
81
- identity_uuid = identity[@identity[:fetch_index]]
82
- role_entries = @roles[:directory].search(@roles[:search_index], identity_uuid)
83
- roles = {}
84
- role_entries.each do |role_entry|
85
- roles[role_entry['identity_role']] = role_entry.key?('identity_role_attributes') ? role_entry['identity_role_attributes'] : {}
80
+ def calculate_all_attributes(identity_uuid)
81
+ begin
82
+ role_entries = @roles[:directory].search(@roles[:search_index], identity_uuid)
83
+ roles = {}
84
+ role_entries.each { |role_entry|
85
+ roles[role_entry['identity_role']] = role_entry.key?('identity_role_attributes') ? role_entry['identity_role_attributes'] : {}
86
+ }
87
+ identity = @identity[:directory].fetch(identity_uuid)
88
+ attributes = {}
89
+ attributes["identity_uuid"] = identity_uuid
90
+ attributes["firstname"] = identity[:givenName] if identity.key?(:givenName)
91
+ attributes["lastname"] = identity[:sn] if identity.key?(:sn)
92
+ attributes["email"] = identity[:mail] if identity.key?(:mail)
93
+ attributes["roles"] = roles
94
+ return attributes
95
+ rescue Soar::Registry::Directory::Error::NoEntriesFoundError => e
96
+ raise SoarIdm::IdentityError, e.message
86
97
  end
87
- attributes = {
88
- identity_uuid: identity_uuid,
89
- firstname: identity['givenName'],
90
- lastname: identity['sn'],
91
- email: identity[@identity[:search_index]],
92
- roles: roles
93
- }
94
- return attributes.stringify_keys
95
98
  end
96
99
 
97
100
  ##
98
- # @param [String] identifier a string that uniquely identifies an identity
99
- # @return [Array<Hash{String => String}>] identities
101
+ # @param [String] identity_uuid
102
+ # @return [Array<String>] identifiers
100
103
  # @raise [Soar::Registry::Directory::Error::NoEntriesFoundError]
101
104
  ##
102
- def calculate_identities(identifier)
103
- return @identities if not @identities.nil?
104
- begin
105
- result = @identity[:directory].fetch(identifier)
106
- @identities = [Hashie.stringify_keys(result)]
107
- return @identities
108
- rescue Soar::Registry::Directory::Error::NoEntriesFoundError => e
109
- raise SoarIdm::IdentityError
110
- end
105
+ def calculate_identities(identity_uuid)
106
+ return [identity_uuid]
111
107
  end
112
108
 
113
109
  end
@@ -21,44 +21,55 @@ module Soar
21
21
  end
22
22
 
23
23
  ##
24
- # @param [Hash{String => String,Number}] identity
24
+ # @param [String] identity_uuid
25
25
  # @return [Array<String>] list of roles
26
26
  ##
27
- def calculate_roles(identity)
28
- return identity.key?('roles') ? identity['roles'].keys : []
27
+ def calculate_roles(identity_uuid)
28
+ begin
29
+ identity = @directory.fetch(identity_uuid)
30
+ return identity.key?('roles') ? identity['roles'].keys : []
31
+ rescue Soar::Registry::Directory::Error::NoEntriesFoundError => e
32
+ return []
33
+ end
29
34
  end
30
35
 
31
36
  ##
32
- # @param [Hash{String => String, Number}] identity
37
+ # @param [String] identity_uuid
33
38
  # @return [Array<String,Number>] list of identifiers
34
39
  ##
35
- def calculate_identifiers(identity)
40
+ def calculate_identifiers(identity_uuid)
36
41
  end
37
42
 
38
43
  ##
39
- # @param [Hash{String => String, Number}] identity
44
+ # @param [String] identity_uuid
40
45
  # @param [String] role
41
46
  # @return [Hash{String => String, Number, Hash, Array}] A hash of attributes
42
47
  ##
43
- def calculate_attributes(identity, role)
48
+ def calculate_attributes(identity_uuid, role)
49
+ identity = @directory.fetch(identity_uuid)
44
50
  return {
45
51
  role => identity['roles'].key?(role) ? identity['roles'][role] : {}
46
52
  }
47
53
  end
48
54
 
49
55
  ##
50
- # @param [Hash{String => String, Number}] identity
56
+ # @param [String] identity_uuid
51
57
  # @return [Hash{String => String, Number, Hash, Array}] A hash of attributes
52
- def calculate_all_attributes(identity)
53
- return identity
58
+ def calculate_all_attributes(identity_uuid)
59
+ begin
60
+ identity = @directory.fetch(identity_uuid)
61
+ return identity
62
+ rescue Soar::Registry::Directory::Error::NoEntriesFoundError => e
63
+ raise SoarIdm::IdentityError, e.message
64
+ end
54
65
  end
55
66
 
56
67
  ##
57
- # @param [String] identifier a string that uniquely identifies an identity
58
- # @return [Array<Hash{String => String, Number }>] identities
68
+ # @param [String] identity_uuid
69
+ # @return [Array<String>] identities
59
70
  ##
60
- def calculate_identities(identifier)
61
- return [@directory.fetch(identifier)]
71
+ def calculate_identities(identity_uuid)
72
+ return [identity_uuid]
62
73
  end
63
74
 
64
75
 
@@ -83,6 +83,8 @@ module Soar
83
83
  @idr = Soar::Registry::Identity.new(identity_provider)
84
84
  end
85
85
 
86
+ ##### when
87
+
86
88
  def get_roles
87
89
  @result = @idr.get_roles(@identity_uuid)
88
90
  end
@@ -92,9 +94,15 @@ module Soar
92
94
  end
93
95
 
94
96
  def get_identity_attributes
95
- @result = @idr.get_attributes(@identity_uuid)
97
+ begin
98
+ @result = @idr.get_attributes(@identity_uuid)
99
+ rescue SoarIdm::IdentityError => e
100
+ @error = e
101
+ end
96
102
  end
97
103
 
104
+ ##### then
105
+
98
106
  def identity_attributes?
99
107
  roles = {}
100
108
  @roles.each do |entry|
@@ -139,8 +147,7 @@ module Soar
139
147
  end
140
148
 
141
149
  def identity_error?
142
- # this is not currently possible
143
- @result == []
150
+ @error.is_a?(SoarIdm::IdentityError)
144
151
  end
145
152
 
146
153
  private
@@ -90,22 +90,26 @@ module Soar
90
90
  @idr = Soar::Registry::Identity.new(identity_provider)
91
91
  end
92
92
 
93
+ ##### when
94
+
93
95
  def get_roles
96
+ @result = @idr.get_roles(@identity_uuid)
97
+ end
98
+
99
+ def get_identity_attributes
94
100
  begin
95
- @result = @idr.get_roles(@identity_uuid)
101
+ @result = @idr.get_attributes(@identity_uuid)
96
102
  rescue SoarIdm::IdentityError => e
97
103
  @error = e
98
104
  end
99
105
  end
100
106
 
101
- def get_identity_attributes
102
- @result = @idr.get_attributes(@identity_uuid)
103
- end
104
-
105
107
  def get_role_attributes
106
108
  @result = @idr.get_attributes(@identity_uuid, @roles.nil? ? Faker::Company.unique.profession : @roles[0][:role])
107
109
  end
108
110
 
111
+ ##### then
112
+
109
113
  def identity_attributes?
110
114
  roles = {}
111
115
  @roles.each do |entry|
@@ -64,12 +64,10 @@ module Soar
64
64
  )
65
65
  end
66
66
 
67
+ ##### when
68
+
67
69
  def get_roles
68
- begin
69
- @result = @idr.get_roles(@identity_uuid)
70
- rescue SoarIdm::IdentityError => e
71
- @error = e
72
- end
70
+ @result = @idr.get_roles(@identity_uuid)
73
71
  end
74
72
 
75
73
  def get_role_attributes
@@ -77,9 +75,15 @@ module Soar
77
75
  end
78
76
 
79
77
  def get_identity_attributes
80
- @result = @idr.get_attributes(@identity_uuid)
78
+ begin
79
+ @result = @idr.get_attributes(@identity_uuid)
80
+ rescue SoarIdm::IdentityError => e
81
+ @error = e
82
+ end
81
83
  end
82
84
 
85
+ ##### then
86
+
83
87
  def identity_attributes?
84
88
  @result == @identity
85
89
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soar-registry-identity
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.1
4
+ version: 5.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Mulder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-23 00:00:00.000000000 Z
11
+ date: 2017-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: soar_idm