omniauth-icalia 0.1.0 → 0.1.5
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 +4 -4
- data/README.md +56 -0
- data/lib/icalia/stubbed_sso_service.rb +205 -0
- data/lib/omniauth-icalia/service_stubs.rb +1 -0
- data/lib/omniauth-icalia/version.rb +1 -1
- data/lib/omniauth/strategies/icalia.rb +21 -1
- data/omniauth-icalia.gemspec +5 -3
- metadata +56 -26
- data/.dockerignore +0 -45
- data/.gitignore +0 -18
- data/.rspec +0 -3
- data/.semaphore/bin/docker-image-manager +0 -161
- data/.semaphore/bin/generate-dotenv-file +0 -16
- data/.semaphore/publishing.yml +0 -62
- data/.semaphore/semaphore.yml +0 -111
- data/.travis.yml +0 -7
- data/Dockerfile +0 -22
- data/Gemfile +0 -9
- data/Gemfile.lock +0 -86
- data/ci-compose.yml +0 -41
- data/docker-compose.yml +0 -20
- data/spec/omniauth/strategies/icalia_spec.rb +0 -109
- data/spec/spec_helper.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76a507c543087c4a2c61fb09072b46178e53254676d28947a921a51901f87824
|
4
|
+
data.tar.gz: 5e807f57157e0b7bd9225bebac96e8f13c9046dc330249c0b7b89408ebb0433d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fbc1b076e8a864123affd12e35b1180702b2ec75a1adb98256c442fdf261e77c48bbbc070cda7715ccd48aff44b9df91cfa9bc94a0552ba375d228ace897350
|
7
|
+
data.tar.gz: 0c141cee9f07f64fb60fe73344311050794ed250f84c7c6ad1ccea275344389a75db0abc02ae15be6a0e249a5e9fe6b0cecbddc16647d4a196d6151e67882131
|
data/README.md
CHANGED
@@ -24,6 +24,62 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
TODO: Write usage instructions here
|
26
26
|
|
27
|
+
## System Testing on your app
|
28
|
+
|
29
|
+
You can use the included service stub in your system tests.
|
30
|
+
|
31
|
+
On your spec_helper, or test setup file:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
require 'omniauth-icalia/service_stubs'
|
35
|
+
```
|
36
|
+
|
37
|
+
Then, in your test setup, call `prepare`:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
# For example, in RSpec:
|
41
|
+
before { Icalia::StubbedSSOService.prepare }
|
42
|
+
|
43
|
+
# Use a block if you need to set the data returned by the service:
|
44
|
+
before do
|
45
|
+
Icalia::StubbedSSOService.prepare do |config|
|
46
|
+
# Optionally add example data about the expected token owner:
|
47
|
+
config.example_resource_owner_id = SecureRandom.uuid
|
48
|
+
config.example_resource_owner_given_name = 'George'
|
49
|
+
config.example_resource_owner_family_name = 'Harrison'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
If your'e testing a sign-in flow:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
scenario 'sign-in' do
|
58
|
+
# Simulate that the user will sign-in at the SSO site:
|
59
|
+
Icalia::StubbedSSOService.sign_in_on_authorize
|
60
|
+
visit root_path # or any path in your app that requires authentication
|
61
|
+
|
62
|
+
#...
|
63
|
+
end
|
64
|
+
```
|
65
|
+
|
66
|
+
If your'e testing a sign-out flow:
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
scenario 'sign-out' do
|
70
|
+
# Simulate that the user will sign-in at the SSO site:
|
71
|
+
Icalia::StubbedSSOService.sign_in_on_authorize
|
72
|
+
visit root_path # or any path in your app that requires authentication
|
73
|
+
|
74
|
+
# Simulate that the user won't sign-in at the SSO site:
|
75
|
+
Icalia::StubbedSSOService.do_not_sign_in_on_authorize
|
76
|
+
click_link 'Logout'
|
77
|
+
|
78
|
+
# The message coming from Artanis & the Fake Artanis "StubbedSSOService":
|
79
|
+
expect(page).to have_content 'Signed out successfully.'
|
80
|
+
end
|
81
|
+
```
|
82
|
+
|
27
83
|
## Development
|
28
84
|
|
29
85
|
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.
|
@@ -0,0 +1,205 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
|
3
|
+
require 'capybara'
|
4
|
+
require 'capybara/server'
|
5
|
+
|
6
|
+
require 'socket'
|
7
|
+
|
8
|
+
module Icalia
|
9
|
+
class StubbedSSOService < Sinatra::Base
|
10
|
+
FIND_AVAILABLE_PORT = 0
|
11
|
+
CODE = 'icalia_oauth_authorization_code'.freeze
|
12
|
+
|
13
|
+
@@sign_in_user_on_authorize = false
|
14
|
+
|
15
|
+
post '/oauth/token' do
|
16
|
+
if params[:code] == CODE
|
17
|
+
response.headers['Content-Type'] = 'application/json'
|
18
|
+
flow = oauth_flows.last
|
19
|
+
data = flow.slice('state').merge(
|
20
|
+
access_token: 'ACCESS_TOKEN',
|
21
|
+
token_type: 'Bearer',
|
22
|
+
created_at: DateTime.now.to_i
|
23
|
+
)
|
24
|
+
flow[:granted_access_data] = data
|
25
|
+
data.to_json
|
26
|
+
else
|
27
|
+
status 400
|
28
|
+
{
|
29
|
+
error: 'invalid_grant',
|
30
|
+
error_description: "Authorization code does not exist: #{code}",
|
31
|
+
}.to_json
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
get '/sign-in' do
|
36
|
+
'Signed out successfully.'
|
37
|
+
end
|
38
|
+
|
39
|
+
get '/sign-out' do
|
40
|
+
uri = URI(params[:redirect_uri])
|
41
|
+
redirect uri
|
42
|
+
end
|
43
|
+
|
44
|
+
get '/oauth/authorize' do
|
45
|
+
return redirect '/sign-in' unless @@sign_in_user_on_authorize
|
46
|
+
|
47
|
+
store_oauth_flow_data params
|
48
|
+
uri = URI(params[:redirect_uri])
|
49
|
+
uri.query = URI.encode_www_form(state: params[:state], code: CODE)
|
50
|
+
redirect uri
|
51
|
+
end
|
52
|
+
|
53
|
+
get '/oauth/token/info' do
|
54
|
+
flow = oauth_flows.last
|
55
|
+
data = {
|
56
|
+
data: {
|
57
|
+
id: SecureRandom.uuid,
|
58
|
+
type: 'oauth-access-token',
|
59
|
+
attributes: {
|
60
|
+
scopes: [],
|
61
|
+
'expires-at': nil,
|
62
|
+
'created-at': Time.at(flow.dig(:granted_access_data, :created_at))
|
63
|
+
},
|
64
|
+
relationships: {
|
65
|
+
'resource-owner': {
|
66
|
+
data: { type: 'person', id: example_resource_owner_id }
|
67
|
+
}
|
68
|
+
}
|
69
|
+
},
|
70
|
+
included: [
|
71
|
+
{
|
72
|
+
type: 'person',
|
73
|
+
id: example_resource_owner_id,
|
74
|
+
attributes: {
|
75
|
+
'full-name': example_resource_owner_full_name,
|
76
|
+
'given-name': example_resource_owner_given_name,
|
77
|
+
'family-name': example_resource_owner_family_name,
|
78
|
+
'gender-type': example_resource_owner_gender_type,
|
79
|
+
'custom-gender': example_resource_owner_custom_gender
|
80
|
+
}
|
81
|
+
}
|
82
|
+
]
|
83
|
+
}
|
84
|
+
response.headers['Content-Type'] = 'application/vnd.api+json'
|
85
|
+
data.to_json
|
86
|
+
end
|
87
|
+
|
88
|
+
%i[example_resource_owner_id example_resource_owner_given_name
|
89
|
+
example_resource_owner_family_name example_resource_owner_gender_type
|
90
|
+
example_resource_owner_custom_gender].each do |method_name|
|
91
|
+
define_singleton_method method_name do
|
92
|
+
class_variable_get("@@#{method_name}")
|
93
|
+
end
|
94
|
+
|
95
|
+
define_singleton_method "#{method_name}=".to_sym do |value|
|
96
|
+
class_variable_set("@@#{method_name}", value)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
%i[oauth_flows store_oauth_flow_data example_resource_owner_id
|
101
|
+
example_resource_owner_given_name example_resource_owner_family_name
|
102
|
+
example_resource_owner_gender_type example_resource_owner_full_name
|
103
|
+
example_resource_owner_custom_gender].each do |method_name|
|
104
|
+
define_method method_name do |*args|
|
105
|
+
self.class.public_send method_name, *args
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
class << self
|
110
|
+
def oauth_flows
|
111
|
+
@oauth_flows ||= []
|
112
|
+
end
|
113
|
+
|
114
|
+
def reset
|
115
|
+
oauth_flows.clear
|
116
|
+
|
117
|
+
self.example_resource_owner_id = SecureRandom.uuid
|
118
|
+
self.example_resource_owner_given_name = 'Example Person'
|
119
|
+
self.example_resource_owner_family_name = 'From Artanis'
|
120
|
+
self.example_resource_owner_gender_type = 'male'
|
121
|
+
self.example_resource_owner_custom_gender = nil
|
122
|
+
end
|
123
|
+
|
124
|
+
def example_resource_owner_full_name
|
125
|
+
[example_resource_owner_given_name, example_resource_owner_family_name]
|
126
|
+
.compact.join(' ').strip
|
127
|
+
end
|
128
|
+
|
129
|
+
def store_oauth_flow_data(data)
|
130
|
+
oauth_flows << data
|
131
|
+
end
|
132
|
+
|
133
|
+
def url
|
134
|
+
"http://localhost:#{server_port}"
|
135
|
+
end
|
136
|
+
|
137
|
+
def sign_in_url
|
138
|
+
"#{url}/sign-in"
|
139
|
+
end
|
140
|
+
|
141
|
+
# Taken from FakeStripe.stub_stripe at fake_stripe gem:
|
142
|
+
def prepare
|
143
|
+
reset
|
144
|
+
|
145
|
+
yield self if block_given?
|
146
|
+
|
147
|
+
# Since the OAuth flow is performed by the browser, we'll need to boot
|
148
|
+
# the Sinatra app instead of just stubbing the app with WebMock...
|
149
|
+
boot_once
|
150
|
+
|
151
|
+
OmniAuth::Strategies::Icalia.instances.each do |strategy|
|
152
|
+
strategy.options.client_options.tap do |options|
|
153
|
+
options.site = url
|
154
|
+
options.token_url = "#{url}/oauth/token"
|
155
|
+
options.authorize_url = "#{url}/oauth/authorize"
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def sign_in_on_authorize
|
161
|
+
@@sign_in_user_on_authorize = true
|
162
|
+
end
|
163
|
+
|
164
|
+
def do_not_sign_in_on_authorize
|
165
|
+
@@sign_in_user_on_authorize = false
|
166
|
+
end
|
167
|
+
|
168
|
+
def teardown
|
169
|
+
default_client_options = OmniAuth::Strategies::Icalia
|
170
|
+
.default_options
|
171
|
+
.client_options
|
172
|
+
|
173
|
+
OmniAuth::Strategies::Icalia.instances.each do |strategy|
|
174
|
+
strategy.options.client_options.tap do |options|
|
175
|
+
options.site = default_client_options.site
|
176
|
+
options.token_url = default_client_options.token_url
|
177
|
+
options.authorize_url = default_client_options.authorize_url
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# Taken from FakeStripe::Utils at fake_stripe gem: =======================
|
183
|
+
def find_available_port
|
184
|
+
server = TCPServer.new(FIND_AVAILABLE_PORT)
|
185
|
+
server.addr[1]
|
186
|
+
ensure
|
187
|
+
server.close if server
|
188
|
+
end
|
189
|
+
|
190
|
+
# Taken from Bootable at fake_stripe gem: ================================
|
191
|
+
def boot(port = find_available_port)
|
192
|
+
instance = new
|
193
|
+
Capybara::Server.new(instance, port: port).tap(&:boot)
|
194
|
+
end
|
195
|
+
|
196
|
+
def boot_once
|
197
|
+
@boot_once ||= boot(server_port)
|
198
|
+
end
|
199
|
+
|
200
|
+
def server_port
|
201
|
+
@server_port ||= find_available_port
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'icalia/stubbed_sso_service'
|
@@ -12,6 +12,18 @@ module OmniAuth
|
|
12
12
|
authorize_url: 'https://artanis.icalialabs.com/oauth/authorize'
|
13
13
|
}
|
14
14
|
|
15
|
+
@@instances = []
|
16
|
+
|
17
|
+
def self.instances
|
18
|
+
class_variable_get('@@instances')
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(*args)
|
22
|
+
ret = super
|
23
|
+
@@instances << self
|
24
|
+
ret
|
25
|
+
end
|
26
|
+
|
15
27
|
def request_phase
|
16
28
|
super
|
17
29
|
end
|
@@ -29,7 +41,15 @@ module OmniAuth
|
|
29
41
|
uid { raw_info.resource_owner.id.to_s }
|
30
42
|
|
31
43
|
info do
|
32
|
-
|
44
|
+
personal_info = raw_info.resource_owner
|
45
|
+
{
|
46
|
+
'full_name' => personal_info.full_name,
|
47
|
+
'given_name' => personal_info.given_name,
|
48
|
+
'family_name' => personal_info.family_name,
|
49
|
+
'gender_type' => personal_info.gender_type,
|
50
|
+
'custom_gender' => personal_info.custom_gender,
|
51
|
+
'date_of_birth' => personal_info.date_of_birth
|
52
|
+
}
|
33
53
|
end
|
34
54
|
|
35
55
|
extra do
|
data/omniauth-icalia.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.license = 'MIT'
|
13
13
|
|
14
14
|
spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
15
|
-
spec.files = `git ls-files`.split("\n")
|
15
|
+
spec.files = `git ls-files -- lib/* *.md *.gemspec *.txt Rakefile`.split("\n")
|
16
16
|
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
17
|
spec.name = 'omniauth-icalia'
|
18
18
|
spec.require_paths = ['lib']
|
@@ -20,9 +20,11 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency 'omniauth', '~> 1.5'
|
22
22
|
spec.add_dependency 'omniauth-oauth2', '>= 1.4.0', '< 2.0'
|
23
|
-
spec.add_dependency 'icalia-sdk-event-core', '~> 0.3.3'
|
23
|
+
spec.add_dependency 'icalia-sdk-event-core', '~> 0.3', '>= 0.3.5'
|
24
24
|
|
25
25
|
spec.add_development_dependency 'bundler', '~> 1.17'
|
26
|
-
spec.add_development_dependency '
|
26
|
+
spec.add_development_dependency 'capybara', '~> 3.0', '>= 3.0.0'
|
27
|
+
spec.add_development_dependency 'sinatra', '~> 2.0', '>= 2.0.0'
|
28
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
27
29
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
28
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-icalia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Quintanilla
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth
|
@@ -50,14 +50,20 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.3
|
53
|
+
version: '0.3'
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.3.5
|
54
57
|
type: :runtime
|
55
58
|
prerelease: false
|
56
59
|
version_requirements: !ruby/object:Gem::Requirement
|
57
60
|
requirements:
|
58
61
|
- - "~>"
|
59
62
|
- !ruby/object:Gem::Version
|
60
|
-
version: 0.3
|
63
|
+
version: '0.3'
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.3.5
|
61
67
|
- !ruby/object:Gem::Dependency
|
62
68
|
name: bundler
|
63
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,20 +78,60 @@ dependencies:
|
|
72
78
|
- - "~>"
|
73
79
|
- !ruby/object:Gem::Version
|
74
80
|
version: '1.17'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: capybara
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 3.0.0
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '3.0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 3.0.0
|
98
|
+
- - "~>"
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '3.0'
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: sinatra
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: 2.0.0
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.0'
|
111
|
+
type: :development
|
112
|
+
prerelease: false
|
113
|
+
version_requirements: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 2.0.0
|
118
|
+
- - "~>"
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '2.0'
|
75
121
|
- !ruby/object:Gem::Dependency
|
76
122
|
name: rake
|
77
123
|
requirement: !ruby/object:Gem::Requirement
|
78
124
|
requirements:
|
79
125
|
- - "~>"
|
80
126
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
127
|
+
version: '13.0'
|
82
128
|
type: :development
|
83
129
|
prerelease: false
|
84
130
|
version_requirements: !ruby/object:Gem::Requirement
|
85
131
|
requirements:
|
86
132
|
- - "~>"
|
87
133
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
134
|
+
version: '13.0'
|
89
135
|
- !ruby/object:Gem::Dependency
|
90
136
|
name: rspec
|
91
137
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,31 +155,18 @@ executables:
|
|
109
155
|
extensions: []
|
110
156
|
extra_rdoc_files: []
|
111
157
|
files:
|
112
|
-
- ".dockerignore"
|
113
|
-
- ".gitignore"
|
114
|
-
- ".rspec"
|
115
|
-
- ".semaphore/bin/docker-image-manager"
|
116
|
-
- ".semaphore/bin/generate-dotenv-file"
|
117
|
-
- ".semaphore/publishing.yml"
|
118
|
-
- ".semaphore/semaphore.yml"
|
119
|
-
- ".travis.yml"
|
120
158
|
- CODE_OF_CONDUCT.md
|
121
|
-
- Dockerfile
|
122
|
-
- Gemfile
|
123
|
-
- Gemfile.lock
|
124
159
|
- LICENSE.txt
|
125
160
|
- README.md
|
126
161
|
- Rakefile
|
127
162
|
- bin/console
|
128
163
|
- bin/setup
|
129
|
-
-
|
130
|
-
- docker-compose.yml
|
164
|
+
- lib/icalia/stubbed_sso_service.rb
|
131
165
|
- lib/omniauth-icalia.rb
|
166
|
+
- lib/omniauth-icalia/service_stubs.rb
|
132
167
|
- lib/omniauth-icalia/version.rb
|
133
168
|
- lib/omniauth/strategies/icalia.rb
|
134
169
|
- omniauth-icalia.gemspec
|
135
|
-
- spec/omniauth/strategies/icalia_spec.rb
|
136
|
-
- spec/spec_helper.rb
|
137
170
|
homepage: https://github.com/IcaliaLabs/omniauth-icalia
|
138
171
|
licenses:
|
139
172
|
- MIT
|
@@ -153,11 +186,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
186
|
- !ruby/object:Gem::Version
|
154
187
|
version: '0'
|
155
188
|
requirements: []
|
156
|
-
|
157
|
-
rubygems_version: 2.7.6
|
189
|
+
rubygems_version: 3.0.3
|
158
190
|
signing_key:
|
159
191
|
specification_version: 4
|
160
192
|
summary: Official Omniauth Strategy for Icalia.
|
161
|
-
test_files:
|
162
|
-
- spec/omniauth/strategies/icalia_spec.rb
|
163
|
-
- spec/spec_helper.rb
|
193
|
+
test_files: []
|
data/.dockerignore
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
# Ignore docker and environment files:
|
2
|
-
*Dockerfile*
|
3
|
-
docker-compose*.yml
|
4
|
-
ci-compose.yml
|
5
|
-
**/*.env
|
6
|
-
.dockerignore
|
7
|
-
|
8
|
-
# Ignore Git repositories:
|
9
|
-
**/.git
|
10
|
-
|
11
|
-
# Ignore temporary files:
|
12
|
-
**/tmp/
|
13
|
-
|
14
|
-
# Ignore OS artifacts:
|
15
|
-
**/.DS_Store
|
16
|
-
|
17
|
-
# 3: Ignore Development container's Home artifacts:
|
18
|
-
# 3.1: Ignore bash / IRB / Byebug history files
|
19
|
-
.*_hist*
|
20
|
-
|
21
|
-
# 3.3: bundler stuff
|
22
|
-
.bundle/*
|
23
|
-
|
24
|
-
# 3.4: Codeclimate stuff:
|
25
|
-
.codeclimate.yml
|
26
|
-
.csslintrc
|
27
|
-
.eslintignore
|
28
|
-
.eslintrc
|
29
|
-
.rubocop.yml
|
30
|
-
coffeelint.json
|
31
|
-
|
32
|
-
# Ignore test coverage reports:
|
33
|
-
coverage/*
|
34
|
-
|
35
|
-
# Ignore auto-downloadable codeclimate plugin configuration files:
|
36
|
-
.rubocop.yml
|
37
|
-
.rubocop-rails.yml
|
38
|
-
.reek
|
39
|
-
.scss-lint.yml
|
40
|
-
|
41
|
-
examples.txt
|
42
|
-
|
43
|
-
**/.gem
|
44
|
-
/.semaphore
|
45
|
-
/tmp
|
data/.gitignore
DELETED
data/.rspec
DELETED
@@ -1,161 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
# Y yo pelándomela con bash...
|
5
|
-
|
6
|
-
def load_env
|
7
|
-
File.read('.env').each_line do |line|
|
8
|
-
variable_name, variable_value = line.match(/\A(\w+)=(\S*)/).captures
|
9
|
-
next if variable_name.nil?
|
10
|
-
ENV[variable_name] = variable_value
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def main_image
|
15
|
-
@main_image ||= @config.dig 'services', @service_name, 'image'
|
16
|
-
end
|
17
|
-
|
18
|
-
def image_repo
|
19
|
-
@image_repo ||= image_and_tag(main_image).first
|
20
|
-
end
|
21
|
-
|
22
|
-
def image_and_tag(image)
|
23
|
-
image.match(/\A(\S+):(\S*)\z/).captures
|
24
|
-
end
|
25
|
-
|
26
|
-
def pull(image)
|
27
|
-
system('docker', 'pull', image, out: $stdout, err: :out)
|
28
|
-
end
|
29
|
-
|
30
|
-
def pull_main_image
|
31
|
-
pull main_image
|
32
|
-
end
|
33
|
-
|
34
|
-
def sorted_cache_images
|
35
|
-
unsorted_images = @config
|
36
|
-
.dig('services', @service_name, 'build', 'cache_from')
|
37
|
-
.reject { |image| image == main_image }
|
38
|
-
.uniq
|
39
|
-
|
40
|
-
# With priority:
|
41
|
-
sorted_images = []
|
42
|
-
|
43
|
-
# 1: Testing of commit:
|
44
|
-
sorted_images << unsorted_images.detect do |image|
|
45
|
-
image == "#{image_repo}:testing-#{ENV['GIT_SHORT_SHA']}"
|
46
|
-
end
|
47
|
-
|
48
|
-
# 2: Builder of branch:
|
49
|
-
sorted_images << unsorted_images.detect do |image|
|
50
|
-
image == "#{image_repo}:builder-#{ENV['TAG_SAFE_BRANCH']}"
|
51
|
-
end
|
52
|
-
|
53
|
-
# 3: Testing of branch:
|
54
|
-
sorted_images << unsorted_images.detect do |image|
|
55
|
-
image == "#{image_repo}:testing-#{ENV['TAG_SAFE_BRANCH']}"
|
56
|
-
end
|
57
|
-
|
58
|
-
# 4: Builder of master branch:
|
59
|
-
sorted_images << unsorted_images.detect do |image|
|
60
|
-
image == "#{image_repo}:builder"
|
61
|
-
end
|
62
|
-
|
63
|
-
# 5: Testing of master branch:
|
64
|
-
sorted_images << unsorted_images.detect do |image|
|
65
|
-
image == "#{image_repo}:testing"
|
66
|
-
end
|
67
|
-
|
68
|
-
(sorted_images + (unsorted_images - sorted_images))
|
69
|
-
.reject { |image| "#{image}" == '' }
|
70
|
-
end
|
71
|
-
|
72
|
-
def pull_cache_images
|
73
|
-
repo_image_pulled = false
|
74
|
-
sorted_cache_images.each do |image|
|
75
|
-
is_repo_image = image.start_with?(image_repo)
|
76
|
-
next if is_repo_image && repo_image_pulled
|
77
|
-
repo_image_pulled = pull(image) && is_repo_image
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def push(image)
|
82
|
-
system 'docker', 'push', image, out: $stdout, err: :out
|
83
|
-
end
|
84
|
-
|
85
|
-
def tag(source_image, target_image)
|
86
|
-
system 'docker', 'tag', source_image, target_image, out: $stdout, err: :out
|
87
|
-
end
|
88
|
-
|
89
|
-
def tag_and_push_branch
|
90
|
-
branch_image = main_image
|
91
|
-
.gsub(ENV['GIT_SHORT_SHA'], ENV['TAG_SAFE_BRANCH'])
|
92
|
-
|
93
|
-
branch_image = branch_image[0..-8] if branch_image =~ /:(\w+)-master\z/
|
94
|
-
|
95
|
-
tag main_image, branch_image
|
96
|
-
push branch_image
|
97
|
-
end
|
98
|
-
|
99
|
-
def tag_and_push_latest
|
100
|
-
# We'll only tag 'testing', 'builder' or 'latest' if we're on master:
|
101
|
-
return unless ENV['TAG_SAFE_BRANCH'] == 'master'
|
102
|
-
|
103
|
-
latest_image = main_image.gsub(ENV['GIT_SHORT_SHA'], '')
|
104
|
-
|
105
|
-
if latest_image.end_with?('-')
|
106
|
-
# It's either a 'builder' or 'testing' tag:
|
107
|
-
latest_image = latest_image[0..-2]
|
108
|
-
elsif latest_image.end_with?(':')
|
109
|
-
# It's neither a 'builder' or 'testing' tag:
|
110
|
-
latest_image = "#{latest_image}latest"
|
111
|
-
end
|
112
|
-
|
113
|
-
tag main_image, latest_image
|
114
|
-
push latest_image
|
115
|
-
end
|
116
|
-
|
117
|
-
def push_images
|
118
|
-
push main_image
|
119
|
-
tag_and_push_branch
|
120
|
-
tag_and_push_latest
|
121
|
-
end
|
122
|
-
|
123
|
-
@command = ARGV[0]
|
124
|
-
unless %w[download-cache tag-and-push].include?(@command)
|
125
|
-
puts "Command '#{@command}' not recognized"
|
126
|
-
exit 1
|
127
|
-
end
|
128
|
-
|
129
|
-
@service_name = ARGV[1]
|
130
|
-
if "#{@service_name}" == ''
|
131
|
-
puts "No service name given"
|
132
|
-
exit 1
|
133
|
-
end
|
134
|
-
|
135
|
-
@config ||= begin
|
136
|
-
require 'yaml'
|
137
|
-
config_str = %x[docker-compose --file docker-compose.yml --file ci-compose.yml config]
|
138
|
-
YAML.load config_str
|
139
|
-
rescue
|
140
|
-
puts config_str
|
141
|
-
exit 1
|
142
|
-
end
|
143
|
-
|
144
|
-
if "#{@service_name}" == ''
|
145
|
-
puts "No service name given"
|
146
|
-
exit 1
|
147
|
-
end
|
148
|
-
|
149
|
-
if @config.dig('services', @service_name).nil?
|
150
|
-
puts "No service '#{@service_name}' exists in config"
|
151
|
-
exit 1
|
152
|
-
end
|
153
|
-
|
154
|
-
load_env
|
155
|
-
|
156
|
-
case @command
|
157
|
-
when 'download-cache'
|
158
|
-
pull_main_image || pull_cache_images
|
159
|
-
when 'tag-and-push'
|
160
|
-
push_images
|
161
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# Exit immediately if a command exits with a non-zero status:
|
4
|
-
set -e
|
5
|
-
|
6
|
-
CONTEXT_DIR=$(pwd)
|
7
|
-
|
8
|
-
GIT_SHORT_SHA=${SEMAPHORE_GIT_SHA:0:7}
|
9
|
-
BUILD_DATE=$(date +%Y-%m-%dT%H:%M:%S%z)
|
10
|
-
TAG_SAFE_BRANCH=$(echo ${SEMAPHORE_GIT_BRANCH} | tr '/' '-')
|
11
|
-
|
12
|
-
echo "BUILD_DATE=${BUILD_DATE}"
|
13
|
-
echo "GIT_SHA=${SEMAPHORE_GIT_SHA}"
|
14
|
-
echo "GIT_SHORT_SHA=${GIT_SHORT_SHA}"
|
15
|
-
echo "GIT_BRANCH=${SEMAPHORE_GIT_BRANCH}"
|
16
|
-
echo "TAG_SAFE_BRANCH=${TAG_SAFE_BRANCH}"
|
data/.semaphore/publishing.yml
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
version: v1.0
|
2
|
-
|
3
|
-
name: 'Publishing Pipeline'
|
4
|
-
|
5
|
-
agent:
|
6
|
-
machine:
|
7
|
-
type: e1-standard-2
|
8
|
-
os_image: ubuntu1804
|
9
|
-
|
10
|
-
blocks:
|
11
|
-
- name: Publish to Rubygems
|
12
|
-
task:
|
13
|
-
secrets:
|
14
|
-
- name: AWS
|
15
|
-
- name: ICALIA_RUBYGEMS
|
16
|
-
prologue:
|
17
|
-
commands:
|
18
|
-
- checkout
|
19
|
-
|
20
|
-
# Correct the permissions on rubygems credentials:
|
21
|
-
- chmod 0600 /home/semaphore/.gem/credentials
|
22
|
-
|
23
|
-
# Add the scripts for CI to the PATH:
|
24
|
-
- export PATH=$(pwd)/.semaphore/bin:${PATH}
|
25
|
-
|
26
|
-
# Generate the dotenv file:
|
27
|
-
- generate-dotenv-file > .env
|
28
|
-
|
29
|
-
# Alias docker-compose commands as 'ci-compose':
|
30
|
-
- alias ci-compose="docker-compose --file docker-compose.yml --file ci-compose.yml"
|
31
|
-
|
32
|
-
# Log in to AWS ECR:
|
33
|
-
- $(aws ecr get-login --no-include-email --region eu-central-1)
|
34
|
-
|
35
|
-
# Pull the images referenced in the 'cache_from' key:
|
36
|
-
- docker-image-manager download-cache libraries
|
37
|
-
|
38
|
-
jobs:
|
39
|
-
- name: Event Core
|
40
|
-
commands:
|
41
|
-
# Build & publish the gem
|
42
|
-
- ci-compose run event_core rake release
|
43
|
-
|
44
|
-
- name: Event Notification
|
45
|
-
commands:
|
46
|
-
# Build & publish the gem
|
47
|
-
- ci-compose run event_notification rake release
|
48
|
-
|
49
|
-
- name: Event Webhook
|
50
|
-
commands:
|
51
|
-
# Build & publish the gem
|
52
|
-
- ci-compose run event_webhook rake release
|
53
|
-
|
54
|
-
- name: Event Meta
|
55
|
-
commands:
|
56
|
-
# Build & publish the gem
|
57
|
-
- ci-compose run event_meta rake release
|
58
|
-
|
59
|
-
- name: SDK Meta
|
60
|
-
commands:
|
61
|
-
# Build & publish the gem
|
62
|
-
- ci-compose run sdk_meta rake release
|
data/.semaphore/semaphore.yml
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
version: v1.0
|
2
|
-
|
3
|
-
name: 'Main Pipeline'
|
4
|
-
|
5
|
-
agent:
|
6
|
-
machine:
|
7
|
-
type: e1-standard-2
|
8
|
-
os_image: ubuntu1804
|
9
|
-
|
10
|
-
blocks:
|
11
|
-
- name: Build Test Image
|
12
|
-
task:
|
13
|
-
secrets:
|
14
|
-
- name: AWS
|
15
|
-
prologue:
|
16
|
-
commands:
|
17
|
-
- checkout
|
18
|
-
|
19
|
-
# Add the scripts for CI to the PATH:
|
20
|
-
- export PATH=$(pwd)/.semaphore/bin:${PATH}
|
21
|
-
|
22
|
-
# Generate the dotenv file:
|
23
|
-
- generate-dotenv-file > .env
|
24
|
-
|
25
|
-
# Alias docker-compose commands as 'ci-compose':
|
26
|
-
- alias ci-compose="docker-compose --file docker-compose.yml --file ci-compose.yml"
|
27
|
-
|
28
|
-
# Log in to AWS ECR:
|
29
|
-
- $(aws ecr get-login --no-include-email --region eu-central-1)
|
30
|
-
jobs:
|
31
|
-
- name: Build
|
32
|
-
commands:
|
33
|
-
# Pull the images referenced in the 'cache_from' key:
|
34
|
-
- docker-image-manager download-cache libraries
|
35
|
-
|
36
|
-
# Build the test image:
|
37
|
-
- ci-compose build --pull libraries
|
38
|
-
|
39
|
-
# Tag & Push test image so we can use it on image cache:
|
40
|
-
- docker-image-manager tag-and-push libraries
|
41
|
-
|
42
|
-
- name: SDK Tests
|
43
|
-
task:
|
44
|
-
secrets:
|
45
|
-
- name: AWS
|
46
|
-
prologue:
|
47
|
-
commands:
|
48
|
-
- checkout
|
49
|
-
|
50
|
-
# Add the scripts for CI to the PATH:
|
51
|
-
- export PATH=$(pwd)/.semaphore/bin:${PATH}
|
52
|
-
|
53
|
-
# Generate the dotenv file:
|
54
|
-
- generate-dotenv-file > .env
|
55
|
-
|
56
|
-
# Alias docker-compose commands as 'ci-compose':
|
57
|
-
- alias ci-compose="docker-compose --file docker-compose.yml --file ci-compose.yml"
|
58
|
-
|
59
|
-
# Log in to AWS ECR:
|
60
|
-
- $(aws ecr get-login --no-include-email --region eu-central-1)
|
61
|
-
|
62
|
-
# Pull the images referenced in the 'cache_from' key:
|
63
|
-
- docker-image-manager download-cache libraries
|
64
|
-
jobs:
|
65
|
-
- name: Event Core
|
66
|
-
commands:
|
67
|
-
# Run the tests
|
68
|
-
- ci-compose run event_core rake spec
|
69
|
-
|
70
|
-
# Build the gem
|
71
|
-
- ci-compose run event_core gem build icalia-sdk-event-core
|
72
|
-
|
73
|
-
- name: Event Notification
|
74
|
-
commands:
|
75
|
-
# Run the tests
|
76
|
-
- ci-compose run event_notification rake spec
|
77
|
-
|
78
|
-
# Build the gem
|
79
|
-
- ci-compose run event_notification gem build icalia-sdk-event-notification
|
80
|
-
|
81
|
-
- name: Event Webhook
|
82
|
-
commands:
|
83
|
-
# Run the tests
|
84
|
-
- ci-compose run event_webhook rake spec
|
85
|
-
|
86
|
-
# Build the gem
|
87
|
-
- ci-compose run event_webhook gem build icalia-sdk-event-webhook
|
88
|
-
|
89
|
-
- name: Event Meta
|
90
|
-
commands:
|
91
|
-
# Run the tests
|
92
|
-
- ci-compose run event_meta rake spec
|
93
|
-
|
94
|
-
# Build the gem
|
95
|
-
- ci-compose run event_meta gem build icalia-sdk-event
|
96
|
-
|
97
|
-
- name: SDK Meta
|
98
|
-
commands:
|
99
|
-
# Run the tests
|
100
|
-
- ci-compose run sdk_meta rake spec
|
101
|
-
|
102
|
-
# Build the gem
|
103
|
-
- ci-compose run sdk_meta gem build icalia-sdk
|
104
|
-
|
105
|
-
promotions:
|
106
|
-
- name: Publish
|
107
|
-
pipeline_file: publishing.yml
|
108
|
-
auto_promote_on:
|
109
|
-
- result: passed
|
110
|
-
branch:
|
111
|
-
- ^refs\/tags\/v(\d+)\.(\d+)\.(\d+)(\.rc\d+)?$
|
data/.travis.yml
DELETED
data/Dockerfile
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
FROM ruby:2.6.5-buster AS development
|
2
|
-
|
3
|
-
WORKDIR /usr/src
|
4
|
-
|
5
|
-
ENV HOME=/usr/src PATH=/usr/src/bin:$PATH
|
6
|
-
|
7
|
-
COPY Gemfile Gemfile.lock omniauth-icalia.gemspec /usr/src/
|
8
|
-
COPY lib/omniauth-icalia/version.rb /usr/src/lib/omniauth-icalia/
|
9
|
-
|
10
|
-
RUN bundle install --jobs=4 --retry=3
|
11
|
-
|
12
|
-
ARG DEVELOPER_UID=1000
|
13
|
-
|
14
|
-
ARG DEVELOPER_USERNAME=you
|
15
|
-
|
16
|
-
ENV DEVELOPER_UID=${DEVELOPER_UID}
|
17
|
-
|
18
|
-
RUN useradd -r -M -u ${DEVELOPER_UID} -d /usr/src -c "Developer User,,," ${DEVELOPER_USERNAME}
|
19
|
-
|
20
|
-
FROM development AS testing
|
21
|
-
|
22
|
-
COPY . /usr/src/
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
omniauth-icalia (0.1.0)
|
5
|
-
icalia-sdk-event-core (>= 0.3.3)
|
6
|
-
omniauth (~> 1.5)
|
7
|
-
omniauth-oauth2 (>= 1.4.0, < 2.0)
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: https://rubygems.org/
|
11
|
-
specs:
|
12
|
-
activemodel (6.0.2.1)
|
13
|
-
activesupport (= 6.0.2.1)
|
14
|
-
activesupport (6.0.2.1)
|
15
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
|
-
i18n (>= 0.7, < 2)
|
17
|
-
minitest (~> 5.1)
|
18
|
-
tzinfo (~> 1.1)
|
19
|
-
zeitwerk (~> 2.2)
|
20
|
-
byebug (11.1.1)
|
21
|
-
coderay (1.1.2)
|
22
|
-
concurrent-ruby (1.1.6)
|
23
|
-
diff-lcs (1.3)
|
24
|
-
faraday (1.0.0)
|
25
|
-
multipart-post (>= 1.2, < 3)
|
26
|
-
hashie (3.6.0)
|
27
|
-
i18n (1.8.2)
|
28
|
-
concurrent-ruby (~> 1.0)
|
29
|
-
icalia-sdk-event-core (0.3.3)
|
30
|
-
activemodel (>= 5.0)
|
31
|
-
jsonapi-deserializable (~> 0.2.0)
|
32
|
-
jsonapi-deserializable (0.2.0)
|
33
|
-
jwt (2.2.1)
|
34
|
-
method_source (0.9.2)
|
35
|
-
minitest (5.14.0)
|
36
|
-
multi_json (1.14.1)
|
37
|
-
multi_xml (0.6.0)
|
38
|
-
multipart-post (2.1.1)
|
39
|
-
oauth2 (1.4.3)
|
40
|
-
faraday (>= 0.8, < 2.0)
|
41
|
-
jwt (>= 1.0, < 3.0)
|
42
|
-
multi_json (~> 1.3)
|
43
|
-
multi_xml (~> 0.5)
|
44
|
-
rack (>= 1.2, < 3)
|
45
|
-
omniauth (1.9.0)
|
46
|
-
hashie (>= 3.4.6, < 3.7.0)
|
47
|
-
rack (>= 1.6.2, < 3)
|
48
|
-
omniauth-oauth2 (1.6.0)
|
49
|
-
oauth2 (~> 1.1)
|
50
|
-
omniauth (~> 1.9)
|
51
|
-
pry (0.12.2)
|
52
|
-
coderay (~> 1.1.0)
|
53
|
-
method_source (~> 0.9.0)
|
54
|
-
rack (2.2.2)
|
55
|
-
rake (10.5.0)
|
56
|
-
rspec (3.9.0)
|
57
|
-
rspec-core (~> 3.9.0)
|
58
|
-
rspec-expectations (~> 3.9.0)
|
59
|
-
rspec-mocks (~> 3.9.0)
|
60
|
-
rspec-core (3.9.1)
|
61
|
-
rspec-support (~> 3.9.1)
|
62
|
-
rspec-expectations (3.9.0)
|
63
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
64
|
-
rspec-support (~> 3.9.0)
|
65
|
-
rspec-mocks (3.9.1)
|
66
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
-
rspec-support (~> 3.9.0)
|
68
|
-
rspec-support (3.9.2)
|
69
|
-
thread_safe (0.3.6)
|
70
|
-
tzinfo (1.2.6)
|
71
|
-
thread_safe (~> 0.1)
|
72
|
-
zeitwerk (2.2.2)
|
73
|
-
|
74
|
-
PLATFORMS
|
75
|
-
ruby
|
76
|
-
|
77
|
-
DEPENDENCIES
|
78
|
-
bundler (~> 1.17)
|
79
|
-
byebug (~> 11.1, >= 11.1)
|
80
|
-
omniauth-icalia!
|
81
|
-
pry (~> 0.12.2)
|
82
|
-
rake (~> 10.0)
|
83
|
-
rspec (~> 3.0)
|
84
|
-
|
85
|
-
BUNDLED WITH
|
86
|
-
1.17.2
|
data/ci-compose.yml
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# We'll use the '3.x spec since it supports the 'cache_from'
|
2
|
-
# option:
|
3
|
-
version: '3.7'
|
4
|
-
|
5
|
-
services:
|
6
|
-
libraries: &library
|
7
|
-
image: 564922552600.dkr.ecr.eu-central-1.amazonaws.com/icalia-sdk-ruby:testing-${GIT_SHORT_SHA:-latest}
|
8
|
-
build:
|
9
|
-
target: testing
|
10
|
-
context: .
|
11
|
-
cache_from:
|
12
|
-
# Since docker-compose will try to build the unused (at this time) runtime
|
13
|
-
# stage, and this project's dev stages and runtime stages start from
|
14
|
-
# different images, we need to include the releaseable image here as well
|
15
|
-
# - this may change with Docker 19.x:
|
16
|
-
- 564922552600.dkr.ecr.eu-central-1.amazonaws.com/icalia-sdk-ruby:testing-${GIT_SHORT_SHA:-latest}
|
17
|
-
- 564922552600.dkr.ecr.eu-central-1.amazonaws.com/icalia-sdk-ruby:testing-${TAG_SAFE_BRANCH}
|
18
|
-
- 564922552600.dkr.ecr.eu-central-1.amazonaws.com/icalia-sdk-ruby:testing
|
19
|
-
command: bundle exec rake spec
|
20
|
-
volumes:
|
21
|
-
- ${HOME}/.gem/credentials:/root/.gem/credentials
|
22
|
-
|
23
|
-
event_core:
|
24
|
-
<<: *library
|
25
|
-
working_dir: /usr/src/gems/icalia-sdk-event-core
|
26
|
-
|
27
|
-
event_notification:
|
28
|
-
<<: *library
|
29
|
-
working_dir: /usr/src/gems/icalia-sdk-event-notification
|
30
|
-
|
31
|
-
event_webhook:
|
32
|
-
<<: *library
|
33
|
-
working_dir: /usr/src/gems/icalia-sdk-event-webhook
|
34
|
-
|
35
|
-
event_meta:
|
36
|
-
<<: *library
|
37
|
-
working_dir: /usr/src/gems/icalia-sdk-event
|
38
|
-
|
39
|
-
sdk_meta:
|
40
|
-
<<: *library
|
41
|
-
working_dir: /usr/src/gems/icalia-sdk
|
data/docker-compose.yml
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
version: '3.7'
|
2
|
-
|
3
|
-
volumes:
|
4
|
-
lib_gem_bundle:
|
5
|
-
|
6
|
-
services:
|
7
|
-
lib:
|
8
|
-
image: icalialabs/omniauth-icalia:development
|
9
|
-
build:
|
10
|
-
context: .
|
11
|
-
target: development
|
12
|
-
args:
|
13
|
-
DEVELOPER_UID: ${UID:-1000}
|
14
|
-
DEVELOPER_USERNAME: ${USER:-you}
|
15
|
-
command: bundle console
|
16
|
-
volumes:
|
17
|
-
- .:/usr/src
|
18
|
-
- lib_gem_bundle:/usr/local/bundle
|
19
|
-
environment:
|
20
|
-
BUNDLE_CONSOLE: pry
|
@@ -1,109 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe OmniAuth::Strategies::Icalia do
|
4
|
-
let(:access_token) { instance_double('AccessToken', :options => {}, :[] => 'user') }
|
5
|
-
let(:parsed_response) { instance_double('ParsedResponse') }
|
6
|
-
let(:response) { instance_double('Response', :parsed => parsed_response) }
|
7
|
-
|
8
|
-
let(:example_overridden_site) { 'https://example.com' }
|
9
|
-
let(:example_overridden_token_url) { 'https://example.com/oauth/token' }
|
10
|
-
let(:example_overridden_authorize_url) { 'https://example.com/oauth/authorize' }
|
11
|
-
|
12
|
-
let(:example_options) { {} }
|
13
|
-
|
14
|
-
subject do
|
15
|
-
OmniAuth::Strategies::Icalia.new 'ICALIA_CLIENT_KEY',
|
16
|
-
'ICALIA_CLIENT_SECRET',
|
17
|
-
example_options
|
18
|
-
end
|
19
|
-
|
20
|
-
before :each do
|
21
|
-
allow(subject).to receive(:access_token).and_return(access_token)
|
22
|
-
end
|
23
|
-
|
24
|
-
describe 'client options' do
|
25
|
-
context 'defaults' do
|
26
|
-
it 'site is artanis' do
|
27
|
-
expect(subject.options.client_options.site).to eq 'https://artanis.icalialabs.com'
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'authorize url is artanis authorize url' do
|
31
|
-
expect(subject.options.client_options.authorize_url).to eq 'https://artanis.icalialabs.com/oauth/authorize'
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'token url is artanis token url' do
|
35
|
-
expect(subject.options.client_options.token_url).to eq 'https://artanis.icalialabs.com/oauth/token'
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'overrides' do
|
40
|
-
let :example_options do
|
41
|
-
{
|
42
|
-
client_options: {
|
43
|
-
site: example_overridden_site,
|
44
|
-
token_url: example_overridden_token_url,
|
45
|
-
authorize_url: example_overridden_authorize_url,
|
46
|
-
}
|
47
|
-
}
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'allows overriding the site' do
|
51
|
-
expect(subject.options.client_options.site)
|
52
|
-
.to eq example_overridden_site
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'allows overriding the authorize url' do
|
56
|
-
expect(subject.options.client_options.authorize_url)
|
57
|
-
.to eq example_overridden_authorize_url
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'allows overriding the token url' do
|
61
|
-
expect(subject.options.client_options.token_url)
|
62
|
-
.to eq example_overridden_token_url
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe '#raw_info' do
|
68
|
-
it 'should use relative paths' do
|
69
|
-
expect(access_token).to receive(:get).with('/oauth/token/info?include=resource-owner.email-accounts').and_return(response)
|
70
|
-
expect(subject.raw_info).to eq(parsed_response)
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'should use the header auth mode' do
|
74
|
-
expect(access_token).to receive(:get).with('user').and_return(response)
|
75
|
-
subject.raw_info
|
76
|
-
expect(access_token.options[:mode]).to eq(:header)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe '#info.email' do
|
81
|
-
it 'should use any available email' do
|
82
|
-
allow(subject).to receive(:raw_info).and_return({})
|
83
|
-
allow(subject).to receive(:email).and_return('you@example.com')
|
84
|
-
expect(subject.info['email']).to eq('you@example.com')
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
context '#info.urls' do
|
89
|
-
it 'should use html_url from raw_info' do
|
90
|
-
allow(subject).to receive(:raw_info).and_return({ 'login' => 'me', 'html_url' => 'http://enterprise/me' })
|
91
|
-
expect(subject.info['urls']['icalia']).to eq('http://enterprise/me')
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
context '#extra.scope' do
|
96
|
-
it 'returns the scope on the returned access_token' do
|
97
|
-
expect(subject.scope).to eq('user')
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
describe '#callback_url' do
|
102
|
-
it 'is a combination of host, script name, and callback path' do
|
103
|
-
allow(subject).to receive(:full_host).and_return('https://example.com')
|
104
|
-
allow(subject).to receive(:script_name).and_return('/sub_uri')
|
105
|
-
|
106
|
-
expect(subject.callback_url).to eq('https://example.com/sub_uri/auth/icalia/callback')
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'bundler/setup'
|
2
|
-
require 'omniauth-icalia'
|
3
|
-
|
4
|
-
RSpec.configure do |config|
|
5
|
-
# Enable flags like --only-failures and --next-failure
|
6
|
-
config.example_status_persistence_file_path = 'examples.txt'
|
7
|
-
|
8
|
-
# Disable RSpec exposing methods globally on `Module` and `main`
|
9
|
-
config.disable_monkey_patching!
|
10
|
-
|
11
|
-
config.expect_with :rspec do |c|
|
12
|
-
c.syntax = :expect
|
13
|
-
end
|
14
|
-
end
|