oct_td_factory 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: 7ae8ba709270295bbea2f0fce2b7c69fa7798fc57ad1af8affb968778e2ae794
4
- data.tar.gz: 3c8a316b1b0a43e4e9367478bd3c085bf39129647a2c0551b563c6cadab17566
3
+ metadata.gz: ba7f6a2adc88fda7b80e72393d1d61f4f31abb5e3974e38493ca133a9a4da28b
4
+ data.tar.gz: 406e0c7cc2c7c28530ffd8170e0e14addce8465a5810ebd382d195feb966339c
5
5
  SHA512:
6
- metadata.gz: 12dac73f177654edd8a695dba57688dabef02adedec405c2c84dca4170b1bb50826076996fccba0ab6e7f2d208b6e4c845835b893d4ef44b47ed184096d4f766
7
- data.tar.gz: 2186a8b613ee81ab2f7c67533c8408b409167bf03e7c1920fa491f0750087619f419c7a8ae68b4687dec7cbeca8575ef3b55b11170a28e62ad98de2f2284c713
6
+ metadata.gz: 847520de8110bc9dc2abdbebe019fbdb03f89d6174de16f167c32e2a1cb85337767a17e932fec4061adc50c706e089e077f3c458fc4a97f5d1ff41280f89ce3b
7
+ data.tar.gz: 962037ef43449a939ea8d5c0769af6744b5eb43452e5fec94cecb0d38f6f1861e8a1e280f1981a5fe3e413c731425438b8c9386f96e3a549b04049b5c8f9bec0
@@ -0,0 +1 @@
1
+ 2.7.1
data/Gemfile CHANGED
@@ -1,4 +1,7 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in oct_td_factory.gemspec
6
+ gem 'rubocop'
4
7
  gemspec
@@ -0,0 +1,70 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ oct_td_factory (0.1.1)
5
+ oauth2 (~> 1.4)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.1)
11
+ diff-lcs (1.4.2)
12
+ faraday (1.0.1)
13
+ multipart-post (>= 1.2, < 3)
14
+ jwt (2.2.1)
15
+ multi_json (1.14.1)
16
+ multi_xml (0.6.0)
17
+ multipart-post (2.1.1)
18
+ oauth2 (1.4.4)
19
+ faraday (>= 0.8, < 2.0)
20
+ jwt (>= 1.0, < 3.0)
21
+ multi_json (~> 1.3)
22
+ multi_xml (~> 0.5)
23
+ rack (>= 1.2, < 3)
24
+ parallel (1.19.2)
25
+ parser (2.7.1.4)
26
+ ast (~> 2.4.1)
27
+ rack (2.2.3)
28
+ rainbow (3.0.0)
29
+ rake (10.5.0)
30
+ regexp_parser (1.7.1)
31
+ rexml (3.2.4)
32
+ rspec (3.9.0)
33
+ rspec-core (~> 3.9.0)
34
+ rspec-expectations (~> 3.9.0)
35
+ rspec-mocks (~> 3.9.0)
36
+ rspec-core (3.9.2)
37
+ rspec-support (~> 3.9.3)
38
+ rspec-expectations (3.9.2)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.9.0)
41
+ rspec-mocks (3.9.1)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.9.0)
44
+ rspec-support (3.9.3)
45
+ rubocop (0.86.0)
46
+ parallel (~> 1.10)
47
+ parser (>= 2.7.0.1)
48
+ rainbow (>= 2.2.2, < 4.0)
49
+ regexp_parser (>= 1.7)
50
+ rexml
51
+ rubocop-ast (>= 0.0.3, < 1.0)
52
+ ruby-progressbar (~> 1.7)
53
+ unicode-display_width (>= 1.4.0, < 2.0)
54
+ rubocop-ast (0.0.3)
55
+ parser (>= 2.7.0.1)
56
+ ruby-progressbar (1.10.1)
57
+ unicode-display_width (1.7.0)
58
+
59
+ PLATFORMS
60
+ ruby
61
+
62
+ DEPENDENCIES
63
+ bundler (~> 2.0)
64
+ oct_td_factory!
65
+ rake (~> 10.0)
66
+ rspec (~> 3.0)
67
+ rubocop
68
+
69
+ BUNDLED WITH
70
+ 2.1.4
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "oct_td_factory"
4
+ require 'bundler/setup'
5
+ require 'oct_td_factory'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "oct_td_factory"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
@@ -1,27 +1,29 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Apps
2
4
  module Align
