-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SHD-160] Add tempo id provider (#6)
Add tempo id provider
- Loading branch information
Showing
3 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
|
||
require "omniauth/nitro_id/version" | ||
require "omniauth/strategies/nitro_id" | ||
require "omniauth/strategies/tempo_id" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
require "omniauth_openid_connect" | ||
|
||
module OmniAuth | ||
module Strategies | ||
class TempoId < OmniAuth::Strategies::OpenIDConnect | ||
DEFAULT_STRATEGY_NAME = "tempo_id" | ||
DEFAULT_ISSUER = "https://id.streamfinancial.io/" | ||
DEFAULT_HOST = "id.streamfinancial.io" | ||
|
||
option :name, DEFAULT_STRATEGY_NAME | ||
option :discovery, true | ||
option :issuer, DEFAULT_ISSUER | ||
option :client_options, host: DEFAULT_HOST | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
describe OmniAuth::Strategies::TempoId do | ||
let(:access_token) { instance_double("AccessToken", :options => {}, :[] => "user") } | ||
let(:custom_client) do | ||
OmniAuth::Strategies::TempoId.new(:test_app, | ||
issuer: "https://example-host.com/", | ||
discovery: false, | ||
client_options: { | ||
host: "example-host.com", | ||
}) | ||
end | ||
|
||
subject do | ||
OmniAuth::Strategies::TempoId.new({}) | ||
end | ||
|
||
before(:each) do | ||
allow(subject).to receive(:access_token).and_return(access_token) | ||
end | ||
|
||
context "options" do | ||
it "should have correct name" do | ||
expect(subject.options.name).to eq "tempo_id" | ||
end | ||
|
||
it "should have correct host" do | ||
expect(subject.options.client_options.host).to eq "id.streamfinancial.io" | ||
end | ||
|
||
it "should have correct issuer" do | ||
expect(subject.options.issuer).to eq "https://id.streamfinancial.io/" | ||
end | ||
|
||
it "should have the correct discovery setting" do | ||
expect(subject.options.discovery).to eq true | ||
end | ||
|
||
describe "should be overrideable" do | ||
it "for host" do | ||
expect(custom_client.options.client_options.host).to eq "example-host.com" | ||
end | ||
|
||
it "for issuer" do | ||
expect(custom_client.options.issuer).to eq "https://example-host.com/" | ||
end | ||
|
||
it "for discovery" do | ||
expect(custom_client.options.discovery).to eq false | ||
end | ||
end | ||
end | ||
end |