soar-authentication-identity_uuid_translator 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75d5f9b8860d8bdbdf32ffa7ffa5a3ca1876dec4
4
- data.tar.gz: bf14f64cbb3fac590c1e4e1a7c8258512ae3db14
3
+ metadata.gz: 5170d8db19db7393f57f5ce3d9e165243bd6d26f
4
+ data.tar.gz: d53f8635ad1f27d24316de2595a5e33bc85720ea
5
5
  SHA512:
6
- metadata.gz: b0a41effcb26eb22ee5d79476637ef5ff61484ac150f52aa40adb4a05ec4f7badb3e9a3cb7b6973c58cf49bcffd6f823ee6c6297f84031dce3307dbad75d79c5
7
- data.tar.gz: 040fb1c8e57b7c4b217a07602b726d96829163e598e74dc106a49ebceb5befe025e5ea748400d9534e10c2af127e9fd2c12bb7fac6752808bd383bf8628649a0
6
+ metadata.gz: 0e71c0fc96fa08683a6a8db684e19277bfd9b29911609649049ada997b8fbf3ea8313cda51b9dc4a31731150fd32f3552c23814f076f928d1862352a7bba8c2a
7
+ data.tar.gz: ea06b97cdd7255bad0e97fc41be960040ece69a5250218b8b8153b69e8311cca72b822878e2a24cabd399a198ee3d8291affe63994e42fc59fa653389f38e67c
data/.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "soar-authentication-identity_uuid_translator"
3
- spec.version = "1.0.0"
3
+ spec.version = "1.0.1"
4
4
  spec.authors = ["Charles Mulder"]
5
5
  spec.email = ["charles.mulder@hetzner.co.za"]
6
6
 
data/README.md CHANGED
@@ -17,8 +17,7 @@ $ bundle exec rspec spec/factory_spec.rb
17
17
 
18
18
  #### Soar::Authentication::IdentityUuidTranslator::RoleGenerator
19
19
  ```bash
20
- $ docker-compose --file docker-compose.dynamo_db.yml up --remove-orphans
21
- $ ROLES_DIRECTORY_CONFIG_FILE=config.dynamo_db.yml bundle exec rspec spec/role_generator_spec.rb
20
+ $ bundle exec rspec spec/role_generator_spec.rb
22
21
  ```
23
22
 
24
23
  #### Soar::Authentication::IdentityUuidTranslator::Provider::Customer
@@ -1,26 +1,15 @@
1
1
  version: "2"
2
2
  services:
3
3
 
4
- dynamodb:
5
- build:
6
- context: .
7
- dockerfile: Dockerfile.dynamo_db
8
- expose:
9
- - "8000"
10
-
11
4
  tests:
12
5
  build:
13
6
  context: .
14
7
  dockerfile: Dockerfile.rspec
15
- links:
16
- - dynamodb
17
8
  command:
18
9
  - bundle
19
10
  - exec
20
11
  - rspec
21
12
  - "spec/role_generator_spec.rb"
22
- environment:
23
- - ROLES_DIRECTORY_CONFIG_FILE=config.ci.dynamo_db.yml
24
13
 
25
14
 
26
15
 
@@ -13,7 +13,15 @@ module Soar
13
13
  module OrchestrationProvider
14
14
  class Base
15
15
 
16
+ SLEEP_SECONDS = 1
17
+ CONNECTION_RETRIES = 6
18
+
19
+ def initialize
20
+ @connection_retries = CONNECTION_RETRIES
21
+ end
22
+
16
23
  def given_roles_directory
24
+ begin
17
25
  roles_directory_configuration = YAML.load_file("config/#{ENV['ROLES_DIRECTORY_CONFIG_FILE']}")
18
26
  @roles_directory = Soar::Registry::Directory.new(
19
27
  Soar::Registry::Directory::Provider::DynamoDb.new(Hashie.symbolize_keys(roles_directory_configuration['config']))
@@ -22,6 +30,12 @@ module Soar
22
30
  name: roles_directory_configuration['config']['table'][:name],
23
31
  structure: JSON.parse(File.read("lib/soar/authentication/identity_uuid_translator/test/fixtures/roles_table.json"))
24
32
  })