3
5
  # - Create Align topic
4
6
  # - Create Align comment
5
7
  def login
6
- @login ||= Login.new
8
+ @login ||= AlignLogin.new
7
9
  end
8
10
 
9
11
  def self.headless_login(creator)
10
12
  Services::Login.login_headless(creator)
11
- # get that user's token
13
+ # get that user's token
12
14
  token = Services::Login.get_logged_in_bearer_token
13
15
  token
14
16
  end
15
17
 
16
- def self.create_topic(creator, participant_id) #use in before block
17
-
18
- token = headless_login(creator)
19
- payload = {
20
- variables: {
21
- input: { title: 'topic created by automation', participantId: participant_id }
22
- },
23
- query:
24
- 'mutation createAlignTopic($input: CreateAlignTopicMutationInput!) {
18
+ def self.create_topic(creator, participant) # use in before block
19
+ participant_id = ENV.fetch("#{participant}_UUID")
20
+ token = login.user_token(creator)
21
+ payload = {
22
+ variables: {
23
+ input: { title: 'topic created by automation', participantId: participant_id }
24
+ },
25
+ query:
26
+ 'mutation createAlignTopic($input: CreateAlignTopicMutationInput!) {
25
27
  createAlignTopic(input: $input) {
26
28
  topic {
27
29
  id
@@ -46,24 +48,23 @@ module Apps
46
48
  }
47
49
  }
48
50
  }'
49
- }
51
+ }
50
52
 
51
- response = JSON.parse(Api::Graphql.post(token, payload).body)
52
- Capybara.current_session.cleanup!
53
- response
53
+ response = JSON.parse(Api::Graphql.post(token, payload).body)
54
+ Capybara.current_session.cleanup!
55
+ response
54
56
  end
55
57
 
56
58
  def self.create_comment(creator, participant_id)
57
-
58
59
  topic_id = create_topic(creator, participant_id)['data']['createAlignTopic']['topic']['id']
59
-
60
+
60
61
  token = headless_login(creator)
61
62
 
