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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 477afd3499aa92780ec4bd963663f94d0a856786090d97847d61b8d3dd3292d0
4
- data.tar.gz: 54789a09b77956aa697fff347c09a0a9cdda39886daaf2c7aa0d8a76a37ae40d
3
+ metadata.gz: ad14691ae656580b454323786b143049a4bcabc5aa7a5712e191e63f8e54d05d
4
+ data.tar.gz: cd1e500ae5c9cffdee787310b91951943989908d42a86df64a7966c28ab32651
5
5
  SHA512:
6
- metadata.gz: c2305700f15a743ffd9ceb076cdc77fdd6f520171a716657474ab8ee0834e354a2666aeb627f783c7bc3bc5edf7af84d9d9707c7d3cb762f1b14d6dbfa492980
7
- data.tar.gz: e60145dfb1922c2b0a3c4a5426db6a60ff238ecea72f8835f0d0a369dc40ba7bd742424fa9f1470abaaf6be4f87ebb776c0149d8929809ccf68db19ac41a67a4
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
- :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"
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
- :site => "https://eaccountingapi.vismaonline.com/v2/",
15
- :authorize_url => "https://identity.vismaonline.com/connect/authorize",
16
- :token_url => "https://identity.vismaonline.com/connect/token"
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 set_urls
57
- options.client_options = AUTH_URLS[options.environment].merge(options.client_options)
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
@@ -1,6 +1,5 @@
1
1
  module OmniAuth
2
2
  module Visma
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
- end
6
-
5
+ end
@@ -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-sandbox.test.vismaonline.com/v2/")
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-sandbox.test.vismaonline.com/connect/authorize")
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-sandbox.test.vismaonline.com/connect/token')
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-visma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Espen Antonsen