-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* フォルダの配置の修正 * Settingsクラスの作成 * 設定値を読み込む機能の実装 * 不要なrequire削除 Co-authored-by: yonetani <[email protected]>
- Loading branch information
Showing
18 changed files
with
248 additions
and
81 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
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
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
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
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,26 @@ | ||
require 'rails/generators' | ||
|
||
module SpRailsSaml | ||
class ConfigGenerator < Rails::Generators::Base | ||
|
||
desc "config/initializersにイニシャライザファイルを作成します" | ||
|
||
def create_initializer_file | ||
create_file "config/initializers/sp-rails-saml.rb", default_initializer | ||
end | ||
|
||
private | ||
|
||
def default_initializer | ||
<<-EOS | ||
SpRailsSaml::Settings.setup do |config| | ||
config.sp_entity_id = '' | ||
config.name_identifier_format = 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress' | ||
config.authn_context = 'urn:oasis:names:tc:SAML:2.0:ac:classes:X509' | ||
config.authn_context_comparison = 'exact' | ||
config.assertion_consumer_service_url = '' | ||
end | ||
EOS | ||
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,6 @@ | ||
require 'sp-rails-saml/settings' | ||
require 'generators/sp-rails-saml/config_generator' | ||
|
||
module SpRailsSaml | ||
class Error < StandardError; 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,18 @@ | ||
module SpRailsSaml | ||
class Settings | ||
class << self | ||
attr_accessor :sp_entity_id | ||
attr_accessor :name_identifier_format | ||
attr_accessor :authn_context | ||
attr_accessor :authn_context_comparison | ||
attr_accessor :assertion_consumer_service_url | ||
|
||
def setup(options = {}) | ||
options.each do |key, value| | ||
instance_variable_set("@#{key}", value) | ||
end | ||
yield(self) if block_given? | ||
end | ||
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,3 @@ | ||
module SpRailsSaml | ||
VERSION = "0.1.0" | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
require_relative 'lib/sp/rails/saml/version' | ||
$LOAD_PATH.push File.expand_path('../lib', __FILE__) | ||
require 'sp-rails-saml/version' | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "sp-rails-saml" | ||
spec.version = Sp::Rails::Saml::VERSION | ||
spec.version = SpRailsSaml::VERSION | ||
spec.authors = ["psyashes"] | ||
spec.email = ["[email protected]"] | ||
|
||
|
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,24 @@ | ||
RSpec.describe SpRailsSaml::ConfigGenerator, type: :generator do | ||
destination File.expand_path("../../../../tmp", __FILE__) | ||
|
||
before(:all) do | ||
prepare_destination | ||
run_generator | ||
end | ||
|
||
let(:initializer_text) do | ||
<<-EOS | ||
SpRailsSaml::Settings.setup do |config| | ||
config.sp_entity_id = '' | ||
config.name_identifier_format = 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress' | ||
config.authn_context = 'urn:oasis:names:tc:SAML:2.0:ac:classes:X509' | ||
config.authn_context_comparison = 'exact' | ||
config.assertion_consumer_service_url = '' | ||
end | ||
EOS | ||
end | ||
|
||
it "should create saml_settings initializer file" do | ||
assert_file "config/initializers/sp-rails-saml.rb", initializer_text | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,5 @@ | ||
RSpec.describe SpRailsSaml do | ||
it "has a version number" do | ||
expect(SpRailsSaml::VERSION).not_to be nil | ||
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,25 @@ | ||
RSpec.describe SpRailsSaml::Settings do | ||
describe '#setup' do | ||
let(:sp_entity_id) { 'sp_entity_id' } | ||
let(:name_identifier_format) { 'name_identifier_format' } | ||
let(:authn_context) { 'authn_context' } | ||
let(:authn_context_comparison) { 'authn_context_comparison' } | ||
let(:assertion_consumer_service_url) { 'assertion_consumer_service_url' } | ||
|
||
it 'should set settings value' do | ||
SpRailsSaml::Settings.setup do |config| | ||
config.sp_entity_id = sp_entity_id | ||
config.name_identifier_format = name_identifier_format | ||
config.authn_context = authn_context | ||
config.authn_context_comparison = authn_context_comparison | ||
config.assertion_consumer_service_url = assertion_consumer_service_url | ||
end | ||
|
||
expect(SpRailsSaml::Settings.sp_entity_id).to eq sp_entity_id | ||
expect(SpRailsSaml::Settings.name_identifier_format).to eq name_identifier_format | ||
expect(SpRailsSaml::Settings.authn_context).to eq authn_context | ||
expect(SpRailsSaml::Settings.authn_context_comparison).to eq authn_context_comparison | ||
expect(SpRailsSaml::Settings.assertion_consumer_service_url).to eq assertion_consumer_service_url | ||
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