62
63
  payload = {
63
64
  variables: {
64
65
  input: { text: 'comment created by automation', topicId: topic_id }
65
66
  },
66
- query:
67
+ query:
67
68
  'mutation createAlignTopicComment(
68
69
  $input: CreateAlignTopicCommentMutationInput!
69
70
  ) {
@@ -88,5 +89,3 @@ module Apps
88
89
  end
89
90
  end
90
91
  end
91
-
92
-
@@ -1,66 +1,96 @@
1
- module Services
2
- class Login
3
- include Capybara::DSL
1
+ # frozen_string_literal: true
4
2
 
5
- def self.get_logged_in_bearer_token
6
- align_cookie = Capybara.current_session.driver.browser.manage.cookie_named('align')[:value]
7
- align_sig = Capybara.current_session.driver.browser.manage.cookie_named('align.sig')[:value]
8
- url = URI("#{ENV.fetch('TOPICS_URL')}/auth/token")
3
+ class AlignLogin < AutomationFramework::Utilities
4
+ attr_accessor :token
5
+ include Capybara::DSL
9
6
 
10
- http = Net::HTTP.new(url.host, url.port)
11
- http.use_ssl = (url.scheme == 'https')
12
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
13
- request = Net::HTTP::Post.new(url)
14
- request['Cookie'] = "align=#{align_cookie}; align.sig=#{align_sig}"
15
- response = http.request(request)
16
- JSON.parse(response.body)['accessToken']
17
- end
7
+ # def app
8
+ # @app ||= AutomationFramework::Application.instance
9
+ # end
18
10
 
19
- def self.login(user, app_url = url)
20
- binding.pry
21
- visit(app_url)
22
- find('#usernameField').set(username(user))
23
- find('button[id=nextButton]').click
24
- has_css?('#usernameField')
25
- has_css?('#passwordField', wait: 1)
26
- find('#passwordField').set(password)
27
- find('#signInButton').click
28
- has_css?('.user-name', wait: 5)
29
- end
11
+ def get_logged_in_bearer_token
12
+ align_cookie = Capybara.current_session.driver.browser.manage.cookie_named('align')[:value]
13
+ align_sig = Capybara.current_session.driver.browser.manage.cookie_named('align.sig')[:value]
14
+ url = URI("#{ENV.fetch('TOPICS_URL')}/auth/token")
30
15
 
31
- def self.login_headless(user)
32
- set_headless_browser
33
- login(user)
34
- end
16
+ http = Net::HTTP.new(url.host, url.port)
17
+ http.use_ssl = (url.scheme == 'https')
18
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
19
+ request = Net::HTTP::Post.new(url)
20
+ request['Cookie'] = "align=#{align_cookie}; align.sig=#{align_sig}"
21
+ response = http.request(request)
22
+ JSON.parse(response.body)['accessToken']
23
+ end
35
24
 
36
- def self.password(user = 'TOPICS')
37
- ENV.fetch(user.upcase + '_PASSWORD')
38
- end
25
+ def login(user, app_url = url)
26
+ logout
27
+ visit(app_url)
28
+ find('#usernameField').set(username(user))
29
+ find('button[id=nextButton]').click
30
+ has_css?('#usernameField')
31
+ has_css?('#passwordField', wait: 1)
32
+ find('#passwordField').set(password)
33
+ find('#signInButton').click
34
+ has_css?('.user-name', wait: 5)
35
+ set_token(user)
36
+ end
39
37
 
40
- def self.re_enter_username?(user)
41
- return if page.find('input[id=usernameField]').value == username(user)
38
+ def login_headless(user)
39
+ set_headless_browser
40
+ login(user)
41
+ end
42
42
 
43
- fill_in 'usernameField', with: username(user)
44
- end
43
+ def logout
44
+ visit("#{url}/logout")
45
+ Capybara.current_session.driver.browser.manage.delete_all_cookies
46
+ end
47
+
48
+ def password(user = 'TOPICS')
49
+ ENV.fetch(user.upcase + '_PASSWORD')
50
+ end
51
+
52
+ def re_enter_username?(user)
53
+ return if page.find('input[id=usernameField]').value == username(user)
45
54
 
46
- def self.set_headless_browser(screen_width = (ENV['SCREEN_WIDTH'] || '1600'),
47
- screen_height = (ENV['SCREEN_HEIGHT'] || '1200'))
48
- Capybara.register_driver :selenium_chrome_headless do |app|
49
- o = Selenium::WebDriver::Chrome::Options
50
- .new(args: ['--headless', '--disable-gpu', '--no-sandbox', '--disable-dev-shm-usage',
51
- '--incognito', '--disable-notifications',
52
- "--window-size=#{screen_width},#{screen_height}"])
53
- Capybara::Selenium::Driver.new(app, browser: :chrome, options: o)
54
- end
55
- Capybara.current_driver = :selenium_chrome_headless
55
+ fill_in 'usernameField', with: username(user)
56
+ end
57
+
58
+ def set_headless_browser(screen_width = (ENV['SCREEN_WIDTH'] || '1600'),
59
+ screen_height = (ENV['SCREEN_HEIGHT'] || '1200'))
60
+ Capybara.register_driver :selenium_chrome_headless do |app|
61
+ o = Selenium::WebDriver::Chrome::Options
62
+ .new(args: ['--headless', '--disable-gpu', '--no-sandbox', '--disable-dev-shm-usage',
63
+ '--incognito', '--disable-notifications',
64
+ "--window-size=#{screen_width},#{screen_height}"])
65
+ Capybara::Selenium::Driver.new(app, browser: :chrome, options: o)
56
66
  end
67
+ Capybara.current_driver = :selenium_chrome_headless
68
+ end
57
69
 
58
- def self.url(app = 'TOPICS')
59
- ENV.fetch(app.upcase + '_URL')
70
+ def set_token(user)
71
+ if token.is_a?(Hash)
72
+ token[user] = get_logged_in_bearer_token
73
+ else
74
+ self.token = { user => get_logged_in_bearer_token }
60
75
  end
76
+ end
61
77
 
62
- def self.username(user)
63
- ENV.fetch(user.upcase + '_USERNAME')
78
+ def user_token(user)
79
+ if token.nil? || token.key?(user) == false
80
+ login_headless(user)
81
+ elsif JWT.decode(token[user], nil, false)[0]['exp'] > (Time.now + 60).to_i
82
+ token[user] = token[user]
83
+ else
84
+ login_headless(user)
64
85
  end
86
+ token[user]
87
+ end
88
+
89
+ def url(app = 'TOPICS')
90
+ ENV.fetch(app.upcase + '_URL')
91
+ end
92
+
93
+ def username(user)
94
+ ENV.fetch(user.upcase + '_USERNAME')
65
95
  end
66
- end
96
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # require "oct_td_factory/version"
2
4
  # require "oct_td_factory/federated_graphql"
3
5
 
@@ -12,4 +14,4 @@ module OctTdFactory
12
14
  def self.create_align_comment(creator, participant_id)
13
15
  Apps::Align.create_comment(creator, participant_id)
14
16
  end
15
- end
17
+ end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Services
2
4
  module CoreAuthClientCredentials
3
5
  def fetch_core_auth_client_credentials
4
- @url = ENV.fetch('CORE_URL')
6
+ @url = ENV.fetch('CORE_URL')
5
7
  @token_url = '/sso/oauth/token'
6
8
  @grant_type = 'client_credentials'
7
9
  @client_id = ENV.fetch('CORE_AUTH_CLIENT_ID')
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Services
2
4
  module FederatedGraphql
3
5
  def self.post(token, payload)
@@ -15,4 +17,4 @@ module Services
15
17
  http.request(request)
16
18
  end
17
19
  end
18
- end
20
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OctTdFactory
2
- VERSION = "0.1.0"
4
+ VERSION = '0.1.1'
3
5
  end
@@ -1,36 +1,38 @@
1
- lib = File.expand_path("lib", __dir__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require "oct_td_factory/version"
5
+ require 'oct_td_factory/version'
4
6
 
5
7
  Gem::Specification.new do |spec|
6
- spec.name = "oct_td_factory"
8
+ spec.name = 'oct_td_factory'
7
9
  spec.version = OctTdFactory::VERSION
8
- spec.authors = ["Raiphe Kelsch"]
9
- spec.email = ["vagorek@hotmail.com"]
10
+ spec.authors = ['Raiphe Kelsch']
11
+ spec.email = ['vagorek@hotmail.com']
10
12
 
11
- spec.summary = %q{Test Data Factory.}
12
- spec.homepage = "https://github.com/octanner/td_factory"
13
+ spec.summary = 'Test Data Factory.'
14
+ spec.homepage = 'https://github.com/octanner/td_factory'
13
15
 
14
- spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
16
+ spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
15
17
 
16
18
  if spec.respond_to?(:metadata)
17
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
18
20
  else
19
- raise "RubyGems 2.0 or newer is required to protect against " \
20
- "public gem pushes."
21
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
22
+ 'public gem pushes.'
21
23
  end
22
24
 
23
25
  # Specify which files should be added to the gem when it is released.
24
26
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
27
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
28
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
29
  end
28
- spec.bindir = "exe"
30
+ spec.bindir = 'exe'
29
31
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
- spec.require_paths = ["lib"]
32
+ spec.require_paths = ['lib']
31
33
 
32
- spec.add_development_dependency "bundler", "~> 2.0"
33
- spec.add_development_dependency "rake", "~> 10.0"
34
- spec.add_development_dependency "rspec", "~> 3.0"
35
- spec.add_runtime_dependency "oauth2", "~> 1.4"
34
+ spec.add_development_dependency 'bundler', '~> 2.0'
35
+ spec.add_development_dependency 'rake', '~> 10.0'
36
+ spec.add_development_dependency 'rspec', '~> 3.0'
37
+ spec.add_runtime_dependency 'oauth2', '~> 1.4'
36
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oct_td_factory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raiphe Kelsch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-14 00:00:00.000000000 Z
11
+ date: 2020-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -75,9 +75,11 @@ extra_rdoc_files: []
75
75
  files:
76
76
  - ".gitignore"
77
77
  - ".rspec"
78
+ - ".ruby-version"
78
79
  - ".travis.yml"
79
80
  - CODE_OF_CONDUCT.md
80
81
  - Gemfile
82
+ - Gemfile.lock
81
83
  - README.md
82
84
  - Rakefile
83
85
  - bin/console
@@ -108,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
110
  - !ruby/object:Gem::Version
109
111
  version: '0'
110
112
  requirements: []
111
- rubygems_version: 3.0.3
113
+ rubygems_version: 3.1.2
112
114
  signing_key:
113
115
  specification_version: 4
114
116
  summary: Test Data Factory.