omniauth-visma 0.0.3 → 0.0.4
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/lib/omniauth/strategies/visma.rb +17 -15
- data/lib/omniauth-visma/version.rb +2 -3
- data/spec/omniauth/strategies/visma_spec.rb +25 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad14691ae656580b454323786b143049a4bcabc5aa7a5712e191e63f8e54d05d
|
4
|
+
data.tar.gz: cd1e500ae5c9cffdee787310b91951943989908d42a86df64a7966c28ab32651
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2705bcdde3b8902f02541b626a4c64793c5820ad95383a309ee77daaec3df5c0f3fcdac05ccb33b14b27fb4dd48d071a69221161cf39d3d4a25d3d3a368f5ff7
|
7
|
+
data.tar.gz: e90621cbcf3ec84dbd6e480f77aec72d19c490d5d221ae7a484b20106896ee649c88de5c25df588e12a3175484c643cb45889db49724241bb93d681eec79aea8
|
@@ -6,20 +6,24 @@ module OmniAuth
|
|
6
6
|
class Visma < OmniAuth::Strategies::OAuth2
|
7
7
|
AUTH_URLS = {
|
8
8
|
:sandbox => {
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
9
|
+
site: "https://eaccountingapi-sandbox.test.vismaonline.com/v2/",
|
10
|
+
authorize_url: "https://identity-sandbox.test.vismaonline.com/connect/authorize",
|
11
|
+
token_url: "https://identity-sandbox.test.vismaonline.com/connect/token"
|
12
12
|
},
|
13
13
|
:production => {
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
14
|
+
site: "https://eaccountingapi.vismaonline.com/v2/",
|
15
|
+
authorize_url: "https://identity.vismaonline.com/connect/authorize",
|
16
|
+
token_url: "https://identity.vismaonline.com/connect/token"
|
17
17
|
}
|
18
18
|
}
|
19
|
-
|
20
19
|
option :name, "visma"
|
21
|
-
option :environment, :production
|
22
20
|
option :client_options, AUTH_URLS[:production]
|
21
|
+
option :environment, :production
|
22
|
+
|
23
|
+
def initialize(*args)
|
24
|
+
super(*args)
|
25
|
+
update_default_environment_urls
|
26
|
+
end
|
23
27
|
|
24
28
|
info do
|
25
29
|
{
|
@@ -46,15 +50,13 @@ module OmniAuth
|
|
46
50
|
@raw_info ||= access_token.get('/v2/companysettings').parsed
|
47
51
|
end
|
48
52
|
|
49
|
-
def request_phase
|
50
|
-
set_urls
|
51
|
-
super
|
52
|
-
end
|
53
|
-
|
54
53
|
private
|
55
54
|
|
56
|
-
def
|
57
|
-
|
55
|
+
def update_default_environment_urls
|
56
|
+
case options.environment
|
57
|
+
when :sandbox
|
58
|
+
options.client_options = options.client_options.merge( AUTH_URLS[options.environment] )
|
59
|
+
end
|
58
60
|
end
|
59
61
|
|
60
62
|
def callback_url
|
@@ -12,16 +12,17 @@ describe OmniAuth::Strategies::Visma do
|
|
12
12
|
|
13
13
|
describe '#client' do
|
14
14
|
it 'should have the correct Visma site' do
|
15
|
-
subject.client.site.should eq("https://eaccountingapi
|
15
|
+
subject.client.site.should eq("https://eaccountingapi.vismaonline.com/v2/")
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'should have the correct authorization url' do
|
19
|
-
subject.client.options[:authorize_url].should eq("https://identity
|
19
|
+
subject.client.options[:authorize_url].should eq("https://identity.vismaonline.com/connect/authorize")
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'should have the correct token url' do
|
23
|
-
subject.client.options[:token_url].should eq('https://identity
|
23
|
+
subject.client.options[:token_url].should eq('https://identity.vismaonline.com/connect/token')
|
24
24
|
end
|
25
|
+
|
25
26
|
end
|
26
27
|
|
27
28
|
describe '#callback_path' do
|
@@ -29,4 +30,25 @@ describe OmniAuth::Strategies::Visma do
|
|
29
30
|
subject.callback_path.should eq('/auth/visma/callback')
|
30
31
|
end
|
31
32
|
end
|
33
|
+
|
34
|
+
describe '#environment' do
|
35
|
+
|
36
|
+
subject do
|
37
|
+
strategy = OmniAuth::Strategies::Visma.new(nil, @options || {})
|
38
|
+
strategy.stub(:session) { {} }
|
39
|
+
strategy
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should use production environment by default' do
|
43
|
+
subject.client.authorize_url.should eq("https://identity.vismaonline.com/connect/authorize")
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should set environment' do
|
47
|
+
@options = {:environment => :sandbox}
|
48
|
+
subject.options.environment.should eq(:sandbox)
|
49
|
+
subject.client.authorize_url.should eq("https://identity-sandbox.test.vismaonline.com/connect/authorize")
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
32
54
|
end
|