alinta-testing 0.2.3 → 0.3.0

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
  SHA256:
3
- metadata.gz: ac9678c036d6a35e3221a169b25b5794f7be840a334bb53ae9fe1a8621f4344e
4
- data.tar.gz: 4725fed5126bfd2a116828de6c430c94f82e9e30f23f41f4d92e7e6778b1ba44
3
+ metadata.gz: 0a0dd9cd987dca9caf8aa75e679a7a214820df68d14d1ab2fcb0db37d2fdd53b
4
+ data.tar.gz: 285ecd4778daaf7b8727e63a0ae8f3fe0d3a974ef8e315f5c6369bd9f7f62f62
5
5
  SHA512:
6
- metadata.gz: bbaa52d49583974f24e2f40c30b01757d6c18965575f638938cfd75cb92042955fddacf73a0cf763697fc8d89b524037e0ec692e2101a024c23cb77d371a8443
7
- data.tar.gz: a6b01376e181a734f740fd69a8ccbc3813060acad73c1a3c0eabd3595293c727e5b659c748d4428f697f0dab1a73cd0204af314ca2b1b5ac421e8b101943621a
6
+ metadata.gz: 8026aabfd05328f4488252749fbbdb9db20bbdd6d9988c74064e6bbf1ed4927bcf60453454d1841a25b181f7ebd48e3ca9aea0bd9ce702f7ed939137560e8e7a
7
+ data.tar.gz: 9ce66c8035e68f3ccd1e51eff726a14d9d102224a5a108784047971570f203b20cd74e057be3853d0bf6a3b22f3ac4bde5f93e132ca123bcf24e282b81017a9e
@@ -0,0 +1,31 @@
1
+ require 'cucumber-rest-bdd'
2
+
3
+ class Hash
4
+ def deep_include?(other)
5
+ diff = other.easy_diff(self)
6
+ diff[0].delete_if { |_k, v| v.empty? if v.is_a?(::Hash) }
7
+ # this line is new and supports regular expressions
8
+ diff[0].delete_if { |_k, v| v.match(diff[1][_k]) if v.is_a?(::Regexp) }
9
+ diff[0].empty?
10
+ end
11
+ end
12
+
13
+ def parse_attributes(hashes)
14
+ hashes.each_with_object({}) do |row, hash|
15
+ name = row['attribute']
16
+ value = row['value']
17
+ type = row['type']
18
+ # this condition is new and allows the value to be resolved from ruby code
19
+ if type == 'expression'
20
+ value = eval(value)
21
+ else
22
+ value = resolve_functions(value)
23
+ value = resolve(value)
24
+ value.gsub!(/\\n/, "\n")
25
+ value = string_to_type(value, type)
26
+ end
27
+ names = split_fields(name)
28
+ new_hash = names.reverse.inject(value) { |a, n| add_to_hash(a, n) }
29
+ hash.deep_merge!(new_hash) { |_, old, new| new.is_a?(Array) ? merge_arrays(old, new) : new }
30
+ end
31
+ end
@@ -0,0 +1,77 @@
1
+ require 'cucumber-rest-bdd'
2
+
3
+ Given("I am an API management authenticated client") do
4
+ if ENV['apim_subscription_key'] != nil && ENV['apim_subscription_key'] != ""
5
+ @apim_subscription_key = ENV['apim_subscription_key']
6
+ else
7
+ variables = %w{ALINTA_TENANTID ALINTA_CLIENTID ALINTA_CLIENTSECRET ALINTA_VAULT}
8
+ missing = variables.find_all { |v| ENV[v] == nil }
9
+ unless missing.empty?
10
+ raise "The following required environment variables have not been defined: #{missing.join(', ')}."
11
+ end
12
+ steps %Q{
13
+ Given I retrieve the API Management subscription key secret "APIMgmnt--End2End--Unlimited--Primary" from Azure Storage Vault "#{ENV['ALINTA_VAULT']}" using tenant "#{ENV['ALINTA_TENANTID']}" with credentials "#{ENV['ALINTA_CLIENTID']}" and "#{ENV['ALINTA_CLIENTSECRET']}"
14
+ }
15
+ end
16
+ steps %Q{
17
+ Given I am a client
18
+ And I add the API Management key header
19
+ }
20
+ end
21
+
22
+ Given("I retrieve the API Management subscription key secret {string} from Azure Storage Vault {string} using tenant {string} with credentials {string} and {string}") do |secret_name, vault_name, tenant_id, client_id, client_secret|
23
+ if @apim_subscription_key.to_s.empty?
24
+ steps %Q{
25
+ Given I retrieve the secret "#{secret_name}" from Azure Storage Vault "#{vault_name}" using tenant "#{tenant_id}" with credentials "#{client_id}" and "#{client_secret}"
26
+ }
27
+ @apim_subscription_key = @response.get_as_type "$..value", "string"
28
+ end
29
+ end
30
+
31
+ Given("I add the API Management key header") do
32
+ steps %Q{
33
+ And I add Headers:
34
+ | Ocp-Apim-Subscription-Key | #{@apim_subscription_key} |
35
+ }
36
+ end
37
+
38
+ Given("I retrieve the secret {string} from Azure Storage Vault {string} using tenant {string} with credentials {string} and {string}") do |secret_name, vault_name, tenant_id, client_id, client_secret|
39
+ steps %Q{
40
+ Given I authenticate with Azure tenant "#{tenant_id}" using client credentials "#{client_id}" and "#{client_secret}"
41
+ }
42
+ access_token = @response.get_as_type "$..access_token", "string"
43
+ steps %Q{
44
+ Given I retrieve the secret "#{secret_name}" from Azure Storage Vault "#{vault_name}" using access token "#{access_token}"
45
+ }
46
+ end
47
+
48
+ Given("I authenticate with Azure tenant {string} using client credentials {string} and {string}") do |tenant_id, client_id, client_secret|
49
+ steps %Q{
50
+ Given I authenticate with "https://login.windows.net/#{tenant_id}/oauth2/token" using client credentials "#{client_id}" and "#{client_secret}"
51
+ }
52
+ end
53
+
54
+ Given("I authenticate with {string} using client credentials {string} and {string}") do |url, client_id, client_secret|
55
+ steps %Q{
56
+ Given I send "www-x-form-urlencoded" and accept JSON
57
+ When I set form request body to:
58
+ | grant_type | client_credentials |
59
+ | client_id | #{client_id} |
60
+ | client_secret | #{client_secret} |
61
+ | resource | https://vault.azure.net |
62
+ And I send a POST request to "#{url}"
63
+ Then the request was successful
64
+ }
65
+ end
66
+
67
+ Given("I retrieve the secret {string} from Azure Storage Vault {string} using access token {string}") do |secret_name, vault_name, access_token|
68
+ api_version = '2015-06-01'
69
+ url = "https://#{vault_name}.vault.azure.net/secrets/#{secret_name}?api-version=#{api_version}"
70
+ steps %Q{
71
+ Given I send and accept JSON
72
+ And I add Headers:
73
+ | Authorization | Bearer #{access_token} |
74
+ When I send a GET request to "#{url}"
75
+ Then the request was successful
76
+ }
77
+ end
@@ -1,20 +1 @@
1
- require 'cucumber-rest-bdd'
2
-
3
- Given("I am an API management authenticated client") do
4
- if ENV['apim_subscription_key'] != nil && ENV['apim_subscription_key'] != ""
5
- @apim_subscription_key = ENV['apim_subscription_key']
6
- else
7
- variables = %w{ALINTA_TENANTID ALINTA_CLIENTID ALINTA_CLIENTSECRET ALINTA_VAULT}
8
- missing = variables.find_all { |v| ENV[v] == nil }
9
- unless missing.empty?
10
- raise "The following required environment variables have not been defined: #{missing.join(', ')}."
11
- end
12
- steps %Q{
13
- Given I retrieve the API Management subscription key secret "APIMgmnt--End2End--Unlimited--Primary" from Azure Storage Vault "#{ENV['ALINTA_VAULT']}" using tenant "#{ENV['ALINTA_TENANTID']}" with credentials "#{ENV['ALINTA_CLIENTID']}" and "#{ENV['ALINTA_CLIENTSECRET']}"
14
- }
15
- end
16
- steps %Q{
17
- Given I am a client
18
- And I add the API Management key header
19
- }
20
- end
1
+ require 'alinta-testing/steps/azure'
@@ -1,3 +1,3 @@
1
1
  module AlintaTesting
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1 +1,2 @@
1
- require 'alinta-testing/steps'
1
+ require 'alinta-testing/steps'
2
+ require 'alinta-testing/overrides'
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alinta-testing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Hosking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-09 00:00:00.000000000 Z
11
+ date: 2018-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: alinta-cucumber-rest-bdd
14
+ name: cucumber-rest-bdd
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.5.23
19
+ version: 0.6.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.5.23
26
+ version: 0.6.1
27
27
  description: alinta-testing performs common tasks for end to end tests in cucumber.
28
28
  email:
29
29
  - matt.hosking@alintaenergy.com.au
@@ -32,7 +32,9 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - lib/alinta-testing.rb
35
+ - lib/alinta-testing/overrides.rb
35
36
  - lib/alinta-testing/steps.rb
37
+ - lib/alinta-testing/steps/azure.rb
36
38
  - lib/alinta-testing/version.rb
37
39
  homepage: https://github.com/AlintaEnergy/alinta-testing
38
40
  licenses: