From caea0de29b1a6593dcd1ccd97e0dbdb30af33140 Mon Sep 17 00:00:00 2001 From: yonetani Date: Fri, 7 May 2021 17:39:39 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=AB=E3=83=80?= =?UTF-8?q?=E3=81=AE=E9=85=8D=E7=BD=AE=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- bin/console | 2 +- lib/sp/rails/saml.rb | 11 ----------- lib/sp/rails/saml/hello.rb | 11 ----------- lib/sp/rails/saml/version.rb | 7 ------- lib/sp_rails_saml.rb | 5 +++++ lib/sp_rails_saml/version.rb | 3 +++ sp-rails-saml.gemspec | 4 ++-- spec/sp/rails/saml_spec.rb | 9 --------- spec/sp_rails_saml/saml_spec.rb | 5 +++++ spec/spec_helper.rb | 2 +- 11 files changed, 19 insertions(+), 44 deletions(-) delete mode 100644 lib/sp/rails/saml.rb delete mode 100644 lib/sp/rails/saml/hello.rb delete mode 100644 lib/sp/rails/saml/version.rb create mode 100644 lib/sp_rails_saml.rb create mode 100644 lib/sp_rails_saml/version.rb delete mode 100644 spec/sp/rails/saml_spec.rb create mode 100644 spec/sp_rails_saml/saml_spec.rb diff --git a/README.md b/README.md index 5e4fd8b..7a72843 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Sp::Rails::Saml +# SpRailsSaml -Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sp/rails/saml`. To experiment with that code, run `bin/console` for an interactive prompt. +Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sp_rails_saml`. To experiment with that code, run `bin/console` for an interactive prompt. TODO: Delete this and the text above, and describe your gem diff --git a/bin/console b/bin/console index 2404810..acb178c 100755 --- a/bin/console +++ b/bin/console @@ -1,7 +1,7 @@ #!/usr/bin/env ruby require "bundler/setup" -require "sp/rails/saml" +require "sp_rails_saml" # You can add fixtures and/or initialization code here to make experimenting # with your gem easier. You can also use a different console, if you like. diff --git a/lib/sp/rails/saml.rb b/lib/sp/rails/saml.rb deleted file mode 100644 index 8ee2181..0000000 --- a/lib/sp/rails/saml.rb +++ /dev/null @@ -1,11 +0,0 @@ -require "sp/rails/saml/version" -require "sp/rails/saml/hello" - -module Sp - module Rails - module Saml - class Error < StandardError; end - # Your code goes here... - end - end -end diff --git a/lib/sp/rails/saml/hello.rb b/lib/sp/rails/saml/hello.rb deleted file mode 100644 index fc9a5c6..0000000 --- a/lib/sp/rails/saml/hello.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Sp - module Rails - module Saml - class Greet - def self.say(word) - word + ', hello.' - end - end - end - end -end diff --git a/lib/sp/rails/saml/version.rb b/lib/sp/rails/saml/version.rb deleted file mode 100644 index a9e0716..0000000 --- a/lib/sp/rails/saml/version.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Sp - module Rails - module Saml - VERSION = "0.1.0" - end - end -end diff --git a/lib/sp_rails_saml.rb b/lib/sp_rails_saml.rb new file mode 100644 index 0000000..4924872 --- /dev/null +++ b/lib/sp_rails_saml.rb @@ -0,0 +1,5 @@ +require "sp_rails_saml/version" + +module SpRailsSaml + class Error < StandardError; end +end diff --git a/lib/sp_rails_saml/version.rb b/lib/sp_rails_saml/version.rb new file mode 100644 index 0000000..def9cb1 --- /dev/null +++ b/lib/sp_rails_saml/version.rb @@ -0,0 +1,3 @@ +module SpRailsSaml + VERSION = "0.1.0" +end diff --git a/sp-rails-saml.gemspec b/sp-rails-saml.gemspec index 4cb297b..4792b70 100644 --- a/sp-rails-saml.gemspec +++ b/sp-rails-saml.gemspec @@ -1,8 +1,8 @@ -require_relative 'lib/sp/rails/saml/version' +require_relative 'lib/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 = ["43512814+psyashes@users.noreply.github.com"] diff --git a/spec/sp/rails/saml_spec.rb b/spec/sp/rails/saml_spec.rb deleted file mode 100644 index 38bef1a..0000000 --- a/spec/sp/rails/saml_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -RSpec.describe Sp::Rails::Saml do - it "has a version number" do - expect(Sp::Rails::Saml::VERSION).not_to be nil - end - - it "return greeting message" do - expect(Sp::Rails::Saml::Greet.say("Eren")).to eq("Eren, hello.") - end -end diff --git a/spec/sp_rails_saml/saml_spec.rb b/spec/sp_rails_saml/saml_spec.rb new file mode 100644 index 0000000..8beaa44 --- /dev/null +++ b/spec/sp_rails_saml/saml_spec.rb @@ -0,0 +1,5 @@ +RSpec.describe SpRailsSaml do + it "has a version number" do + expect(SpRailsSaml::VERSION).not_to be nil + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 020d227..2122666 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,5 @@ require "bundler/setup" -require "sp/rails/saml" +require "sp_rails_saml" RSpec.configure do |config| # Enable flags like --only-failures and --next-failure From 3cd9642b1ae362dc0052c2ddde36954aa50a1c6a Mon Sep 17 00:00:00 2001 From: yonetani Date: Fri, 7 May 2021 17:50:52 +0900 Subject: [PATCH 2/4] =?UTF-8?q?Settings=E3=82=AF=E3=83=A9=E3=82=B9?= =?UTF-8?q?=E3=81=AE=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 2 +- lib/sp_rails_saml.rb | 1 + lib/sp_rails_saml/settings.rb | 21 ++++++++++++++++ spec/setting_spec.rb | 37 ----------------------------- spec/sp_rails_saml/settings_spec.rb | 34 ++++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 38 deletions(-) create mode 100644 lib/sp_rails_saml/settings.rb delete mode 100644 spec/setting_spec.rb create mode 100644 spec/sp_rails_saml/settings_spec.rb diff --git a/Gemfile b/Gemfile index 14a57d8..c84311c 100644 --- a/Gemfile +++ b/Gemfile @@ -4,4 +4,4 @@ source "https://rubygems.org" gemspec gem "rake", "~> 12.0" -gem "rspec", "~> 3.0" +gem "rspec", "~> 3.0" \ No newline at end of file diff --git a/lib/sp_rails_saml.rb b/lib/sp_rails_saml.rb index 4924872..8b067df 100644 --- a/lib/sp_rails_saml.rb +++ b/lib/sp_rails_saml.rb @@ -1,4 +1,5 @@ require "sp_rails_saml/version" +require 'sp_rails_saml/settings' module SpRailsSaml class Error < StandardError; end diff --git a/lib/sp_rails_saml/settings.rb b/lib/sp_rails_saml/settings.rb new file mode 100644 index 0000000..73a0b8b --- /dev/null +++ b/lib/sp_rails_saml/settings.rb @@ -0,0 +1,21 @@ +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 :idp_sso_service_url + attr_accessor :assertion_consumer_service_url + attr_accessor :idp_cert + attr_accessor :idp_entity_id + + def setup(options = {}) + options.each do |key, value| + instance_variable_set("@#{key}", value) + end + yield(self) if block_given? + end + end + end +end \ No newline at end of file diff --git a/spec/setting_spec.rb b/spec/setting_spec.rb deleted file mode 100644 index 6c8f66b..0000000 --- a/spec/setting_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -RSpec.describe SpRailsSaml::Setting 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(:idp_sso_service_url) { 'idp_sso_service_url' } - let(:assertion_consumer_service_url) { 'assertion_consumer_service_url' } - let(:idp_cert) { 'idp_cert' } - let(:idp_entity_id) { 'idp_entity_id' } - let(:assertion_consumer_service_url) { 'assertion_consumer_service_url' } - - it 'should set settings value' do - SpRailsSaml::Setting.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.idp_sso_service_url = idp_sso_service_url - config.assertion_consumer_service_url = assertion_consumer_service_url - config.idp_cert = idp_cert - config.idp_entity_id = idp_entity_id - config.assertion_consumer_service_url = assertion_consumer_service_url - end - - expect(SpRailsSaml::Setting.sp_entity_id).to eq sp_entity_id - expect(SpRailsSaml::Setting.name_identifier_format).to eq name_identifier_format - expect(SpRailsSaml::Setting.authn_context).to eq authn_context - expect(SpRailsSaml::Setting.authn_context_comparison).to eq authn_context_comparison - expect(SpRailsSaml::Setting.idp_sso_service_url).to eq idp_sso_service_url - expect(SpRailsSaml::Setting.assertion_consumer_service_url).to eq assertion_consumer_service_url - expect(SpRailsSaml::Setting.idp_cert).to eq idp_cert - expect(SpRailsSaml::Setting.idp_entity_id).to eq idp_entity_id - expect(SpRailsSaml::Setting.assertion_consumer_service_url).to eq assertion_consumer_service_url - end - end -end diff --git a/spec/sp_rails_saml/settings_spec.rb b/spec/sp_rails_saml/settings_spec.rb new file mode 100644 index 0000000..f791f80 --- /dev/null +++ b/spec/sp_rails_saml/settings_spec.rb @@ -0,0 +1,34 @@ +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(:idp_sso_service_url) { 'idp_sso_service_url' } + let(:assertion_consumer_service_url) { 'assertion_consumer_service_url' } + let(:idp_cert) { 'idp_cert' } + let(:idp_entity_id) { 'idp_entity_id' } + + 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.idp_sso_service_url = idp_sso_service_url + config.assertion_consumer_service_url = assertion_consumer_service_url + config.idp_cert = idp_cert + config.idp_entity_id = idp_entity_id + 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.idp_sso_service_url).to eq idp_sso_service_url + expect(SpRailsSaml::Settings.assertion_consumer_service_url).to eq assertion_consumer_service_url + expect(SpRailsSaml::Settings.idp_cert).to eq idp_cert + expect(SpRailsSaml::Settings.idp_entity_id).to eq idp_entity_id + end + end +end From a17ce0e363b173660189a01a86f7cf389a619240 Mon Sep 17 00:00:00 2001 From: yonetani Date: Mon, 10 May 2021 14:25:00 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E5=80=A4=E3=82=92?= =?UTF-8?q?=E8=AA=AD=E3=81=BF=E8=BE=BC=E3=82=80=E6=A9=9F=E8=83=BD=E3=81=AE?= =?UTF-8?q?=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 7 +- Gemfile.lock | 128 ++++++++++++++++++ README.md | 2 +- bin/console | 2 +- .../sp-rails-saml/config_generator.rb | 26 ++++ lib/sp-rails-saml.rb | 7 + .../settings.rb | 3 - .../version.rb | 0 lib/sp_rails_saml.rb | 6 - sp-rails-saml.gemspec | 3 +- .../sp_rails_saml/settings_generator_spec.rb | 24 ++++ spec/sp_rails_saml/settings_spec.rb | 9 -- spec/spec_helper.rb | 3 +- 13 files changed, 197 insertions(+), 23 deletions(-) create mode 100644 lib/generators/sp-rails-saml/config_generator.rb create mode 100644 lib/sp-rails-saml.rb rename lib/{sp_rails_saml => sp-rails-saml}/settings.rb (81%) rename lib/{sp_rails_saml => sp-rails-saml}/version.rb (100%) delete mode 100644 lib/sp_rails_saml.rb create mode 100644 spec/generators/sp_rails_saml/settings_generator_spec.rb diff --git a/Gemfile b/Gemfile index c84311c..248e3e6 100644 --- a/Gemfile +++ b/Gemfile @@ -4,4 +4,9 @@ source "https://rubygems.org" gemspec gem "rake", "~> 12.0" -gem "rspec", "~> 3.0" \ No newline at end of file +gem "rspec", "~> 3.0" + +group :test do + gem "rails", "~> 6.1.0" + gem "generator_spec" +end \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 01551d1..ed625a1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,7 +6,119 @@ PATH GEM remote: https://rubygems.org/ specs: + actioncable (6.1.3.2) + actionpack (= 6.1.3.2) + activesupport (= 6.1.3.2) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (6.1.3.2) + actionpack (= 6.1.3.2) + activejob (= 6.1.3.2) + activerecord (= 6.1.3.2) + activestorage (= 6.1.3.2) + activesupport (= 6.1.3.2) + mail (>= 2.7.1) + actionmailer (6.1.3.2) + actionpack (= 6.1.3.2) + actionview (= 6.1.3.2) + activejob (= 6.1.3.2) + activesupport (= 6.1.3.2) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (6.1.3.2) + actionview (= 6.1.3.2) + activesupport (= 6.1.3.2) + rack (~> 2.0, >= 2.0.9) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.1.3.2) + actionpack (= 6.1.3.2) + activerecord (= 6.1.3.2) + activestorage (= 6.1.3.2) + activesupport (= 6.1.3.2) + nokogiri (>= 1.8.5) + actionview (6.1.3.2) + activesupport (= 6.1.3.2) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (6.1.3.2) + activesupport (= 6.1.3.2) + globalid (>= 0.3.6) + activemodel (6.1.3.2) + activesupport (= 6.1.3.2) + activerecord (6.1.3.2) + activemodel (= 6.1.3.2) + activesupport (= 6.1.3.2) + activestorage (6.1.3.2) + actionpack (= 6.1.3.2) + activejob (= 6.1.3.2) + activerecord (= 6.1.3.2) + activesupport (= 6.1.3.2) + marcel (~> 1.0.0) + mini_mime (~> 1.0.2) + activesupport (6.1.3.2) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + builder (3.2.4) + concurrent-ruby (1.1.8) + crass (1.0.6) diff-lcs (1.4.4) + erubi (1.10.0) + generator_spec (0.9.4) + activesupport (>= 3.0.0) + railties (>= 3.0.0) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.10) + concurrent-ruby (~> 1.0) + loofah (2.9.1) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (1.0.1) + method_source (1.0.0) + mini_mime (1.0.3) + minitest (5.14.4) + nio4r (2.5.7) + nokogiri (1.11.3-x86_64-darwin) + racc (~> 1.4) + racc (1.5.2) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (6.1.3.2) + actioncable (= 6.1.3.2) + actionmailbox (= 6.1.3.2) + actionmailer (= 6.1.3.2) + actionpack (= 6.1.3.2) + actiontext (= 6.1.3.2) + actionview (= 6.1.3.2) + activejob (= 6.1.3.2) + activemodel (= 6.1.3.2) + activerecord (= 6.1.3.2) + activestorage (= 6.1.3.2) + activesupport (= 6.1.3.2) + bundler (>= 1.15.0) + railties (= 6.1.3.2) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (6.1.3.2) + actionpack (= 6.1.3.2) + activesupport (= 6.1.3.2) + method_source + rake (>= 0.8.7) + thor (~> 1.0) rake (12.3.3) rspec (3.10.0) rspec-core (~> 3.10.0) @@ -21,11 +133,27 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-support (3.10.2) + sprockets (4.0.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.2) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + thor (1.1.0) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + websocket-driver (0.7.3) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.4.2) PLATFORMS ruby DEPENDENCIES + generator_spec + rails (~> 6.1.0) rake (~> 12.0) rspec (~> 3.0) sp-rails-saml! diff --git a/README.md b/README.md index 7a72843..722211c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # SpRailsSaml -Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sp_rails_saml`. To experiment with that code, run `bin/console` for an interactive prompt. +Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sp-rails-saml`. To experiment with that code, run `bin/console` for an interactive prompt. TODO: Delete this and the text above, and describe your gem diff --git a/bin/console b/bin/console index acb178c..016ca06 100755 --- a/bin/console +++ b/bin/console @@ -1,7 +1,7 @@ #!/usr/bin/env ruby require "bundler/setup" -require "sp_rails_saml" +require "sp-rails-saml" # You can add fixtures and/or initialization code here to make experimenting # with your gem easier. You can also use a different console, if you like. diff --git a/lib/generators/sp-rails-saml/config_generator.rb b/lib/generators/sp-rails-saml/config_generator.rb new file mode 100644 index 0000000..a155358 --- /dev/null +++ b/lib/generators/sp-rails-saml/config_generator.rb @@ -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 diff --git a/lib/sp-rails-saml.rb b/lib/sp-rails-saml.rb new file mode 100644 index 0000000..00d65e5 --- /dev/null +++ b/lib/sp-rails-saml.rb @@ -0,0 +1,7 @@ +require "active_support" +require 'sp-rails-saml/settings' +require 'generators/sp-rails-saml/config_generator' + +module SpRailsSaml + class Error < StandardError; end +end diff --git a/lib/sp_rails_saml/settings.rb b/lib/sp-rails-saml/settings.rb similarity index 81% rename from lib/sp_rails_saml/settings.rb rename to lib/sp-rails-saml/settings.rb index 73a0b8b..9a683b0 100644 --- a/lib/sp_rails_saml/settings.rb +++ b/lib/sp-rails-saml/settings.rb @@ -5,10 +5,7 @@ class << self attr_accessor :name_identifier_format attr_accessor :authn_context attr_accessor :authn_context_comparison - attr_accessor :idp_sso_service_url attr_accessor :assertion_consumer_service_url - attr_accessor :idp_cert - attr_accessor :idp_entity_id def setup(options = {}) options.each do |key, value| diff --git a/lib/sp_rails_saml/version.rb b/lib/sp-rails-saml/version.rb similarity index 100% rename from lib/sp_rails_saml/version.rb rename to lib/sp-rails-saml/version.rb diff --git a/lib/sp_rails_saml.rb b/lib/sp_rails_saml.rb deleted file mode 100644 index 8b067df..0000000 --- a/lib/sp_rails_saml.rb +++ /dev/null @@ -1,6 +0,0 @@ -require "sp_rails_saml/version" -require 'sp_rails_saml/settings' - -module SpRailsSaml - class Error < StandardError; end -end diff --git a/sp-rails-saml.gemspec b/sp-rails-saml.gemspec index 4792b70..edbb750 100644 --- a/sp-rails-saml.gemspec +++ b/sp-rails-saml.gemspec @@ -1,4 +1,5 @@ -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" diff --git a/spec/generators/sp_rails_saml/settings_generator_spec.rb b/spec/generators/sp_rails_saml/settings_generator_spec.rb new file mode 100644 index 0000000..5ea90fe --- /dev/null +++ b/spec/generators/sp_rails_saml/settings_generator_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/sp_rails_saml/settings_spec.rb b/spec/sp_rails_saml/settings_spec.rb index f791f80..8b15890 100644 --- a/spec/sp_rails_saml/settings_spec.rb +++ b/spec/sp_rails_saml/settings_spec.rb @@ -4,10 +4,7 @@ let(:name_identifier_format) { 'name_identifier_format' } let(:authn_context) { 'authn_context' } let(:authn_context_comparison) { 'authn_context_comparison' } - let(:idp_sso_service_url) { 'idp_sso_service_url' } let(:assertion_consumer_service_url) { 'assertion_consumer_service_url' } - let(:idp_cert) { 'idp_cert' } - let(:idp_entity_id) { 'idp_entity_id' } it 'should set settings value' do SpRailsSaml::Settings.setup do |config| @@ -15,20 +12,14 @@ config.name_identifier_format = name_identifier_format config.authn_context = authn_context config.authn_context_comparison = authn_context_comparison - config.idp_sso_service_url = idp_sso_service_url config.assertion_consumer_service_url = assertion_consumer_service_url - config.idp_cert = idp_cert - config.idp_entity_id = idp_entity_id 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.idp_sso_service_url).to eq idp_sso_service_url expect(SpRailsSaml::Settings.assertion_consumer_service_url).to eq assertion_consumer_service_url - expect(SpRailsSaml::Settings.idp_cert).to eq idp_cert - expect(SpRailsSaml::Settings.idp_entity_id).to eq idp_entity_id end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2122666..14d5d2d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,6 @@ require "bundler/setup" -require "sp_rails_saml" +require "sp-rails-saml" +require "generator_spec" RSpec.configure do |config| # Enable flags like --only-failures and --next-failure From afeb6e583b20456313a45830b9f08347d42dcea1 Mon Sep 17 00:00:00 2001 From: yonetani Date: Mon, 10 May 2021 15:55:03 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AArequire=E5=89=8A?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/sp-rails-saml.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/sp-rails-saml.rb b/lib/sp-rails-saml.rb index 00d65e5..d20d50a 100644 --- a/lib/sp-rails-saml.rb +++ b/lib/sp-rails-saml.rb @@ -1,4 +1,3 @@ -require "active_support" require 'sp-rails-saml/settings' require 'generators/sp-rails-saml/config_generator'