oct_td_factory 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7ae8ba709270295bbea2f0fce2b7c69fa7798fc57ad1af8affb968778e2ae794
4
+ data.tar.gz: 3c8a316b1b0a43e4e9367478bd3c085bf39129647a2c0551b563c6cadab17566
5
+ SHA512:
6
+ metadata.gz: 12dac73f177654edd8a695dba57688dabef02adedec405c2c84dca4170b1bb50826076996fccba0ab6e7f2d208b6e4c845835b893d4ef44b47ed184096d4f766
7
+ data.tar.gz: 2186a8b613ee81ab2f7c67533c8408b409167bf03e7c1920fa491f0750087619f419c7a8ae68b4687dec7cbeca8575ef3b55b11170a28e62ad98de2f2284c713
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.3.7
7
+ before_install: gem install bundler -v 2.0.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at doug.vincent@octanner.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in oct_td_factory.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # OctTDFactory
2
+
3
+ ## Roadmap
4
+
5
+ - Align:
6
+ - Create Align topic
7
+ - Create Align comment
8
+
9
+
10
+ ## Usage
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'oct_td_factory'
16
+ ```
17
+
18
+ And then `bundle install`.
19
+
20
+
21
+ ## Development
22
+
23
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
+
25
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/octanner/oct_td_factory. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
34
+
35
+ ## Code of Conduct
36
+
37
+ Everyone interacting in the OctTdFactory project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/oct_td_factory/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "oct_td_factory"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,92 @@
1
+ module Apps
2
+ module Align
3
+ # - Create Align topic
4
+ # - Create Align comment
5
+ def login
6
+ @login ||= Login.new
7
+ end
8
+
9
+ def self.headless_login(creator)
10
+ Services::Login.login_headless(creator)
11
+ # get that user's token
12
+ token = Services::Login.get_logged_in_bearer_token
13
+ token
14
+ end
15
+
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!) {
25
+ createAlignTopic(input: $input) {
26
+ topic {
27
+ id
28
+ title
29
+ resolvedAt
30
+ resolvedBy {
31
+ id
32
+ }
33
+ createdAt
34
+ modifiedAt
35
+ deletedAt
36
+ owner {
37
+ id
38
+ }
39
+ participants {
40
+ nodes {
41
+ identity {
42
+ id
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }'
49
+ }
50
+
51
+ response = JSON.parse(Api::Graphql.post(token, payload).body)
52
+ Capybara.current_session.cleanup!
53
+ response
54
+ end
55
+
56
+ def self.create_comment(creator, participant_id)
57
+
58
+ topic_id = create_topic(creator, participant_id)['data']['createAlignTopic']['topic']['id']
59
+
60
+ token = headless_login(creator)
61
+
62
+ payload = {
63
+ variables: {
64
+ input: { text: 'comment created by automation', topicId: topic_id }
65
+ },
66
+ query:
67
+ 'mutation createAlignTopicComment(
68
+ $input: CreateAlignTopicCommentMutationInput!
69
+ ) {
70
+ createAlignTopicComment(input: $input) {
71
+ comment {
72
+ id
73
+ text
74
+ createdAt
75
+ modifiedAt
76
+ deletedAt
77
+ owner {
78
+ id
79
+ }
80
+ }
81
+ }
82
+ }'
83
+ }
84
+
85
+ response = JSON.parse(Api::Graphql.post(token, payload).body)
86
+ Capybara.current_session.cleanup!
87
+ response
88
+ end
89
+ end
90
+ end
91
+
92
+
@@ -0,0 +1,66 @@
1
+ module Services
2
+ class Login
3
+ include Capybara::DSL
4
+
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")
9
+
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
18
+
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
30
+
31
+ def self.login_headless(user)
32
+ set_headless_browser
33
+ login(user)
34
+ end
35
+
36
+ def self.password(user = 'TOPICS')
37
+ ENV.fetch(user.upcase + '_PASSWORD')
38
+ end
39
+
40
+ def self.re_enter_username?(user)
41
+ return if page.find('input[id=usernameField]').value == username(user)
42
+
43
+ fill_in 'usernameField', with: username(user)
44
+ end
45
+
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
56
+ end
57
+
58
+ def self.url(app = 'TOPICS')
59
+ ENV.fetch(app.upcase + '_URL')
60
+ end
61
+
62
+ def self.username(user)
63
+ ENV.fetch(user.upcase + '_USERNAME')
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,15 @@
1
+ # require "oct_td_factory/version"
2
+ # require "oct_td_factory/federated_graphql"
3
+
4
+ module OctTdFactory
5
+ class Error < StandardError; end
6
+ # Your code goes here...
7
+
8
+ def self.create_align_topic(creator, participant_id)
9
+ Apps::Align.create_topic(creator, participant_id)
10
+ end
11
+
12
+ def self.create_align_comment(creator, participant_id)
13
+ Apps::Align.create_comment(creator, participant_id)
14
+ end
15
+ end
@@ -0,0 +1,34 @@
1
+ module Services
2
+ module CoreAuthClientCredentials
3
+ def fetch_core_auth_client_credentials
4
+ @url = ENV.fetch('CORE_URL')
5
+ @token_url = '/sso/oauth/token'
6
+ @grant_type = 'client_credentials'
7
+ @client_id = ENV.fetch('CORE_AUTH_CLIENT_ID')
8
+ @client_secret = ENV.fetch('CORE_AUTH_CLIENT_SECRET')
9
+ end
10
+
11
+ def core_client
12
+ fetch_core_auth_client_credentials
13
+
14
+ OAuth2::Client.new(
15
+ @client_id,
16
+ @client_secret,
17
+ site: @url,
18
+ token_url: @token_url
19
+ )
20
+ end
21
+
22
+ def core_token_response
23
+ @core_token_response ||= core_client.client_credentials.get_token
24
+ end
25
+
26
+ def core_access_token
27
+ @core_access_token ||= core_client.client_credentials.get_token.token
28
+ end
29
+
30
+ def create_request
31
+ OAuth2::AccessToken.new(core_client, core_access_token)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,18 @@
1
+ module Services
2
+ module FederatedGraphql
3
+ def self.post(token, payload)
4
+ url = URI(ENV.fetch('FED_GRAPHQL_URL'))
5
+
6
+ http = Net::HTTP.new(url.host, url.port)
7
+ http.use_ssl = (url.scheme == 'https')
8
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
9
+
10
+ request = Net::HTTP::Post.new(url)
11
+ request['Authorization'] = "Bearer #{token}"
12
+ request['Content-Type'] = 'application/json'
13
+ request.body = payload.to_json
14
+
15
+ http.request(request)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module OctTdFactory
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,36 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "oct_td_factory/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "oct_td_factory"
7
+ spec.version = OctTdFactory::VERSION
8
+ spec.authors = ["Raiphe Kelsch"]
9
+ spec.email = ["vagorek@hotmail.com"]
10
+
11
+ spec.summary = %q{Test Data Factory.}
12
+ spec.homepage = "https://github.com/octanner/td_factory"
13
+
14
+ spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
15
+
16
+ if spec.respond_to?(:metadata)
17
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
+ else
19
+ raise "RubyGems 2.0 or newer is required to protect against " \
20
+ "public gem pushes."
21
+ end
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # 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
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
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"
36
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: oct_td_factory
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Raiphe Kelsch
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-05-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: oauth2
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.4'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.4'
69
+ description:
70
+ email:
71
+ - vagorek@hotmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - lib/oct_td_factory/apps/align.rb
86
+ - lib/oct_td_factory/helpers/align_login.rb
87
+ - lib/oct_td_factory/oct_td_factory.rb
88
+ - lib/oct_td_factory/services/core_auth_client_credentials.rb
89
+ - lib/oct_td_factory/services/federated_graphql.rb
90
+ - lib/oct_td_factory/version.rb
91
+ - oct_td_factory.gemspec
92
+ homepage: https://github.com/octanner/td_factory
93
+ licenses: []
94
+ metadata:
95
+ allowed_push_host: https://rubygems.org
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubygems_version: 3.0.3
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Test Data Factory.
115
+ test_files: []