diff --git a/lib/oktakit/client.rb b/lib/oktakit/client.rb index f8f197b..c43a234 100644 --- a/lib/oktakit/client.rb +++ b/lib/oktakit/client.rb @@ -27,8 +27,8 @@ class Client # Default Faraday middleware stack MIDDLEWARE = RACK_BUILDER_CLASS.new do |builder| - builder.use Oktakit::Response::RaiseError - builder.adapter Faraday.default_adapter + builder.use(Oktakit::Response::RaiseError) + builder.adapter(Faraday.default_adapter) end def initialize(token: nil, access_token: nil, organization: nil, api_endpoint: nil) @@ -68,16 +68,16 @@ def get(url, options = {}) accept: options.delete(:accept), content_type: options.delete(:content_type), paginate: should_paginate, - data: options + data: options, } - resp, status, next_page = request :get, url, **request_options + resp, status, next_page = request(:get, url, **request_options) # If request succeeded and we should paginate, then automatically traverse all next_pages if status == 200 && should_paginate all_objs = [resp] while next_page - resp, status, next_page = request :get, next_page, **request_options + resp, status, next_page = request(:get, next_page, **request_options) break unless status == 200 # Return early if page request fails all_objs << resp @@ -98,9 +98,9 @@ def get(url, options = {}) # @param options [Hash] Optional. Body params for request. # @return [Sawyer::Resource] def post(url, options = {}) - request :post, url, query: options.delete(:query), headers: options.delete(:headers), + request(:post, url, query: options.delete(:query), headers: options.delete(:headers), accept: options.delete(:accept), content_type: options.delete(:content_type), - data: options + data: options) end # Make a HTTP PUT request @@ -113,9 +113,9 @@ def post(url, options = {}) # @param options [Hash] Optional. Body params for request. # @return [Sawyer::Resource] def put(url, options = {}) - request :put, url, query: options.delete(:query), headers: options.delete(:headers), + request(:put, url, query: options.delete(:query), headers: options.delete(:headers), accept: options.delete(:accept), content_type: options.delete(:content_type), - data: options + data: options) end # Make a HTTP PATCH request @@ -128,9 +128,9 @@ def put(url, options = {}) # @param options [Hash] Optional. Body params for request. # @return [Sawyer::Resource] def patch(url, options = {}) - request :patch, url, query: options.delete(:query), headers: options.delete(:headers), + request(:patch, url, query: options.delete(:query), headers: options.delete(:headers), accept: options.delete(:accept), content_type: options.delete(:content_type), - data: options + data: options) end # Make a HTTP DELETE request @@ -143,9 +143,9 @@ def patch(url, options = {}) # @param options [Hash] Optional. Body params for request. # @return [Sawyer::Resource] def delete(url, options = {}) - request :delete, url, query: options.delete(:query), headers: options.delete(:headers), + request(:delete, url, query: options.delete(:query), headers: options.delete(:headers), accept: options.delete(:accept), content_type: options.delete(:content_type), - data: options + data: options) end # Make a HTTP HEAD request @@ -158,9 +158,9 @@ def delete(url, options = {}) # @param options [Hash] Optional. Body params for request. # @return [Sawyer::Resource] def head(url, options = {}) - request :head, url, query: options.delete(:query), headers: options.delete(:headers), + request(:head, url, query: options.delete(:query), headers: options.delete(:headers), accept: options.delete(:accept), content_type: options.delete(:content_type), - data: options + data: options) end attr_reader :last_response @@ -187,15 +187,15 @@ def sawyer_agent http.headers[:accept] = 'application/json' http.headers[:content_type] = 'application/json' http.headers[:user_agent] = "Oktakit v#{Oktakit::VERSION}" - http.authorization 'SSWS ', @token if @token - http.authorization :Bearer, @access_token if @access_token + http.authorization('SSWS ', @token) if @token + http.authorization(:Bearer, @access_token) if @access_token end end def sawyer_options { links_parser: Sawyer::LinkParsers::Simple.new, - faraday: Faraday.new(builder: MIDDLEWARE) + faraday: Faraday.new(builder: MIDDLEWARE), } end diff --git a/lib/oktakit/error.rb b/lib/oktakit/error.rb index 8b981fd..5ea9f4d 100644 --- a/lib/oktakit/error.rb +++ b/lib/oktakit/error.rb @@ -8,7 +8,7 @@ class Error < StandardError # @return [Oktakit::Error] def self.from_response(response) status = response[:status].to_i - if klass = error(status) + if (klass = error(status)) klass.new(response) end end @@ -89,7 +89,7 @@ def build_error_message def redact_url(url_string) %w[client_secret access_token].each do |token| - url_string.gsub!(/#{token}=\S+/, "#{token}=(redacted)") if url_string.include? token + url_string.gsub!(/#{token}=\S+/, "#{token}=(redacted)") if url_string.include?(token) end url_string end diff --git a/lib/oktakit/response/raise_error.rb b/lib/oktakit/response/raise_error.rb index 100d6e8..5837a48 100644 --- a/lib/oktakit/response/raise_error.rb +++ b/lib/oktakit/response/raise_error.rb @@ -10,7 +10,7 @@ class RaiseError < Faraday::Response::Middleware private def on_complete(response) - if error = Oktakit::Error.from_response(response) + if (error = Oktakit::Error.from_response(response)) raise error end end diff --git a/oktakit.gemspec b/oktakit.gemspec index d5207ac..74dbdc3 100644 --- a/oktakit.gemspec +++ b/oktakit.gemspec @@ -9,16 +9,16 @@ Gem::Specification.new do |spec| spec.email = ['graeme.johnson@shopify.com', 'julian@shopify.com'] spec.summary = 'Ruby toolkit for working with the Okta API' - spec.homepage = 'https://github.com/shopify/oktakit' + spec.homepage = 'https://github.com/Shopify/oktakit' spec.license = 'MIT' - spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } + spec.files = %x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } spec.bindir = 'exe' spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ['lib'] spec.required_ruby_version = '>= 2.6' - spec.add_dependency 'sawyer', '~> 0.8.1' - spec.add_development_dependency 'bundler' + spec.add_dependency('sawyer', '~> 0.8.1') + spec.add_development_dependency('bundler') end diff --git a/spec/client/admin_roles_spec.rb b/spec/client/admin_roles_spec.rb index 30b9e18..2e107af 100644 --- a/spec/client/admin_roles_spec.rb +++ b/spec/client/admin_roles_spec.rb @@ -7,16 +7,16 @@ describe '#list_roles_assigned_to_user' do it 'returns array of role' do - VCR.use_cassette 'list_roles_assigned_to_user' do + VCR.use_cassette('list_roles_assigned_to_user') do resp, = client.list_roles_assigned_to_user(ADMIN_ROLES_USER_ID) - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end describe '#assign_role_to_user' do it 'returns assigned role' do - VCR.use_cassette 'assign_role_to_user' do + VCR.use_cassette('assign_role_to_user') do resp, = client.assign_role_to_user(ADMIN_ROLES_USER_ID, type: 'SUPER_ADMIN') expected_hash = { id: "ra16nmck9rsYOQiqi0h7", @@ -24,84 +24,84 @@ type: "SUPER_ADMIN", status: "ACTIVE", created: "2016-07-14T03:21:12.000Z", - lastUpdated: "2016-07-14T03:21:12.000Z" + lastUpdated: "2016-07-14T03:21:12.000Z", } - expect(resp.to_h).to be == expected_hash + expect(resp.to_h).to(be == expected_hash) end end end describe '#unassign_role_from_user' do it 'returns http 204 no content' do - VCR.use_cassette 'unassign_role_from_user' do + VCR.use_cassette('unassign_role_from_user') do _, status = client.unassign_role_from_user(ADMIN_ROLES_USER_ID, 'ra16nmck9rsYOQiqi0h7') - expect(status).to be(204) + expect(status).to(be(204)) end end end describe '#list_group_targets_for_user_admin_role' do it 'returns array of groups' do - VCR.use_cassette 'list_group_targets_for_user_admin_role' do + VCR.use_cassette('list_group_targets_for_user_admin_role') do resp, = client.list_group_targets_for_user_admin_role(ADMIN_ROLES_USER_ID, 'ra16nlr5esxo0o0TI0h7') - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end describe '#add_group_target_to_user_admin_role' do it 'returns http 204 no content' do - VCR.use_cassette 'add_group_target_to_user_admin_role' do + VCR.use_cassette('add_group_target_to_user_admin_role') do _, status = client.add_group_target_to_user_admin_role( ADMIN_ROLES_USER_ID, 'ra16nmg6csiUalQhH0h7', ADMIN_ROLES_GROUP_ID ) - expect(status).to be(204) + expect(status).to(be(204)) end end end describe '#remove_group_target_from_user_admin_role' do it 'returns http 204 no content' do - VCR.use_cassette 'remove_group_target_from_user_admin_role' do + VCR.use_cassette('remove_group_target_from_user_admin_role') do _, status = client.remove_group_target_from_user_admin_role( ADMIN_ROLES_USER_ID, 'role_id', ADMIN_ROLES_GROUP_ID ) - expect(status).to be(204) + expect(status).to(be(204)) end end end describe '#list_app_targets_for_app_admin_role' do it 'returns array of catalog apps' do - VCR.use_cassette 'list_app_targets_for_app_admin_role' do + VCR.use_cassette('list_app_targets_for_app_admin_role') do resp, = client.list_app_targets_for_app_admin_role(ADMIN_ROLES_USER_ID, 'ra16nmg6csiUalQhH0h7') - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end describe '#add_app_target_to_app_admin_role' do it 'returns http 204 no content' do - VCR.use_cassette 'add_app_target_to_app_admin_role' do + VCR.use_cassette('add_app_target_to_app_admin_role') do _, status = client.add_app_target_to_app_admin_role( ADMIN_ROLES_USER_ID, 'ra16nmg6csiUalQhH0h7', ADMIN_ROLES_APP_NAME ) - expect(status).to be(204) + expect(status).to(be(204)) end end end describe '#remove_app_target_from_app_admin_role' do it 'returns http 204 no content' do - VCR.use_cassette 'remove_app_target_from_app_admin_role' do + VCR.use_cassette('remove_app_target_from_app_admin_role') do _, status = client.remove_app_target_from_app_admin_role(ADMIN_ROLES_USER_ID, 'role_id', ADMIN_ROLES_APP_NAME) - expect(status).to be(204) + expect(status).to(be(204)) end end end diff --git a/spec/client/apps_spec.rb b/spec/client/apps_spec.rb index 534cf23..edb40b5 100644 --- a/spec/client/apps_spec.rb +++ b/spec/client/apps_spec.rb @@ -11,90 +11,90 @@ params = { "name" => "template_saml_2_0", "label" => "Example SAML App", "signOnMode" => "SAML_2_0", "settings" => { "app" => { "audienceRestriction" => "https://example.com/tenant/123", "forceAuthn" => false, "postBackURL" => "https://example.com/sso/saml", "authnContextClassRef" => "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport", "requestCompressed" => "COMPRESSED", "recipient" => "https://example.com/sso/saml", "signAssertion" => "SIGNED", "destination" => "https://example.com/sso/saml", "signResponse" => "SIGNED", "nameIDFormat" => "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", "groupName" => nil, "groupFilter" => nil, "defaultRelayState" => nil, "configuredIssuer" => nil, "attributeStatements" => nil } } } # rubocop:enable Metrics/LineLength - VCR.use_cassette 'add_application' do + VCR.use_cassette('add_application') do resp, = client.add_application(params) - expect(resp.id).to be == APPS_APP_ID + expect(resp.id).to(be == APPS_APP_ID) end end end describe '#get_application' do it 'returns fetched application' do - VCR.use_cassette 'get_application' do + VCR.use_cassette('get_application') do resp, = client.get_application(APPS_APP_ID) - expect(resp.id).to be == APPS_APP_ID + expect(resp.id).to(be == APPS_APP_ID) end end end describe '#list_applications' do it 'returns array of applications' do - VCR.use_cassette 'list_applications' do + VCR.use_cassette('list_applications') do resp, = client.list_applications - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end describe '#update_application' do it 'returns updated application' do - VCR.use_cassette 'update_application', record: :new_episodes do + VCR.use_cassette('update_application', record: :new_episodes) do resp, = client.update_application(APPS_APP_ID, id: APPS_APP_ID, signOnMode: "SAML_2_0") - expect(resp.id).to be == APPS_APP_ID + expect(resp.id).to(be == APPS_APP_ID) end end end describe '#delete_application' do it 'returns an empty json object {}' do - VCR.use_cassette 'delete_application', record: :new_episodes do + VCR.use_cassette('delete_application', record: :new_episodes) do resp, status = client.delete_application(APPS_APP_ID) - expect(status).to be(204) - expect(resp).to be == "" + expect(status).to(be(204)) + expect(resp).to(be == "") end end end describe '#activate_application' do it 'returns an empty json object {}' do - VCR.use_cassette 'activate_application' do + VCR.use_cassette('activate_application') do resp, status = client.activate_application(APPS_APP_ID) - expect(status).to be(200) - expect(resp.to_h).to be == {} + expect(status).to(be(200)) + expect(resp.to_h).to(be == {}) end end end describe '#deactivate_application' do it 'returns an empty json object {}' do - VCR.use_cassette 'deactivate_application' do + VCR.use_cassette('deactivate_application') do resp, status = client.deactivate_application(APPS_APP_ID) - expect(status).to be(200) - expect(resp.to_h).to be == {} + expect(status).to(be(200)) + expect(resp.to_h).to(be == {}) end end end describe '#assign_user_to_application_for_sso' do it 'returns application user' do - VCR.use_cassette 'assign_user_to_application_for_sso' do + VCR.use_cassette('assign_user_to_application_for_sso') do resp, status = client.assign_user_to_application_for_sso(APPS_APP_ID, id: APPS_USER_ID, scope: "USER", credentials: { - userName: "user@example.com" + userName: "user@example.com", }) - expect(status).to be(200) - expect(resp.id).to be == '00u6nm9ytbmwHeunx0h7' + expect(status).to(be(200)) + expect(resp.id).to(be == '00u6nm9ytbmwHeunx0h7') end end end describe '#assign_user_to_application_for_sso_provisioning' do it 'returns application user with user profile mappings applied' do - VCR.use_cassette 'assign_user_to_application_for_sso_provisioning', record: :new_episodes do + VCR.use_cassette('assign_user_to_application_for_sso_provisioning', record: :new_episodes) do resp, status = client.assign_user_to_application_for_sso_provisioning( APPS_APP_ID, id: APPS_USER_ID, @@ -102,133 +102,133 @@ credentials: { userName: "user@example.com" }, profile: {} ) - expect(status).to be(200) - expect(resp.id).to be == '00u6nm9ytbmwHeunx0h7' + expect(status).to(be(200)) + expect(resp.id).to(be == '00u6nm9ytbmwHeunx0h7') end end end describe '#get_assigned_user_for_application' do it 'returns application user' do - VCR.use_cassette 'get_assigned_user_for_application' do + VCR.use_cassette('get_assigned_user_for_application') do resp, = client.get_assigned_user_for_application(APPS_APP_ID, APPS_USER_ID) - expect(resp.id).to be == '00u6nm9ytbmwHeunx0h7' + expect(resp.id).to(be == '00u6nm9ytbmwHeunx0h7') end end end describe '#list_users_assigned_to_application' do it 'returns array of application users' do - VCR.use_cassette 'list_users_assigned_to_application', record: :new_episodes do + VCR.use_cassette('list_users_assigned_to_application', record: :new_episodes) do resp, = client.list_users_assigned_to_application(APPS_APP_ID) - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end describe '#update_application_credentials_for_assigned_user' do it 'returns application user' do - VCR.use_cassette 'update_application_credentials_for_assigned_user', record: :new_episodes do + VCR.use_cassette('update_application_credentials_for_assigned_user', record: :new_episodes) do resp, = client.update_application_credentials_for_assigned_user(APPS_APP_ID, APPS_USER_ID, credentials: { userName: "user@example.com", password: { - value: "newPassword" - } + value: "newPassword", + }, }) - expect(resp.id).to be == '00u6nm9ytbmwHeunx0h7' + expect(resp.id).to(be == '00u6nm9ytbmwHeunx0h7') end end end describe '#update_application_profile_for_assigned_user' do it 'returns application user with user profile mappings applied' do - VCR.use_cassette 'update_application_profile_for_assigned_user', record: :new_episodes do + VCR.use_cassette('update_application_profile_for_assigned_user', record: :new_episodes) do resp, = client.update_application_profile_for_assigned_user(APPS_APP_ID, APPS_USER_ID, profile: {}) - expect(resp.id).to be == '00u6nm9ytbmwHeunx0h7' + expect(resp.id).to(be == '00u6nm9ytbmwHeunx0h7') end end end describe '#remove_user_from_application' do it 'returns an empty json object {}' do - VCR.use_cassette 'remove_user_from_application', record: :new_episodes do + VCR.use_cassette('remove_user_from_application', record: :new_episodes) do resp, status = client.remove_user_from_application(APPS_APP_ID, APPS_USER_ID) - expect(status).to be(204) - expect(resp).to be == "" + expect(status).to(be(204)) + expect(resp).to(be == "") end end end describe '#assign_group_to_application' do it 'returns all responses return the assigned application group.' do - VCR.use_cassette 'assign_group_to_application', record: :new_episodes do + VCR.use_cassette('assign_group_to_application', record: :new_episodes) do resp, = client.assign_group_to_application(APPS_APP_ID, APPS_GROUP_ID) - expect(resp.id).to be == '00g6nm9yt5VEl6xYd0h7' + expect(resp.id).to(be == '00g6nm9yt5VEl6xYd0h7') end end end describe '#get_assigned_group_for_application' do it 'returns fetched application group' do - VCR.use_cassette 'get_assigned_group_for_application', record: :new_episodes do + VCR.use_cassette('get_assigned_group_for_application', record: :new_episodes) do resp, = client.get_assigned_group_for_application(APPS_APP_ID, APPS_GROUP_ID) - expect(resp.id).to be == '00g6nm9yt5VEl6xYd0h7' + expect(resp.id).to(be == '00g6nm9yt5VEl6xYd0h7') end end end describe '#list_groups_assigned_to_application' do it 'returns array of application groups' do - VCR.use_cassette 'list_groups_assigned_to_application', record: :new_episodes do + VCR.use_cassette('list_groups_assigned_to_application', record: :new_episodes) do resp, = client.list_groups_assigned_to_application(APPS_APP_ID) - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end describe '#remove_group_from_application' do it 'returns an empty json object {}' do - VCR.use_cassette 'remove_group_from_application', record: :new_episodes do + VCR.use_cassette('remove_group_from_application', record: :new_episodes) do resp, = client.remove_group_from_application(APPS_APP_ID, APPS_GROUP_ID) - expect(resp).to be == "" + expect(resp).to(be == "") end end end describe '#generate_new_application_key_credential' do it 'returns return the generated application key credential.' do - VCR.use_cassette 'generate_new_application_key_credential', record: :new_episodes do + VCR.use_cassette('generate_new_application_key_credential', record: :new_episodes) do resp, = client.generate_new_application_key_credential(APPS_APP_ID, query: { validityYears: '1' }) - expect(resp.kid).to be == 'akm5hvbbevE341ovl0h7' + expect(resp.kid).to(be == 'akm5hvbbevE341ovl0h7') end end end describe '#list_key_credentials_for_application' do it 'returns array of application key credential.' do - VCR.use_cassette 'list_key_credentials_for_application', record: :new_episodes do + VCR.use_cassette('list_key_credentials_for_application', record: :new_episodes) do resp, = client.list_key_credentials_for_application(APPS_APP_ID) - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end describe '#get_key_credential_for_application' do it 'returns application key credential.' do - VCR.use_cassette 'get_key_credential_for_application', record: :new_episodes do + VCR.use_cassette('get_key_credential_for_application', record: :new_episodes) do resp, = client.get_key_credential_for_application(APPS_APP_ID, 'akm5hvbbevE341ovl0h7') - expect(resp.kid).to be == 'akm5hvbbevE341ovl0h7' + expect(resp.kid).to(be == 'akm5hvbbevE341ovl0h7') end end end describe '#preview_saml_metadata_for_application' do it 'returns saml metadata in xml' do - VCR.use_cassette 'preview_saml_metadata_for_application', record: :new_episodes do + VCR.use_cassette('preview_saml_metadata_for_application', record: :new_episodes) do resp, status = client.preview_saml_metadata_for_application(APPS_APP_ID, query: { q: 'akml95AVptFeCi4zm0g3' }) - expect(status).to be(200) - expect(resp).to start_with('') + expect(status).to(be(200)) + expect(resp).to(start_with('')) end end end diff --git a/spec/client/events_spec.rb b/spec/client/events_spec.rb index 1589f7d..874f23f 100644 --- a/spec/client/events_spec.rb +++ b/spec/client/events_spec.rb @@ -3,9 +3,9 @@ describe Oktakit::Client::Events do describe '#list_events' do it 'returns array of events' do - VCR.use_cassette 'list_events' do + VCR.use_cassette('list_events') do resp, = client.list_events - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end diff --git a/spec/client/factors_spec.rb b/spec/client/factors_spec.rb index 114bf3d..118404e 100644 --- a/spec/client/factors_spec.rb +++ b/spec/client/factors_spec.rb @@ -7,126 +7,126 @@ describe '#get_factor' do it 'returns factor' do - VCR.use_cassette 'get_factor', record: :new_episodes do + VCR.use_cassette('get_factor', record: :new_episodes) do resp, = client.get_factor(FACTORS_USER_ID, FACTORS_FACTOR_ID) - expect(resp.id).to be == FACTORS_FACTOR_ID + expect(resp.id).to(be == FACTORS_FACTOR_ID) end end end describe '#list_enrolled_factors' do it 'returns array of factors' do - VCR.use_cassette 'list_enrolled_factors', record: :new_episodes do + VCR.use_cassette('list_enrolled_factors', record: :new_episodes) do resp, = client.list_enrolled_factors(FACTORS_USER_ID) - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end describe '#list_factors_to_enroll' do it 'returns array of factors' do - VCR.use_cassette 'list_factors_to_enroll', record: :new_episodes do + VCR.use_cassette('list_factors_to_enroll', record: :new_episodes) do resp, = client.list_factors_to_enroll(FACTORS_USER_ID) - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end describe '#list_security_questions' do it 'returns array of questions' do - VCR.use_cassette 'list_security_questions', record: :new_episodes do + VCR.use_cassette('list_security_questions', record: :new_episodes) do resp, = client.list_security_questions(FACTORS_USER_ID) - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end describe '#enroll_factor' do it 'returns all responses return the enrolled factor with a status of either pending_activation or active.' do - VCR.use_cassette 'enroll_factor', record: :new_episodes do + VCR.use_cassette('enroll_factor', record: :new_episodes) do resp, = client.enroll_factor(FACTORS_USER_ID, factorType: "sms", provider: "OKTA", profile: { - phoneNumber: "+1-613-456-1234" + phoneNumber: "+1-613-456-1234", }) - expect(resp.id).not_to be_nil + expect(resp.id).not_to(be_nil) end end end describe '#activate_factor' do it 'returns if the passcode is correct you will receive the factor with an active status.' do - VCR.use_cassette 'activate_factor', record: :new_episodes do + VCR.use_cassette('activate_factor', record: :new_episodes) do resp, = client.activate_factor(FACTORS_USER_ID, FACTORS_FACTOR_ID) - expect(resp.id).not_to be_nil + expect(resp.id).not_to(be_nil) end end end describe '#reset_factor' do it 'returns 204 no content' do - VCR.use_cassette 'reset_factor', record: :new_episodes do + VCR.use_cassette('reset_factor', record: :new_episodes) do _, status = client.reset_factor(FACTORS_USER_ID, FACTORS_FACTOR_ID) - expect(status).to be(204) + expect(status).to(be(204)) end end end describe '#verify_security_question_factor' do it 'returns verification result' do - VCR.use_cassette 'verify_security_question_factor', record: :new_episodes do + VCR.use_cassette('verify_security_question_factor', record: :new_episodes) do resp, = client.verify_security_question_factor(FACTORS_USER_ID, FACTORS_FACTOR_ID) - expect(resp.factorResult).to be == 'SUCCESS' + expect(resp.factorResult).to(be == 'SUCCESS') end end end describe '#verify_sms_factor' do it 'returns verification result' do - VCR.use_cassette 'verify_sms_factor', record: :new_episodes do + VCR.use_cassette('verify_sms_factor', record: :new_episodes) do resp, = client.verify_sms_factor(FACTORS_USER_ID, FACTORS_FACTOR_ID) - expect(resp.factorResult).to be == 'SUCCESS' + expect(resp.factorResult).to(be == 'SUCCESS') end end end describe '#verify_totp_factor' do it 'returns verification result' do - VCR.use_cassette 'verify_totp_factor', record: :new_episodes do + VCR.use_cassette('verify_totp_factor', record: :new_episodes) do resp, = client.verify_totp_factor(FACTORS_USER_ID, FACTORS_FACTOR_ID) - expect(resp.factorResult).to be == 'SUCCESS' + expect(resp.factorResult).to(be == 'SUCCESS') end end end describe '#verify_push_factor' do it 'returns verification result (waiting, success, rejected, or timeout)' do - VCR.use_cassette 'verify_push_factor', record: :new_episodes do + VCR.use_cassette('verify_push_factor', record: :new_episodes) do resp, = client.verify_push_factor(FACTORS_USER_ID, FACTORS_FACTOR_ID) - expect(resp.factorResult).to be == 'WAITING' + expect(resp.factorResult).to(be == 'WAITING') end end end describe '#poll_for_verify_transaction_completion' do it 'returns verification result' do - VCR.use_cassette 'poll_for_verify_transaction_completion', record: :new_episodes do + VCR.use_cassette('poll_for_verify_transaction_completion', record: :new_episodes) do resp, = client.poll_for_verify_transaction_completion( FACTORS_USER_ID, FACTORS_FACTOR_ID, FACTORS_TRANSACTION_ID ) - expect(resp.factorResult).to be == 'WAITING' + expect(resp.factorResult).to(be == 'WAITING') end end end describe '#verify_token_factor' do it 'returns verification result' do - VCR.use_cassette 'verify_token_factor', record: :new_episodes do + VCR.use_cassette('verify_token_factor', record: :new_episodes) do resp, = client.verify_token_factor(FACTORS_USER_ID, FACTORS_FACTOR_ID) - expect(resp.factorResult).to be == 'SUCCESS' + expect(resp.factorResult).to(be == 'SUCCESS') end end end diff --git a/spec/client/groups_spec.rb b/spec/client/groups_spec.rb index d8d98bc..efa39d1 100644 --- a/spec/client/groups_spec.rb +++ b/spec/client/groups_spec.rb @@ -6,90 +6,90 @@ describe '#add_group' do it 'returns the created group.' do - VCR.use_cassette 'add_group' do + VCR.use_cassette('add_group') do resp, = client.add_group( profile: { name: "New Group Users", - description: "New Group Users" + description: "New Group Users", } ) - expect(resp.id).not_to be_nil + expect(resp.id).not_to(be_nil) end end end describe '#get_group' do it 'returns fetched group' do - VCR.use_cassette 'get_group' do + VCR.use_cassette('get_group') do resp, = client.get_group(GROUPS_GROUP_ID) - expect(resp.id).to be == GROUPS_GROUP_ID + expect(resp.id).to(be == GROUPS_GROUP_ID) end end end describe '#list_groups' do it 'returns array of groups' do - VCR.use_cassette 'list_groups' do + VCR.use_cassette('list_groups') do resp, = client.list_groups - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end describe '#update_group' do it 'returns updated group' do - VCR.use_cassette 'update_group' do + VCR.use_cassette('update_group') do resp, = client.update_group(GROUPS_GROUP_ID, profile: { name: "New Name for the Group", - description: "New Name for the Group" + description: "New Name for the Group", }) - expect(resp.profile.name).to be == "New Name for the Group" + expect(resp.profile.name).to(be == "New Name for the Group") end end end describe '#remove_group' do it 'returns http 204 no content' do - VCR.use_cassette 'remove_group' do + VCR.use_cassette('remove_group') do _, status = client.remove_group(GROUPS_GROUP_ID) - expect(status).to be(204) + expect(status).to(be(204)) end end end describe '#list_group_members' do it 'returns array of users' do - VCR.use_cassette 'list_group_members' do + VCR.use_cassette('list_group_members') do resp, = client.list_group_members(GROUPS_GROUP_ID) - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end describe '#add_user_to_group' do it 'returns http 204 no content' do - VCR.use_cassette 'add_user_to_group' do + VCR.use_cassette('add_user_to_group') do _, status = client.add_user_to_group(GROUPS_GROUP_ID, GROUPS_USER_ID) - expect(status).to be(204) + expect(status).to(be(204)) end end end describe '#remove_user_from_group' do it 'returns http 204 no content' do - VCR.use_cassette 'remove_user_from_group' do + VCR.use_cassette('remove_user_from_group') do _, status = client.remove_user_from_group(GROUPS_GROUP_ID, GROUPS_USER_ID) - expect(status).to be(204) + expect(status).to(be(204)) end end end describe '#list_assigned_applications' do it 'returns array of applications' do - VCR.use_cassette 'list_assigned_applications' do + VCR.use_cassette('list_assigned_applications') do resp, = client.list_assigned_applications(GROUPS_GROUP_ID) - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end diff --git a/spec/client/identity_providers_spec.rb b/spec/client/identity_providers_spec.rb index 70fbd66..48814bc 100644 --- a/spec/client/identity_providers_spec.rb +++ b/spec/client/identity_providers_spec.rb @@ -8,7 +8,7 @@ describe '#add_identity_provider' do it 'returns the created identity provider' do - VCR.use_cassette 'add_identity_provider', record: :new_episodes do + VCR.use_cassette('add_identity_provider', record: :new_episodes) do resp, = client.add_identity_provider( type: "SAML2", name: "Example IdP", @@ -18,83 +18,83 @@ sso: { url: "https://idp.example.com", binding: "HTTP-POST", - destination: "https://idp.example.com" + destination: "https://idp.example.com", }, acs: { binding: "HTTP-POST", - type: "INSTANCE" - } + type: "INSTANCE", + }, }, algorithms: { request: { signature: { algorithm: "SHA-256", - scope: "REQUEST" - } + scope: "REQUEST", + }, }, response: { signature: { algorithm: "SHA-256", - scope: "ANY" - } - } + scope: "ANY", + }, + }, }, credentials: { trust: { issuer: "https://idp.example.com", audience: "http://www.okta.com/123", - kid: "74bb2164-e0c8-4457-862b-7c29ba6cd2c9" - } - } + kid: "74bb2164-e0c8-4457-862b-7c29ba6cd2c9", + }, + }, }, policy: { provisioning: { action: "AUTO", profileMaster: true, groups: { - action: "NONE" - } + action: "NONE", + }, }, accountLink: { filter: nil, - action: "AUTO" + action: "AUTO", }, subject: { userNameTemplate: { - template: "saml.subjectNameId" + template: "saml.subjectNameId", }, format: ["urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified"], filter: "(\\S+@example\\.com)", - matchType: "USERNAME" - } + matchType: "USERNAME", + }, } ) - expect(resp.id).not_to be_nil + expect(resp.id).not_to(be_nil) end end end describe '#get_identity_provider' do it 'returns identity provider' do - VCR.use_cassette 'get_identity_provider', record: :new_episodes do + VCR.use_cassette('get_identity_provider', record: :new_episodes) do resp, = client.get_identity_provider(IDENTITY_PROVIDERS_IDENTITY_ID) - expect(resp.id).to be == IDENTITY_PROVIDERS_IDENTITY_ID + expect(resp.id).to(be == IDENTITY_PROVIDERS_IDENTITY_ID) end end end describe '#list_identity_providers' do it 'returns array of identity provider' do - VCR.use_cassette 'list_identity_providers', record: :new_episodes do + VCR.use_cassette('list_identity_providers', record: :new_episodes) do resp, = client.list_identity_providers - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end describe '#update_identity_provider' do it 'returns updated identity provider' do - VCR.use_cassette 'update_identity_provider', record: :new_episodes do + VCR.use_cassette('update_identity_provider', record: :new_episodes) do _, status = client.update_identity_provider( IDENTITY_PROVIDERS_IDENTITY_ID, id: "0oa62bfdjnK55Z5x80h7", @@ -106,182 +106,182 @@ sso: { url: "https://idp.example.com/saml2/sso", binding: "HTTP-REDIRECT", - destination: "https://idp.example.com/saml2/sso" + destination: "https://idp.example.com/saml2/sso", }, acs: { binding: "HTTP-POST", - type: "INSTANCE" - } + type: "INSTANCE", + }, }, algorithms: { request: { signature: { algorithm: "SHA-256", - scope: "REQUEST" - } + scope: "REQUEST", + }, }, response: { signature: { algorithm: "SHA-256", - scope: "ANY" - } - } + scope: "ANY", + }, + }, }, credentials: { trust: { issuer: "https://idp.example.com", audience: "https://www.okta.com/saml2/service-provider/spCQJRNaaxs7ANqKBO7M", - kid: "74bb2164-e0c8-4457-862b-7c29ba6cd2c9" - } - } + kid: "74bb2164-e0c8-4457-862b-7c29ba6cd2c9", + }, + }, }, policy: { provisioning: { action: "AUTO", profileMaster: true, groups: { - action: "NONE" - } + action: "NONE", + }, }, accountLink: { filter: nil, - action: "AUTO" + action: "AUTO", }, subject: { userNameTemplate: { template: "idpuser.subjectNameId", - type: "BUILT_IN" + type: "BUILT_IN", }, format: [ - "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" + "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified", ], filter: nil, - matchType: "USERNAME" + matchType: "USERNAME", }, - maxClockSkew: 120000 + maxClockSkew: 120000, } ) - expect(status).to be(200) + expect(status).to(be(200)) end end end describe '#delete_identity_provider' do it 'returns http 204 no content' do - VCR.use_cassette 'delete_identity_provider', record: :new_episodes do + VCR.use_cassette('delete_identity_provider', record: :new_episodes) do _, status = client.delete_identity_provider(IDENTITY_PROVIDERS_IDENTITY_ID) - expect(status).to be(204) + expect(status).to(be(204)) end end end describe '#activate_identity_provider' do it 'returns activated identity provider' do - VCR.use_cassette 'activate_identity_provider', record: :new_episodes do + VCR.use_cassette('activate_identity_provider', record: :new_episodes) do resp, = client.activate_identity_provider(IDENTITY_PROVIDERS_IDENTITY_ID) - expect(resp.id).to be == IDENTITY_PROVIDERS_IDENTITY_ID + expect(resp.id).to(be == IDENTITY_PROVIDERS_IDENTITY_ID) end end end describe '#deactivate_identity_provider' do it 'returns deactivated identity provider' do - VCR.use_cassette 'deactivate_identity_provider', record: :new_episodes do + VCR.use_cassette('deactivate_identity_provider', record: :new_episodes) do resp, = client.deactivate_identity_provider(IDENTITY_PROVIDERS_IDENTITY_ID) - expect(resp.id).to be == IDENTITY_PROVIDERS_IDENTITY_ID + expect(resp.id).to(be == IDENTITY_PROVIDERS_IDENTITY_ID) end end end describe '#get_identity_provider_transaction' do it 'returns identity provider transaction' do - VCR.use_cassette 'get_identity_provider_transaction', record: :new_episodes do + VCR.use_cassette('get_identity_provider_transaction', record: :new_episodes) do resp, = client.get_identity_provider_transaction(IDENTITY_PROVIDERS_TRANSACTION_ID) - expect(resp.id).not_to be_nil + expect(resp.id).not_to(be_nil) end end end describe '#get_source_idp_user_for_idp_transaction' do it 'returns identity provider user' do - VCR.use_cassette 'get_source_idp_user_for_idp_transaction', record: :new_episodes do + VCR.use_cassette('get_source_idp_user_for_idp_transaction', record: :new_episodes) do resp, = client.get_source_idp_user_for_idp_transaction(IDENTITY_PROVIDERS_TRANSACTION_ID) - expect(resp.externalId).not_to be_nil + expect(resp.externalId).not_to(be_nil) end end end describe '#get_target_user_for_idp_provision_transaction' do it 'returns trasformed okta user profile' do - VCR.use_cassette 'get_target_user_for_idp_provision_transaction', record: :new_episodes do + VCR.use_cassette('get_target_user_for_idp_provision_transaction', record: :new_episodes) do resp, = client.get_target_user_for_idp_provision_transaction(IDENTITY_PROVIDERS_TRANSACTION_ID) - expect(resp.profile).not_to be_nil + expect(resp.profile).not_to(be_nil) end end end describe '#list_users_for_idp_link_transaction' do it 'returns array of okta user' do - VCR.use_cassette 'list_users_for_idp_link_transaction', record: :new_episodes do + VCR.use_cassette('list_users_for_idp_link_transaction', record: :new_episodes) do resp, = client.list_users_for_idp_link_transaction(IDENTITY_PROVIDERS_TRANSACTION_ID) - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end describe '#provision_idp_user' do it 'returns identity provider transaction' do - VCR.use_cassette 'provision_idp_user', record: :new_episodes do + VCR.use_cassette('provision_idp_user', record: :new_episodes) do resp, = client.provision_idp_user(IDENTITY_PROVIDERS_TRANSACTION_ID, profile: { userType: "Social" }) - expect(resp.id).not_to be_nil + expect(resp.id).not_to(be_nil) end end end describe '#link_idp_user' do it 'returns identity provider transaction' do - VCR.use_cassette 'link_idp_user', record: :new_episodes do + VCR.use_cassette('link_idp_user', record: :new_episodes) do resp, = client.link_idp_user(IDENTITY_PROVIDERS_TRANSACTION_ID, IDENTITY_PROVIDERS_USER_ID, profile: { - userType: "Social" + userType: "Social", }) - expect(resp.id).not_to be_nil + expect(resp.id).not_to(be_nil) end end end describe '#add_x509_certificate_public_key' do it 'returns identity provider key credential' do - VCR.use_cassette 'add_x509_certificate_public_key', record: :new_episodes do + VCR.use_cassette('add_x509_certificate_public_key', record: :new_episodes) do resp, = client.add_x509_certificate_public_key - expect(resp.kid).not_to be_nil + expect(resp.kid).not_to(be_nil) end end end describe '#get_key' do it 'returns identity provider key credential' do - VCR.use_cassette 'get_key', record: :new_episodes do + VCR.use_cassette('get_key', record: :new_episodes) do resp, = client.get_key(IDENTITY_PROVIDERS_KEY_ID) - expect(resp.kid).not_to be_nil + expect(resp.kid).not_to(be_nil) end end end describe '#list_keys' do it 'returns array of identity provider key credential' do - VCR.use_cassette 'list_keys', record: :new_episodes do + VCR.use_cassette('list_keys', record: :new_episodes) do resp, = client.list_keys - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end describe '#delete_key' do it 'returns http 204 no content' do - VCR.use_cassette 'delete_key', record: :new_episodes do + VCR.use_cassette('delete_key', record: :new_episodes) do _, status = client.delete_key(IDENTITY_PROVIDERS_KEY_ID) - expect(status).to be(204) + expect(status).to(be(204)) end end end diff --git a/spec/client/schemas_spec.rb b/spec/client/schemas_spec.rb index b0042d9..e29f0bd 100644 --- a/spec/client/schemas_spec.rb +++ b/spec/client/schemas_spec.rb @@ -5,16 +5,16 @@ describe '#get_user_schema' do it 'returns user schema' do - VCR.use_cassette 'get_user_schema' do + VCR.use_cassette('get_user_schema') do resp, = client.get_user_schema - expect(resp.id).not_to be_nil + expect(resp.id).not_to(be_nil) end end end describe '#add_property_to_user_profile_schema' do it 'returns user schema' do - VCR.use_cassette 'add_property_to_user_profile_schema' do + VCR.use_cassette('add_property_to_user_profile_schema') do resp, status = client.add_property_to_user_profile_schema( definitions: { custom: { @@ -31,24 +31,24 @@ permissions: [ { principal: "SELF", - action: "READ_WRITE" - } - ] - } + action: "READ_WRITE", + }, + ], + }, }, - required: [] - } + required: [], + }, } ) - expect(resp.id).not_to be_nil - expect(status).to be(200) + expect(resp.id).not_to(be_nil) + expect(status).to(be(200)) end end end describe '#update_user_profile_schema_property' do it 'returns user schema' do - VCR.use_cassette 'update_user_profile_schema_property' do + VCR.use_cassette('update_user_profile_schema_property') do resp, status = client.update_user_profile_schema_property( definitions: { custom: { @@ -65,34 +65,34 @@ permissions: [ { principal: "SELF", - action: "READ_ONLY" - } - ] - } + action: "READ_ONLY", + }, + ], + }, }, - required: [] - } + required: [], + }, } ) - expect(resp.id).not_to be_nil - expect(status).to be(200) + expect(resp.id).not_to(be_nil) + expect(status).to(be(200)) end end end describe '#remove_property_from_user_profile_schema' do it 'returns user schema' do - VCR.use_cassette 'remove_property_from_user_profile_schema' do + VCR.use_cassette('remove_property_from_user_profile_schema') do _, status = client.remove_property_from_user_profile_schema( definitions: { custom: { id: "#custom", type: "object", - properties: { twitterUserName: nil } - } + properties: { twitterUserName: nil }, + }, } ) - expect(status).to be(200) + expect(status).to(be(200)) end end end diff --git a/spec/client/templates_spec.rb b/spec/client/templates_spec.rb index 311043c..93cb2d7 100644 --- a/spec/client/templates_spec.rb +++ b/spec/client/templates_spec.rb @@ -5,7 +5,7 @@ describe '#add_sms_template' do it 'returns the created sms template.' do - VCR.use_cassette 'add_sms_template' do + VCR.use_cassette('add_sms_template') do resp, = client.add_sms_template( name: "Custom", type: "SMS_VERIFY_CODE", @@ -14,35 +14,35 @@ { es: "${org.name}: el código de verificación es ${code}", fr: "${org.name}: votre code de vérification est ${code}", - it: "${org.name}: il codice di verifica è ${code}" + it: "${org.name}: il codice di verifica è ${code}", } ) - expect(resp.id).not_to be_nil + expect(resp.id).not_to(be_nil) end end end describe '#get_sms_template' do it 'returns fetched sms template' do - VCR.use_cassette 'get_sms_template' do + VCR.use_cassette('get_sms_template') do resp, = client.get_sms_template(TEMPLATES_TEMPLATE_ID) - expect(resp.id).to be == TEMPLATES_TEMPLATE_ID + expect(resp.id).to(be == TEMPLATES_TEMPLATE_ID) end end end describe '#list_sms_templates' do it 'returns array of sms template' do - VCR.use_cassette 'list_sms_templates' do + VCR.use_cassette('list_sms_templates') do resp, = client.list_sms_templates - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end describe '#update_sms_template' do it 'returns updated sms template' do - VCR.use_cassette 'update_sms_template' do + VCR.use_cassette('update_sms_template') do _, status = client.update_sms_template(TEMPLATES_TEMPLATE_ID, name: "Custom", type: "SMS_VERIFY_CODE", @@ -51,30 +51,30 @@ { es: "${org.name}: ${code}.", fr: "${org.name}: ${code}.", - it: "${org.name}: ${code}." + it: "${org.name}: ${code}.", }) - expect(status).to be(200) + expect(status).to(be(200)) end end end describe '#partial_sms_template_update' do it 'returns updated sms template' do - VCR.use_cassette 'partial_sms_template_update' do + VCR.use_cassette('partial_sms_template_update') do resp, = client.partial_sms_template_update(TEMPLATES_TEMPLATE_ID, translations: { - de: "${org.name}: ihre bestätigungscode ist ${code}." + de: "${org.name}: ihre bestätigungscode ist ${code}.", }) - expect(resp.translations.de).to be == '${org.name}: ihre bestätigungscode ist ${code}.' + expect(resp.translations.de).to(be == '${org.name}: ihre bestätigungscode ist ${code}.') end end end describe '#remove_sms_template' do it 'returns there is no content in the response.' do - VCR.use_cassette 'remove_sms_template' do + VCR.use_cassette('remove_sms_template') do _, status = client.remove_sms_template(TEMPLATES_TEMPLATE_ID) - expect(status).to be(204) + expect(status).to(be(204)) end end end diff --git a/spec/client/users_spec.rb b/spec/client/users_spec.rb index fd0c4f5..2f0716e 100644 --- a/spec/client/users_spec.rb +++ b/spec/client/users_spec.rb @@ -5,35 +5,35 @@ describe '#create_user' do it 'returns all responses return the created user.' do - VCR.use_cassette 'create_user' do + VCR.use_cassette('create_user') do resp, = client.create_user( profile: { firstName: "Example", lastName: "User", email: "example@example.com", - login: "example@example.com" + login: "example@example.com", }, credentials: { password: { value: "MyPassword123!" }, recovery_question: { question: "How much wood could a woodchuck chuck?", - answer: "A woodchuck could chuck as much as he could chuck." - } + answer: "A woodchuck could chuck as much as he could chuck.", + }, } ) - expect(resp.id).not_to be_nil + expect(resp.id).not_to(be_nil) end end end describe '#get_user' do it 'returns fetched user' do - VCR.use_cassette 'get_user' do + VCR.use_cassette('get_user') do resp, = client.get_user(USERS_USER_ID) - expect(resp.to_h).to have_key(:id) - expect(resp.to_h).to have_key(:profile) + expect(resp.to_h).to(have_key(:id)) + expect(resp.to_h).to(have_key(:profile)) %w[firstName lastName login email].each do |key| - expect(resp.to_h[:profile].to_h).to have_key(key.to_sym) + expect(resp.to_h[:profile].to_h).to(have_key(key.to_sym)) end end end @@ -41,192 +41,192 @@ describe '#list_users' do it 'returns array of user' do - VCR.use_cassette 'list_users' do + VCR.use_cassette('list_users') do resp, = client.list_users - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end describe '#update_user' do it 'returns updated user' do - VCR.use_cassette 'update_user' do + VCR.use_cassette('update_user') do resp, = client.update_user(USERS_USER_ID, profile: { firstName: "Bob", lastName: "User", email: "example@example.com", - login: "example@example.com" + login: "example@example.com", }) - expect(resp.profile.firstName).to be == 'Bob' + expect(resp.profile.firstName).to(be == 'Bob') end end end describe '#update_user partial' do it 'returns updated user' do - VCR.use_cassette 'update_user_partial' do + VCR.use_cassette('update_user_partial') do resp, = client.update_user(USERS_USER_ID, profile: { firstName: "Bob", lastName: "User", email: "example@example.com", - login: "example@example.com" + login: "example@example.com", }, partial: true) - expect(resp.profile.firstName).to be == 'Bob' + expect(resp.profile.firstName).to(be == 'Bob') end end end describe '#update_profile' do it 'returns updated user' do - VCR.use_cassette 'update_profile' do + VCR.use_cassette('update_profile') do resp, = client.update_profile(USERS_USER_ID, profile: { firstName: "Other Bob", lastName: "User", email: "example@example.com", - login: "example@example.com" + login: "example@example.com", }) - expect(resp.profile.firstName).to be == 'Other Bob' + expect(resp.profile.firstName).to(be == 'Other Bob') end end end describe '#get_assigned_app_links' do it 'returns array of app links' do - VCR.use_cassette 'get_assigned_app_links' do + VCR.use_cassette('get_assigned_app_links') do resp, = client.get_assigned_app_links(USERS_USER_ID) - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end describe '#get_member_groups' do it 'returns array of groups' do - VCR.use_cassette 'get_member_groups' do + VCR.use_cassette('get_member_groups') do resp, = client.get_member_groups(USERS_USER_ID) - expect(resp).to be_a(Array) + expect(resp).to(be_a(Array)) end end end describe '#activate_user' do it 'returns empty object by default.' do - VCR.use_cassette 'activate_user' do + VCR.use_cassette('activate_user') do resp, = client.activate_user(USERS_USER_ID) - expect(resp.to_h).to be == {} + expect(resp.to_h).to(be == {}) end end end describe '#deactivate_user' do it 'returns an empty object.' do - VCR.use_cassette 'deactivate_user' do + VCR.use_cassette('deactivate_user') do resp, = client.deactivate_user(USERS_USER_ID) - expect(resp.to_h).to be == {} + expect(resp.to_h).to(be == {}) end end end describe '#suspend_user' do it 'returns an empty object.' do - VCR.use_cassette 'suspend_user' do + VCR.use_cassette('suspend_user') do resp, = client.suspend_user(USERS_USER_ID) - expect(resp.to_h).to be == {} + expect(resp.to_h).to(be == {}) end end end describe '#unsuspend_user' do it 'returns an empty object. returns an empty object.' do - VCR.use_cassette 'unsuspend_user' do + VCR.use_cassette('unsuspend_user') do resp, = client.unsuspend_user(USERS_USER_ID) - expect(resp.to_h).to be == {} + expect(resp.to_h).to(be == {}) end end end describe '#unlock_user' do it 'returns an empty object' do - VCR.use_cassette 'unlock_user' do + VCR.use_cassette('unlock_user') do _, status = client.unlock_user(USERS_USER_ID) - expect(status).to be(200) + expect(status).to(be(200)) end end end describe '#reset_password' do it 'returns an empty object by default.' do - VCR.use_cassette 'reset_password' do + VCR.use_cassette('reset_password') do resp, = client.reset_password(USERS_USER_ID) - expect(resp.to_h).to be == {} + expect(resp.to_h).to(be == {}) end end end describe '#expire_password' do it 'returns the complete user object by default.' do - VCR.use_cassette 'expire_password' do + VCR.use_cassette('expire_password') do resp, = client.expire_password(USERS_USER_ID) - expect(resp.status).to be == 'PASSWORD_EXPIRED' + expect(resp.status).to(be == 'PASSWORD_EXPIRED') end end end describe '#reset_factors' do it 'returns an empty object by default.' do - VCR.use_cassette 'reset_factors' do + VCR.use_cassette('reset_factors') do resp, = client.reset_factors(USERS_USER_ID) - expect(resp.to_h).to be == {} + expect(resp.to_h).to(be == {}) end end end describe '#forgot_password' do it 'returns an empty object by default.' do - VCR.use_cassette 'forgot_password' do + VCR.use_cassette('forgot_password') do resp, = client.forgot_password( USERS_USER_ID, password: { value: "123Password!" }, recovery_question: { answer: "A woodchuck could chuck as much as he could chuck." } ) - expect(resp.password.to_h).to be == {} + expect(resp.password.to_h).to(be == {}) end end end describe '#change_password' do it 'returns credentials of the user' do - VCR.use_cassette 'change_password' do + VCR.use_cassette('change_password') do _, status = client.change_password(USERS_USER_ID, oldPassword: { value: "uTVM,TPw55" }, newPassword: { value: "NewPassword1234!" }) - expect(status).to be(200) + expect(status).to(be(200)) end end end describe '#change_recovery_question' do it 'returns credentials of the user' do - VCR.use_cassette 'change_recovery_question' do + VCR.use_cassette('change_recovery_question') do resp, = client.change_recovery_question(USERS_USER_ID, password: { value: "NewPassword1234!" }, recovery_question: { question: "Where is Shopify's HQ?", - answer: "Ottawa" + answer: "Ottawa", }) - expect(resp.recovery_question.question).to be == "Where is Shopify's HQ?" + expect(resp.recovery_question.question).to(be == "Where is Shopify's HQ?") end end end describe '#clear_user_sessions' do it 'returns 204 no content' do - VCR.use_cassette 'clear_user_sessions' do + VCR.use_cassette('clear_user_sessions') do _, status = client.clear_user_sessions(USERS_USER_ID) - expect(status).to be(204) + expect(status).to(be(204)) end end end diff --git a/spec/oktakit_spec.rb b/spec/oktakit_spec.rb index 5f2b0dc..273f06f 100644 --- a/spec/oktakit_spec.rb +++ b/spec/oktakit_spec.rb @@ -2,22 +2,22 @@ describe Oktakit do it 'has a version number' do - expect(Oktakit::VERSION).not_to be nil + expect(Oktakit::VERSION).not_to(be(nil)) end describe 'client' do it 'has a default API endpoint' do client = Oktakit::Client.new(token: test_okta_token, organization: 'okta-test') - expect(client.api_endpoint).to eq('https://okta-test.okta.com/api/v1') + expect(client.api_endpoint).to(eq('https://okta-test.okta.com/api/v1')) end it 'allows to configure the API endpoint' do client = Oktakit::Client.new(token: test_okta_token, api_endpoint: 'https://okta-test.oktapreview.com/api/v1') - expect(client.api_endpoint).to eq('https://okta-test.oktapreview.com/api/v1') + expect(client.api_endpoint).to(eq('https://okta-test.oktapreview.com/api/v1')) end it 'raises ArgumentError when no organization or api_endpoint is provided' do - expect { Oktakit::Client.new(token: test_okta_token) }.to raise_error(ArgumentError) + expect { Oktakit::Client.new(token: test_okta_token) }.to(raise_error(ArgumentError)) end end @@ -36,14 +36,14 @@ 501 => Oktakit::NotImplemented, 502 => Oktakit::BadGateway, 503 => Oktakit::ServiceUnavailable, - 504 => Oktakit::ServerError + 504 => Oktakit::ServerError, } describe 'errors' do ERRORS.each do |code, error| it "raises a #{error} on #{code} responses" do - VCR.use_cassette code do - expect { client.get('/users/-1') }.to raise_error(error) + VCR.use_cassette(code) do + expect { client.get('/users/-1') }.to(raise_error(error)) end end end diff --git a/spec/pagination_spec.rb b/spec/pagination_spec.rb index f93f330..ba5f521 100644 --- a/spec/pagination_spec.rb +++ b/spec/pagination_spec.rb @@ -5,21 +5,21 @@ PAGED_APPS_APP_ID = '0oaYAubtaubhslaOg0x7' it 'should auto paginate' do - VCR.use_cassette 'pagination' do + VCR.use_cassette('pagination') do users, = client.list_users(paginate: true) - expect(users.size).to be == 10 + expect(users.size).to(be == 10) end end it 'should send query parameters in each page request' do - VCR.use_cassette 'pagination_with_query_params' do + VCR.use_cassette('pagination_with_query_params') do users, = client.list_users_assigned_to_application(PAGED_APPS_APP_ID, paginate: true, query: { expand: 'user', limit: '1' }) users.each do |user| - expect(user._embedded).not_to be_nil, "User #{user.id} was expected to have expanded user profile in _embedded" + expect(user._embedded).not_to(be_nil, "User #{user.id} was expected to have expanded user profile in _embedded") end - expect(users.size).to be == 3 + expect(users.size).to(be == 3) end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3db0b07..72db7d4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -15,7 +15,7 @@ def serializable_body(*) VCR.configure do |config| config.configure_rspec_metadata! config.cassette_library_dir = 'spec/cassettes/' - config.hook_into :faraday + config.hook_into(:faraday) config.filter_sensitive_data('<>') do test_okta_token end @@ -26,7 +26,7 @@ def serializable_body(*) end end -$LOAD_PATH.unshift File.expand_path('../lib', __dir__) +$LOAD_PATH.unshift(File.expand_path('../lib', __dir__)) require 'oktakit' module TestClient @@ -35,7 +35,7 @@ module TestClient end RSpec.configure do |config| - config.include TestClient + config.include(TestClient) end def test_okta_token