omniauth-teamwork 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c794bffd4ee256ed8ef34e6ec5871c600306d8ca137a22411591228ae5667d5b
4
+ data.tar.gz: ace126d606b9aa0ab738376b9a58b5fe0ce1a61cb03ce263f16bab7f4cfd6fac
5
+ SHA512:
6
+ metadata.gz: 8e0ee15cee3947e00ff4e211134ef2c11d8ebbc235926bffbaeb8c86b1070d300fc9f9b4cd4b29179250475b7e8a251d70f23ed3343825a3d34f4f7065019e6d
7
+ data.tar.gz: 193495e99ed2e2dcf4b18c4d5c3ffcb599f74e9e857d0b806409322b1195b7cb2a3631f4913a749fa20fc0f3ae993a9e49753d746e1c8270b5d657ab12ed23e0
@@ -0,0 +1,28 @@
1
+ name: Ruby
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ${{ matrix.os }}-latest
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ os:
12
+ - ubuntu
13
+ ruby:
14
+ - "2.5"
15
+ - "2.6"
16
+ - "2.7"
17
+ - "3.0"
18
+ - "3.1"
19
+ - "3.2"
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+ - name: Set up Ruby
23
+ uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: ${{ matrix.ruby }}
26
+ bundler-cache: true # 'bundle install' and cache
27
+ - name: Run tests
28
+ run: bundle exec rake
@@ -0,0 +1,21 @@
1
+ name: Mark stale issues and pull requests
2
+
3
+ on:
4
+ schedule:
5
+ - cron: "0 0 * * *"
6
+
7
+ jobs:
8
+ stale:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/stale@v1
12
+ with:
13
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
14
+ stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
15
+ stale-pr-message: 'This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
16
+ stale-issue-label: 'no-issue-activity'
17
+ stale-pr-label: 'no-pr-activity'
18
+ days-before-stale: 30
19
+ days-before-close: 5
20
+ exempt-pr-label: 'pinned'
21
+ exempt-issue-label: 'pinned'
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ tmp
6
+ bin
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'http://rubygems.org'
4
+
5
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Kalpana
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/strategies/oauth2'
4
+
5
+ module OmniAuth
6
+ module Strategies
7
+ class Teamwork < OmniAuth::Strategies::OAuth2
8
+ option :name, 'teamwork'
9
+
10
+ option :client_options, {
11
+ site: 'https://www.teamwork.com/',
12
+ authorize_url: 'https://www.teamwork.com/launchpad/login',
13
+ token_url: 'https://www.teamwork.com/launchpad/v1/token'
14
+ }
15
+
16
+ uid { raw_info['id'] }
17
+
18
+ info do
19
+ {
20
+ email: raw_info['email_address'],
21
+ first_name: raw_info['first_name'],
22
+ last_name: raw_info['last_name'],
23
+ avatar_url: raw_info['avatar_url']
24
+ }
25
+ end
26
+
27
+ credentials { { token: access_token.token } }
28
+
29
+ extra { { raw_info: raw_info } }
30
+
31
+ def callback_url
32
+ options[:redirect_uri] || (full_host + script_name + callback_path)
33
+ end
34
+
35
+ def raw_info
36
+ url = "#{access_token.response.parsed.installation.api_end_point}me.json"
37
+ @raw_info ||= access_token.get(url).parsed.person
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAuth
4
+ module Teamwork
5
+ VERSION = '1.0.0'
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/teamwork/version'
4
+ require 'omniauth/strategies/teamwork'
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('./lib/omniauth/teamwork/version', __dir__)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = 'omniauth-teamwork'
7
+ gem.summary = 'Unofficial OmniAuth strategy for Teamwork.'
8
+ gem.description = 'Unofficial OmniAuth strategy for Teamwork.'
9
+ gem.authors = ['Kalpana']
10
+ gem.homepage = ''
11
+ gem.license = 'MIT'
12
+
13
+ gem.files = `git ls-files`.split("\n")
14
+ gem.require_paths = ['lib']
15
+ gem.version = OmniAuth::Teamwork::VERSION
16
+
17
+ gem.add_runtime_dependency 'omniauth-oauth2', '>= 1.2', '< 3'
18
+
19
+ gem.add_development_dependency 'rspec', '~> 3.12'
20
+ gem.add_development_dependency 'rake', '~> 13.0'
21
+ end
@@ -0,0 +1,83 @@
1
+ {
2
+ "marketo_id": "0",
3
+ "user_hash": "e3ba22a2d1699984884917f6695a3e14488799cce9e2d61332646818cb6f1b80",
4
+ "permissions": {
5
+ "can_access_templates": true,
6
+ "can_view_project_templates": true,
7
+ "can_add_projects": true,
8
+ "can_manage_custom_fields": true,
9
+ "can_manage_project_templates": true,
10
+ "can_access_calendar": true,
11
+ "is_admin_on_a_project": false,
12
+ "can_manage_people": true
13
+ },
14
+ "avatar_url": "https://s3.amazonaws.com/TWFiles/1021139/userAvatar/twia_a158142a5a47ade8d410a6ae0e34a7e5.png",
15
+ "current_feature_announcement": {
16
+ "date": "2023-07-28T15:55:00Z",
17
+ "code": "",
18
+ "link_text": "Learn more",
19
+ "callout_image": "",
20
+ "link": "https://www3.teamwork.com/everything-you-need-to-know-about-what-we-released-in-july",
21
+ "is_read": false,
22
+ "title": "What's new in Teamwork.com | July 2023",
23
+ "text": "Get the scoop on the latest product releases we've been cooking up at Teamwork.com.",
24
+ "html": "",
25
+ "id": "2520",
26
+ "type": "announcement"
27
+ },
28
+ "last_changed_on": "",
29
+ "email_address": "test_user@example.com",
30
+ "last_login": "2023-08-03T06:16:09Z",
31
+ "document_editor_installed": false,
32
+ "user_name": "testusername",
33
+ "id": "136576",
34
+ "phone_number_fax": "",
35
+ "site_owner": true,
36
+ "company_name": "Awesome Company",
37
+ "user_invited_date": "",
38
+ "phone_number_mobile": "",
39
+ "user_type": "account",
40
+ "has_feature_updates": true,
41
+ "open_id": "",
42
+ "address": { "city": "", "country": "", "countrycode": "", "zipcode": "", "state": "", "line1": "", "line2": "" },
43
+ "phone_number_office": "+01 123457890",
44
+ "im_handle": "",
45
+ "ld_hash": "99d2ae9093b3a812d74e4b7e411ea22fdb38b821259d374572f6f79f524dee41",
46
+ "is_client_user": false,
47
+ "two_factor_auth_enabled": false,
48
+ "tags": [],
49
+ "has_access_to_new_projects": true,
50
+ "installation_id": "1021139",
51
+ "im_service": "",
52
+ "deleted": false,
53
+ "notes": "",
54
+ "in_owner_company": "1",
55
+ "profile": "",
56
+ "user_invited_status": "COMPLETE",
57
+ "user_uuid": "",
58
+ "user_invited": "0",
59
+ "created_at": "2023-07-31T10:37:41Z",
60
+ "is_service_account": false,
61
+ "company_id": "1371610",
62
+ "has_desk_account": false,
63
+ "integrations": { "microsoft_connector": { "enabled": false } },
64
+ "phone_number_home": "",
65
+ "company_role_id": "5",
66
+ "profile_text": "",
67
+ "private_notes_text": "",
68
+ "pid": "",
69
+ "phone_number_mobile_parts": { "country_code": "", "prefix": "", "phone": "" },
70
+ "login_count": "50",
71
+ "private_notes": "",
72
+ "email_alt_1": "",
73
+ "administrator": true,
74
+ "email_alt_2": "",
75
+ "email_alt_3": "",
76
+ "feature_updates_count": "8",
77
+ "title": "",
78
+ "last_name": "User",
79
+ "first_name": "Test",
80
+ "phone_number_office_ext": "",
81
+ "twitter": "",
82
+ "length_of_day": "8.0"
83
+ }
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+ require 'omniauth-teamwork'
3
+
4
+ describe OmniAuth::Strategies::Teamwork do
5
+ let(:client_id) { '123' }
6
+ let(:client_secret) { 'asdfgh' }
7
+ let(:raw_info) { JSON.parse(File.read('./spec/fixtures/raw_info.json')) }
8
+ let(:request) { double('Request') }
9
+ let(:access_token) { double('OAuth2::AccessToken') }
10
+
11
+ before do
12
+ allow(request).to receive(:params).and_return({})
13
+ end
14
+
15
+ subject do
16
+ args = [client_id, client_secret].compact
17
+ OmniAuth::Strategies::Teamwork.new(nil, *args).tap do |strategy|
18
+ allow(strategy).to receive(:request).and_return(request)
19
+ end
20
+ end
21
+
22
+ describe '#client' do
23
+ it 'has correct Teamwork site' do
24
+ expect(subject.client.site).to eq('https://www.teamwork.com/')
25
+ end
26
+
27
+ it 'has correct authorize url' do
28
+ expect(subject.client.options[:authorize_url]).to eq('https://www.teamwork.com/launchpad/login')
29
+ end
30
+
31
+ it 'has correct token url' do
32
+ expect(subject.client.options[:token_url]).to eq('https://www.teamwork.com/launchpad/v1/token')
33
+ end
34
+ end
35
+
36
+ describe '#info' do
37
+ before do
38
+ allow(subject).to receive(:raw_info).and_return(raw_info)
39
+ end
40
+
41
+ context 'when data is present in raw info' do
42
+ it 'returns the name' do
43
+ expect(subject.info[:first_name]).to eq(raw_info['first_name'])
44
+ expect(subject.info[:last_name]).to eq(raw_info['last_name'])
45
+ end
46
+
47
+ it 'returns the avatar url' do
48
+ expect(subject.info[:avatar_url]).to eq(raw_info['avatar_url'])
49
+ end
50
+
51
+ it 'return the email' do
52
+ expect(subject.info[:email]).to eq(raw_info['email_address'])
53
+ end
54
+ end
55
+ end
56
+
57
+ describe '#credentials' do
58
+ before do
59
+ allow(access_token).to receive(:token).and_return('xxxxx')
60
+ allow(access_token).to receive(:expires?)
61
+ allow(subject).to receive(:access_token).and_return(access_token)
62
+ end
63
+
64
+ it 'returns a Hash' do
65
+ expect(subject.credentials).to be_a(Hash)
66
+ end
67
+
68
+ it 'returns the token' do
69
+ expect(subject.credentials[:token]).to eq('xxxxx')
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,5 @@
1
+ require 'bundler/setup'
2
+ require 'rspec'
3
+ require 'json'
4
+
5
+ Dir[File.expand_path('./spec/fixtures/**/*', __dir__)].each { |f| require f }
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-teamwork
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Kalpana
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-08-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '3'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '1.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '3'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.12'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.12'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '13.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '13.0'
61
+ description: Unofficial OmniAuth strategy for Teamwork.
62
+ email:
63
+ executables: []
64
+ extensions: []
65
+ extra_rdoc_files: []
66
+ files:
67
+ - ".github/workflows/ci.yml"
68
+ - ".github/workflows/stale.yml"
69
+ - ".gitignore"
70
+ - Gemfile
71
+ - LICENSE.md
72
+ - Rakefile
73
+ - lib/omniauth-teamwork.rb
74
+ - lib/omniauth/strategies/teamwork.rb
75
+ - lib/omniauth/teamwork/version.rb
76
+ - omniauth-teamwork.gemspec
77
+ - spec/fixtures/raw_info.json
78
+ - spec/omniauth/strategies/teamwork_spec.rb
79
+ - spec/spec_helper.rb
80
+ homepage: ''
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubygems_version: 3.2.22
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: Unofficial OmniAuth strategy for Teamwork.
103
+ test_files: []