diff --git a/.travis.yml b/.travis.yml index 5b778c3..6396aa2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,10 +34,9 @@ after_success: - test -z "$DEPLOY_DOCS" || git push origin source env: global: - - STORMPATH_APPLICATION_URL=https://api.stormpath.com/v1/applications/4xz3y2Hrid4aqp5YwbNTvk - - secure: VMjIMI42vIPTMPTr0fnzSPiIjzuSAnT7iNWjhAXP9WsdaCmxwHp1vOlry4QuX8DzpKHv2MQubeUN/UA227Nk1xn+CVu9mujWOqvvjmL9m20wMJvwT4ctn7zG+FJK76id9TEyx0mCTlH4ZrRoDMGfM9yzhpsg8FtSebBDdHxePaM= - - secure: IhR6H9qxmxCDNbLK0ebYuIXQRsGA/JhD6In4V/hnSMJ8lPi2kwRn6eKclNCHGNjcy6QF1V5vddKIfKOkFFZvIyP26reygTX1g5Mfa8SqTGKh3DAW4WP+T+yaE4z4UBDK1zZpbV0Zbkw/HC0xeD8UPnjRzERX1LVZp1qeEjhQrks= - - secure: MWBpUnXAj1nkPXOy17IOOY/HwQ7nsEtaNRzvbwNt2Nvr8vtsClcLlu3dXF3suex9k1ZG1c0SuNQdUOQmiOUvobUOPa2PgKcjzRcw8NhIuKxZAZLNKqtNIWsDzlf5zDuUIUkCVewGtsjUZJLIRi/1XZLFsbjZYvEdc/ZPM5LoPo8= + - STORMPATH_APPLICATION_HREF=https://api.stormpath.com/v1/applications/4xz3y2Hrid4aqp5YwbNTvk + - secure: fuZU/DCNpezx1qrhpt/b+eeZRF83AiAwJnUNgA0D2fH4KGleN+BGfz5wEy6oOu5QKDWWAWepHDuwUjTP6QL504QId8+QZbycr52tFM0NXDSzpzhGkoaAEIALjuJ+DBto032yr8hoFjM+P5M1057p2jZKyr5CMkB66j4g3oWwA5k= + - secure: F0+m4wWKgqZLWpouKwn3BQB1/DXkbwmKEE6E+XFSEJB3rIsf8J4stP6OslqGmkdOzbx/4Dl/V3EXMmWk6R8hnQ5rmr60FGN6FBXUTA+s/9ZULl1I3+J/PsV5azFUwuP+87hbS9QQTVxbG7S3Gpmuy3JCSjySQ4vfXo8fZPz6Plk= matrix: include: - env: BUILD_DOCS=true diff --git a/Gemfile b/Gemfile index f7c25da..3f9e423 100644 --- a/Gemfile +++ b/Gemfile @@ -18,8 +18,6 @@ group :test do gem 'webmock' gem 'vcr', '3.0.1' gem 'ammeter', git: 'https://github.com/alexrothenberg/ammeter' - gem 'simplecov', require: false - gem 'coveralls', require: false gem 'json_matchers' gem 'match_json', '0.0.5' gem 'capybara' diff --git a/README.md b/README.md index afa28ec..96eead1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ [![Build Status](https://travis-ci.org/stormpath/stormpath-rails.svg?branch=master)](https://travis-ci.org/stormpath/stormpath-rails) -[![Coverage Status](https://coveralls.io/repos/stormpath/stormpath-rails/badge.svg?branch=master&service=github)](https://coveralls.io/github/stormpath/stormpath-rails?branch=master) [![Code Climate](https://codeclimate.com/github/stormpath/stormpath-rails/badges/gpa.svg)](https://codeclimate.com/github/stormpath/stormpath-rails) # Stormpath Rails @@ -38,16 +37,16 @@ rails generate stormpath:install Create a Stormpath account if you haven't already, and be sure to set up the following environment variables: - - STORMPATH_API_KEY_ID - - STORMPATH_API_KEY_SECRET + - STORMPATH_CLIENT_APIKEY_ID + - STORMPATH_CLIENT_APIKEY_SECRET Environment variables should be set up in you .bashrc file (or .zshrc if you use myzsh). Example setup: ```sh -export STORMPATH_API_KEY_ID=6U4HZMHGVHN0U765BGW -export STORMPATH_API_KEY_SECRET=0e0TuVZKYiPiLTDLNnswEwpPpa5nPv +export STORMPATH_CLIENT_APIKEY_ID=6U4HZMHGVHN0U765BGW +export STORMPATH_CLIENT_APIKEY_SECRET=0e0TuVZKYiPiLTDLNnswEwpPpa5nPv ``` Alternatively you can use gems such as [Dotenv](https://github.com/bkeepers/dotenv) or [Figaro](https://github.com/laserlemon/figaro) to preload environment variables. @@ -91,7 +90,7 @@ You can use embedded ruby (ERB) in the configuration file: ```yaml stormpath: application: - href: <%= ENV['STORMPATH_APPLICATION_URL'] %> + href: <%= ENV['STORMPATH_APPLICATION_HREF'] %> ``` ## Usage @@ -298,12 +297,9 @@ If you wish to contribute to the gem, please follow these steps: 1. Create a Stormpath Application. 2. Export the following env variables: - - STORMPATH_API_KEY_ID - - STORMPATH_API_KEY_SECRET + - STORMPATH_CLIENT_APIKEY_ID + - STORMPATH_CLIENT_APIKEY_SECRET 3. Create a Directory and associate it to the app. Make it the default account and group store for the app. -4. Create a Directory With a Verification Workflow and associate it to the app. -5. Export the following env variable: - - STORMPATH_SDK_TEST_DIRECTORY_WITH_VERIFICATION_URL ### Specs diff --git a/app/services/stormpath/rails/token_cookie_setter.rb b/app/services/stormpath/rails/token_cookie_setter.rb index 7e11676..fdf8294 100644 --- a/app/services/stormpath/rails/token_cookie_setter.rb +++ b/app/services/stormpath/rails/token_cookie_setter.rb @@ -58,7 +58,7 @@ def cookie_data end def expires - Time.zone.at(JWT.decode(token, ENV['STORMPATH_API_KEY_SECRET']).first['exp']) + Time.zone.at(JWT.decode(token, Stormpath::Rails::Client.client.data_store.api_key.secret).first['exp']) end def http_only diff --git a/docs/configuration.rst b/docs/configuration.rst index a09c0fd..c792c0e 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -23,9 +23,9 @@ by running the following commands in the shell: .. code-block:: bash - export STORMPATH_API_KEY_ID=YOUR_ID_HERE - export STORMPATH_API_KEY_SECRET=YOUR_SECRET_HERE - export STORMPATH_APPLICATION_URL=YOUR_APP_HREF + export STORMPATH_CLIENT_APIKEY_ID=YOUR_ID_HERE + export STORMPATH_CLIENT_APIKEY_SECRET=YOUR_SECRET_HERE + export STORMPATH_APPLICATION_HREF=YOUR_APP_HREF or by using any text editor and adding the environment variables to .bashrc (or .zshrc if you're using ohmyzsh) @@ -35,9 +35,9 @@ or by using any text editor and adding the environment variables to .bashrc (or .. code-block:: bash - set STORMPATH_API_KEY_ID=YOUR_ID_HERE - set STORMPATH_API_KEY_SECRET=YOUR_SECRET_HERE - set STORMPATH_APPLICATION_URL=YOUR_APP_HREF + set STORMPATH_CLIENT_APIKEY_ID=YOUR_ID_HERE + set STORMPATH_CLIENT_APIKEY_SECRET=YOUR_SECRET_HERE + set STORMPATH_APPLICATION_HREF=YOUR_APP_HREF The examples above show you the 3 mandatory settings you need to configure to make stormpath-rails work. These settings can be configured via environment diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 6c6c4b8..cb9bfdf 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -30,8 +30,8 @@ prompt you to download your key pair. Once you've downloaded your `apiKey.properties` file, save it and be sure to set up the following environment variables: - - STORMPATH_API_KEY_ID - - STORMPATH_API_KEY_SECRET + - STORMPATH_CLIENT_APIKEY_ID + - STORMPATH_CLIENT_APIKEY_SECRET Environment variables should be set up in you .bashrc file (or .zshrc if you use myzsh). @@ -39,8 +39,8 @@ Example setup: .. code-block:: sh - export STORMPATH_API_KEY_ID=6U4HZMHGVHN0U765BGW - export STORMPATH_API_KEY_SECRET=0e0TuVZKYiPiLTDLNnswEwpPpa5nPv + export STORMPATH_CLIENT_APIKEY_ID=6U4HZMHGVHN0U765BGW + export STORMPATH_CLIENT_APIKEY_SECRET=0e0TuVZKYiPiLTDLNnswEwpPpa5nPv Find Your Stormpath Application ------------------------------- @@ -73,7 +73,7 @@ Now that you have your application HREF, make sure to set up another environment .. code-block:: sh - export STORMPATH_APPLICATION_URL=https://api.stormpath.com/v1/applications/24kkU5XOz4tQlZ7sBtPUN6 + export STORMPATH_APPLICATION_HREF=https://api.stormpath.com/v1/applications/24kkU5XOz4tQlZ7sBtPUN6 You're ready to bundle Stormpath Rails gem into your project! diff --git a/lib/stormpath/rails.rb b/lib/stormpath/rails.rb index 54d4fc1..67041a5 100644 --- a/lib/stormpath/rails.rb +++ b/lib/stormpath/rails.rb @@ -15,6 +15,7 @@ module Rails autoload :Controller, 'stormpath/rails/controller' autoload :Version, 'stormpath/rails/version' autoload :Social, 'stormpath/rails/social' + autoload :ApiKey, 'stormpath/rails/api_key' autoload :ContentTypeNegotiator, 'stormpath/rails/content_type_negotiator' autoload :RoutingConstraint, 'stormpath/rails/routing_constraint' autoload :InvalidSptokenError, 'stormpath/rails/errors/invalid_sptoken_error' @@ -23,5 +24,6 @@ module Rails autoload :NoGithubAuthorizationError, 'stormpath/rails/errors/no_github_authorization_error' autoload :FacebookAuthCodeExchange, 'stormpath/rails/facebook_auth_code_exchange' autoload :GithubAuthCodeExchange, 'stormpath/rails/github_auth_code_exchange' + autoload :EnvNamesWarning, 'stormpath/rails/env_names_warning' end end diff --git a/lib/stormpath/rails/api_key.rb b/lib/stormpath/rails/api_key.rb new file mode 100644 index 0000000..e4c3e18 --- /dev/null +++ b/lib/stormpath/rails/api_key.rb @@ -0,0 +1,87 @@ +module Stormpath + module Rails + class ApiKey + TEST_ENV_VARS = { + required: { + STORMPATH_CLIENT_APIKEY_ID: 'The id from your Stormpath API Key', + STORMPATH_CLIENT_APIKEY_SECRET: 'The secret from your Stormpath API Key', + STORMPATH_APPLICATION_HREF: 'The href to your application' + }, + deprecated: { + STORMPATH_API_KEY_ID: 'The id from your Stormpath API Key', + STORMPATH_API_KEY_SECRET: 'The secret from your Stormpath API Key', + STORMPATH_APPLICATION_URL: 'The url to your application' + } + }.freeze + + def credentials + check_env_variable_names + credentials_from_env_variables + end + + private + + def check_env_variable_names + unless test_missing_required_env_vars.empty? + show_deprecation_warning unless env_vars_not_set? + end + + raise set_up_message if env_vars_not_set? + end + + def credentials_from_env_variables + { + id: ENV['STORMPATH_CLIENT_APIKEY_ID'] || ENV['STORMPATH_API_KEY_ID'], + secret: ENV['STORMPATH_CLIENT_APIKEY_SECRET'] || ENV['STORMPATH_API_KEY_SECRET'] + } + end + + def test_missing_deprecated_env_vars + TEST_ENV_VARS[:deprecated].reject do |var, _| + ENV[var.to_s] + end + end + + def test_missing_required_env_vars + TEST_ENV_VARS[:required].reject do |var, _| + ENV[var.to_s] + end + end + + def env_vars_not_set? + !test_missing_deprecated_env_vars.empty? && !test_missing_required_env_vars.empty? + end + + def show_deprecation_warning + warn deprecation_warning + end + + def deprecation_warning + warn_message = "\n\n" + 40.times { warn_message << '*' } + warn_message << 'STORMPATH RAILS' + 52.times { warn_message << '*' } + warn_message << "\n\n" + warn_message << TEST_ENV_VARS[:deprecated].map do |var, _| + "\t#{var} is deprecated since the new version of the gem." + end.join("\n") + warn_message << "\n\tPlease update your environment variables to use the new names:\n" + warn_message << "\n\t\texport STORMPATH_CLIENT_APIKEY_ID=your_api_key_id" + warn_message << "\n\t\texport STORMPATH_CLIENT_APIKEY_SECRET=your_api_key_secret" + warn_message << "\n\t\texport STORMPATH_APPLICATION_HREF=href_to_application\n\n" + 110.times { warn_message << '*' } + warn_message << "\n\n" + warn_message + end + + def set_up_message + set_up_message = "In order to use the stormpath-rails gem you need to set the following environment variables:\n\t" + set_up_message << test_missing_required_env_vars.map do |var, message| + "#{var} : #{message}" + end.join("\n\t") + set_up_message << "\nBe sure to configure these before trying to run your application.\n\n" + set_up_message + end + end + end +end diff --git a/lib/stormpath/rails/client.rb b/lib/stormpath/rails/client.rb index 42c332f..bbf569a 100644 --- a/lib/stormpath/rails/client.rb +++ b/lib/stormpath/rails/client.rb @@ -24,12 +24,11 @@ def self.application end def self.client - self.connection ||= Stormpath::Client.new( - api_key: { - id: ENV['STORMPATH_API_KEY_ID'], - secret: ENV['STORMPATH_API_KEY_SECRET'] - } - ) + self.connection ||= Stormpath::Client.new(api_key: api_key.credentials) + end + + def self.api_key + Stormpath::Rails::ApiKey.new end end end diff --git a/lib/stormpath/rails/env_names_warning.rb b/lib/stormpath/rails/env_names_warning.rb new file mode 100644 index 0000000..7813460 --- /dev/null +++ b/lib/stormpath/rails/env_names_warning.rb @@ -0,0 +1,62 @@ +module Stormpath + module Rails + module EnvNamesWarning + TEST_ENV_VARS = { + required: { + STORMPATH_CLIENT_APIKEY_ID: 'The id from your Stormpath API Key', + STORMPATH_CLIENT_APIKEY_SECRET: 'The secret from your Stormpath API Key', + STORMPATH_APPLICATION_HREF: 'The href to your application' + }, + deprecated: { + STORMPATH_API_KEY_ID: 'The id from your Stormpath API Key', + STORMPATH_API_KEY_SECRET: 'The secret from your Stormpath API Key', + STORMPATH_APPLICATION_URL: 'The url to your application' + } + }.freeze + + def self.test_missing_deprecated_env_vars + TEST_ENV_VARS[:deprecated].reject do |var, _| + ENV[var.to_s] + end + end + + def self.test_missing_required_env_vars + TEST_ENV_VARS[:required].reject do |var, _| + ENV[var.to_s] + end + end + + def self.env_vars_not_set? + !test_missing_deprecated_env_vars.empty? && !test_missing_required_env_vars.empty? + end + + def self.check_env_variable_names + unless Stormpath::Rails::EnvNamesWarning.test_missing_required_env_vars.empty? + warn_message = "\n\n" + 40.times { warn_message << '*' } + warn_message << 'STORMPATH RAILS' + 52.times { warn_message << '*' } + warn_message << "\n\n" + warn_message << TEST_ENV_VARS[:deprecated].map do |var, _| + "\t#{var} is deprecated since the new version of the gem." + end.join("\n") + warn_message << "\n\tPlease update your environment variables to use the new names:\n" + warn_message << "\n\t\texport STORMPATH_CLIENT_APIKEY_ID=your_api_key_id" + warn_message << "\n\t\texport STORMPATH_CLIENT_APIKEY_SECRET=your_api_key_secret" + warn_message << "\n\t\texport STORMPATH_APPLICATION_HREF=href_to_application\n\n" + 110.times { warn_message << '*' } + warn "#{warn_message}\n\n" unless Stormpath::Rails::EnvNamesWarning.env_vars_not_set? + end + + if Stormpath::Rails::EnvNamesWarning.env_vars_not_set? + set_up_message = "In order to use the stormpath-rails gem you need to set the following environment variables:\n\t" + set_up_message << Stormpath::Rails::EnvNamesWarning.test_missing_required_env_vars.map do |var, message| + "#{var} : #{message}" + end.join("\n\t") + set_up_message << "\nBe sure to configure these before trying to run your application.\n\n" + raise set_up_message + end + end + end + end +end diff --git a/spec/dummy/config/stormpath.yml b/spec/dummy/config/stormpath.yml index ae865da..f89d7b7 100644 --- a/spec/dummy/config/stormpath.yml +++ b/spec/dummy/config/stormpath.yml @@ -1,6 +1,6 @@ stormpath: application: - href: <%= ENV['STORMPATH_APPLICATION_URL'] %> + href: <%= ENV['STORMPATH_APPLICATION_HREF'] || ENV['STORMPATH_APPLICATION_URL'] %> name: null web: diff --git a/spec/features/email_verification_spec.rb b/spec/features/email_verification_spec.rb index 8b7cf5d..b36b773 100644 --- a/spec/features/email_verification_spec.rb +++ b/spec/features/email_verification_spec.rb @@ -1,27 +1,26 @@ require 'spec_helper' describe 'the email verification feature', type: :feature, vcr: true do - let(:verify_email_config) { configuration.web.verify_email } - + let(:application) { test_application } let(:test_dir_with_verification) do - Stormpath::Rails::Client.client.directories.get( - ENV.fetch('STORMPATH_SDK_TEST_DIRECTORY_WITH_VERIFICATION_URL') - ) + Stormpath::Rails::Client.client.directories.create(FactoryGirl.attributes_for(:directory)) end - let(:account) { test_dir_with_verification.accounts.create(account_attrs) } - let(:account_attrs) { FactoryGirl.attributes_for(:account) } - let(:sptoken) { account.email_verification_token.token } before do - account + enable_email_verification_for(test_dir_with_verification) + map_account_store(application, test_dir_with_verification, 2, false, false) enable_email_verification Rails.application.reload_routes! + account end - after { account.delete } + after do + test_dir_with_verification.delete + account.delete + end describe 'GET /verify' do describe 'with no sptoken' do diff --git a/spec/requests/email_verification/get_spec.rb b/spec/requests/email_verification/get_spec.rb index 2b22911..b6503f2 100644 --- a/spec/requests/email_verification/get_spec.rb +++ b/spec/requests/email_verification/get_spec.rb @@ -2,20 +2,17 @@ describe 'Email Verification GET', type: :request, vcr: true do let(:response_body) { JSON.parse(response.body) } - + let(:application) { test_application } let(:test_dir_with_verification) do - Stormpath::Rails::Client.client.directories.get( - ENV.fetch('STORMPATH_SDK_TEST_DIRECTORY_WITH_VERIFICATION_URL') - ) + Stormpath::Rails::Client.client.directories.create(FactoryGirl.attributes_for(:directory)) end - let(:account) { test_dir_with_verification.accounts.create(account_attrs) } - let(:account_attrs) { FactoryGirl.attributes_for(:account) } - let(:sptoken) { account.email_verification_token.token } before do + enable_email_verification_for(test_dir_with_verification) + map_account_store(application, test_dir_with_verification, 2, false, false) account enable_email_verification Rails.application.reload_routes! @@ -23,6 +20,7 @@ after do account.delete + test_dir_with_verification.delete end context 'application/json' do diff --git a/spec/requests/email_verification/post_spec.rb b/spec/requests/email_verification/post_spec.rb index 98b62de..569e9bc 100644 --- a/spec/requests/email_verification/post_spec.rb +++ b/spec/requests/email_verification/post_spec.rb @@ -1,17 +1,16 @@ require 'spec_helper' describe 'Email Verification POST', type: :request, vcr: true do + let(:application) { test_application } let(:test_dir_with_verification) do - Stormpath::Rails::Client.client.directories.get( - ENV.fetch('STORMPATH_SDK_TEST_DIRECTORY_WITH_VERIFICATION_URL') - ) + Stormpath::Rails::Client.client.directories.create(FactoryGirl.attributes_for(:directory)) end - let(:account) { test_dir_with_verification.accounts.create(account_attrs) } - let(:account_attrs) { FactoryGirl.attributes_for(:account) } before do + enable_email_verification_for(test_dir_with_verification) + map_account_store(application, test_dir_with_verification, 2, false, false) account enable_email_verification Rails.application.reload_routes! @@ -19,6 +18,7 @@ after do account.delete + test_dir_with_verification.delete end context 'application/json' do diff --git a/spec/requests/id_site_login/get_spec.rb b/spec/requests/id_site_login/get_spec.rb index 0b494fc..51063e9 100644 --- a/spec/requests/id_site_login/get_spec.rb +++ b/spec/requests/id_site_login/get_spec.rb @@ -9,8 +9,8 @@ let(:path) { '' } let(:tenant_name) { application.tenant.name } let(:tenant_domain) { "https://#{tenant_name}.id.stormpath.io" } - let(:api_key_secret) { ENV['STORMPATH_API_KEY_SECRET'] } - let(:aud) { ENV['STORMPATH_API_KEY_ID'] } + let(:api_key_secret) { Stormpath::Rails::Client.client.data_store.api_key.secret } + let(:aud) { Stormpath::Rails::Client.client.data_store.api_key.id } let(:account) { application.accounts.create(account_attrs) } let(:account_attrs) { FactoryGirl.attributes_for(:account) } let(:jwt_response) do diff --git a/spec/services/token_cookie_setter_spec.rb b/spec/services/token_cookie_setter_spec.rb index 0eb8e2a..10204c5 100644 --- a/spec/services/token_cookie_setter_spec.rb +++ b/spec/services/token_cookie_setter_spec.rb @@ -26,7 +26,7 @@ end def expiration_from_token(token) - Time.zone.at(JWT.decode(token, ENV['STORMPATH_API_KEY_SECRET']).first['exp']) + Time.zone.at(JWT.decode(token, Stormpath::Rails::Client.client.data_store.api_key.secret).first['exp']) end describe 'default setup' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ecaf5b1..7a32b5f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,17 +1,5 @@ -TEST_ENV_REQUIRED_VARS = [ - :STORMPATH_API_KEY_ID, - :STORMPATH_API_KEY_SECRET, - :STORMPATH_SDK_TEST_DIRECTORY_WITH_VERIFICATION_URL -].freeze - $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) ENV['RAILS_ENV'] ||= 'test' -require 'simplecov' -SimpleCov.start - -require 'coveralls' -Coveralls.wear! - require 'webmock/rspec' require 'vcr' require 'pry' @@ -42,12 +30,6 @@ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes' c.hook_into :webmock c.configure_rspec_metadata! - c.ignore_request do |request| - request.uri == Stormpath::Rails.config.application.href - end - c.ignore_request do |request| - request.uri == ENV['STORMPATH_SDK_TEST_DIRECTORY_WITH_VERIFICATION_URL'] - end end RSpec.configure do |config| @@ -59,16 +41,8 @@ config.include Capybara::DSL, type: :feature config.include ConfigSpecHelpers config.include Stormpath::Social::Helpers - RSpec::Matchers.alias_matcher :match_json, :include_json - config.before(:suite) do - missing_env_vars = TEST_ENV_REQUIRED_VARS.reject { |var| ENV[var.to_s] } - if missing_env_vars.any? - raise "Missing the following ENV vars to run the specs: #{missing_env_vars.join(', ')}" - end - end - config.before(:each) do Timecop.freeze( VCR.current_cassette && VCR.current_cassette.originally_recorded_at || Time.zone.now @@ -83,4 +57,4 @@ Capybara::RackTest::Driver.new(app, headers: { 'HTTP_ACCEPT' => 'text/html' }) end -Rails.application.routes.default_url_options[:host]= 'localhost:3000' +Rails.application.routes.default_url_options[:host] = 'localhost:3000' diff --git a/spec/support/config_spec_helpers.rb b/spec/support/config_spec_helpers.rb index 9b97833..2335a65 100644 --- a/spec/support/config_spec_helpers.rb +++ b/spec/support/config_spec_helpers.rb @@ -74,4 +74,21 @@ def reload_form_class Stormpath::Rails.send(:remove_const, 'RegistrationForm') if defined?(Stormpath::Rails::RegistrationForm) load('stormpath/rails/registration_form.rb') end + + def map_account_store(app, store, index, default_account_store, default_group_store) + Stormpath::Rails::Client.client.account_store_mappings.create( + application: app, + account_store: store, + list_index: index, + is_default_account_store: default_account_store, + is_default_group_store: default_group_store + ) + end + + def enable_email_verification_for(directory) + directory.account_creation_policy.verification_email_status = 'ENABLED' + directory.account_creation_policy.verification_success_email_status = 'ENABLED' + directory.account_creation_policy.welcome_email_status = 'ENABLED' + directory.account_creation_policy.save + end end