33
+ rescue Soar::Registry::Directory::Error::NetworkingError => e
34
+ raise if @connection_retries == 0
35
+ sleep(SLEEP_SECONDS)
36
+ @connection_retries -= 1
37
+ given_roles_directory
38
+ end
25
39
  end
26
40
 
27
41
  def given_role_generator
@@ -33,15 +33,6 @@ module Soar
33
33
  @uuid == Soar::Authentication::IdentityUuidTranslator::UuidGenerator.generate("#{Soar::Authentication::IdentityUuidTranslator::Provider::Customer::PREFIX}#{@identity[:ID]}")
34
34
  end
35
35
 
36
- protected
37
-
38
- ##
39
- # Execute command using mysql client on terminal
40
- ##
41
- def recreate_table(host:, username:, password:, filepath:)
42
- `mysql -h #{host} -u#{username} -p#{password} konsoleh_genie < '#{filepath}'`
43
- end
44
-
45
36
  end
46
37
  end
47
38
  end
@@ -9,33 +9,36 @@ module Soar
9
9
 
10
10
  def given_identity_registry
11
11
 
12
- directory_configuration = YAML.load_file("config/#{ENV['IDENTITY_DIRECTORY_CONFIG_FILE']}")
13
-
14
- recreate_table({
15
- host: directory_configuration['config']['config']['host'],
16
- username: directory_configuration['config']['credentials']['username'],
17
- password: directory_configuration['config']['credentials']['password'],
18
- filepath: "lib/soar/authentication/identity_uuid_translator/test/fixtures/client_table.sql"
19
- })
20
-
21
- @directory = Soar::Registry::Directory.new(
22
- Soar::Registry::Directory::Provider::Mysql.new(Hashie.symbolize_keys(directory_configuration['config']))
23
- )
24
-
25
- @identity_registry = Soar::Registry::Identity.new(
26
- Soar::Registry::Identity::Provider::Customer::ClientNumber.new({
27
- directory: @directory,
28
- fetch_index: 'ID',
29
- search_index: 'Client_Number'
30
- })
31
- )
12
+ begin
13
+
14
+ directory_configuration = YAML.load_file("config/#{ENV['IDENTITY_DIRECTORY_CONFIG_FILE']}")
15
+
16
+ provider = Soar::Registry::Directory::Provider::Mysql.new(Hashie.symbolize_keys(directory_configuration['config']))
17
+ provider.client.query("DROP TABLE IF EXISTS `Client`")
18
+ 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))")
19
+
20
+ @directory = Soar::Registry::Directory.new(provider)
21
+
22
+ @identity_registry = Soar::Registry::Identity.new(
23
+ Soar::Registry::Identity::Provider::Customer::ClientNumber.new({
24
+ directory: @directory,
25
+ fetch_index: 'ID',
26
+ search_index: 'Client_Number'
27
+ })
28
+ )
29
+ rescue Soar::Registry::Directory::Error::NetworkingError => e
30
+ raise if @connection_retries == 0
31
+ sleep(SLEEP_SECONDS)
32
+ @connection_retries -= 1
33
+ given_identity_registry
34
+ end
32
35
  end
33
36
 
34
37
  def given_existing_identity
35
38
  @identity = {
36
39
  ID: Faker::Number.number(4),
37
- "Notifyemail_Invoice": Faker::Internet.email,
38
- "Client_Number": @identifier
40
+ Notifyemail_Invoice: Faker::Internet.email,
41
+ Client_Number: @identifier
39
42
  }
40
43
  @directory.put(@identity)
41
44
  end
@@ -9,33 +9,37 @@ module Soar
9
9
 
10
10
  def given_identity_registry
11
11
 
12
- directory_configuration = YAML.load_file("config/#{ENV['IDENTITY_DIRECTORY_CONFIG_FILE']}")
13
-
14
- recreate_table({
15
- host: directory_configuration['config']['config']['host'],
16
- username: directory_configuration['config']['credentials']['username'],
17
- password: directory_configuration['config']['credentials']['password'],
18
- filepath: "lib/soar/authentication/identity_uuid_translator/test/fixtures/client_table.sql"
19
- })
20
-
21
- @directory = Soar::Registry::Directory.new(
22
- Soar::Registry::Directory::Provider::Mysql.new(Hashie.symbolize_keys(directory_configuration['config']))
23
- )
24
-
25
- @identity_registry = Soar::Registry::Identity.new(
26
- Soar::Registry::Identity::Provider::Customer::Email.new({
27
- directory: @directory,
28
- fetch_index: 'ID',
29
- search_index: 'Notifyemail_Invoice'
30
- })
31
- )
12
+ begin
13
+ directory_configuration = YAML.load_file("config/#{ENV['IDENTITY_DIRECTORY_CONFIG_FILE']}")
14
+
15
+ provider = Soar::Registry::Directory::Provider::Mysql.new(Hashie.symbolize_keys(directory_configuration['config']))
16
+
17
+ provider.client.query("DROP TABLE IF EXISTS `Client`")
18
+ 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))")
19
+
20
+ @directory = Soar::Registry::Directory.new(provider)
21
+
22
+ @identity_registry = Soar::Registry::Identity.new(
23
+ Soar::Registry::Identity::Provider::Customer::Email.new({
24
+ directory: @directory,
25
+ fetch_index: 'ID',
26
+ search_index: 'Notifyemail_Invoice'
27
+ })
28
+ )
29
+ rescue Soar::Registry::Directory::Error::NetworkingError => e
30
+ raise if @connection_retries == 0
31
+ sleep(self::SLEEP_SECONDS)
32
+ @connection_retries -= 1
33
+ given_identity_registry
34
+ end
35
+
32
36
  end
33
37
 
34
38
  def given_existing_identity
35
39
  @identity = {
36
40
  ID: Faker::Number.number(4),
37
- "Notifyemail_Invoice": @identifier,
38
- "Client_Number": "C#{Faker::Number.unique.number(10)}"
41
+ Notifyemail_Invoice: @identifier,
42
+ Client_Number: "C#{Faker::Number.unique.number(10)}"
39
43
  }
40
44
  @directory.put(@identity)
41
45
  end
@@ -39,19 +39,26 @@ module Soar
39
39
 
40
40
  def given_identity_registry
41
41
 
42
- @identity_directory_configuration = YAML.load_file("config/#{ENV['IDENTITY_DIRECTORY_CONFIG_FILE']}")
42
+ begin
43
+ @identity_directory_configuration = YAML.load_file("config/#{ENV['IDENTITY_DIRECTORY_CONFIG_FILE']}")
43
44
 
44
- @identity_directory = Soar::Registry::Directory.new(
45
- Soar::Registry::Directory::Provider::Ldap.new(Hashie.symbolize_keys(@identity_directory_configuration['config']))
46
- )
45
+ @identity_directory = Soar::Registry::Directory.new(
46
+ Soar::Registry::Directory::Provider::Ldap.new(Hashie.symbolize_keys(@identity_directory_configuration['config']))
47
+ )
47
48
 
48
- @identity_registry = Soar::Registry::Identity.new(
49
- Soar::Registry::Identity::Provider::Staff::Email.new({
50
- directory: @identity_directory,
51
- fetch_index: 'entryuuid',
52
- search_index: 'mail'
53
- })
54
- )
49
+ @identity_registry = Soar::Registry::Identity.new(
50
+ Soar::Registry::Identity::Provider::Staff::Email.new({
51
+ directory: @identity_directory,
52
+ fetch_index: 'entryuuid',
53
+ search_index: 'mail'
54
+ })
55
+ )
56
+ rescue Soar::Registry::Directory::Error::NetworkingError => e
57
+ raise if @connection_retries == 0
58
+ sleep(SLEEP_SECONDS)
59
+ @connection_retries -= 1
60
+ given_identity_registry
61
+ end
55
62
  end
56
63
 
57
64
  def role?
@@ -1,3 +1,5 @@
1
+ require 'uuidtools'
2
+
1
3
  module Soar
2
4
  module Authentication
3
5
  module IdentityUuidTranslator
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soar-authentication-identity_uuid_translator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
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-02-28 00:00:00.000000000 Z
11
+ date: 2017-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: soar-registry-identity