diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-10-06 16:14:14 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-10-06 16:14:14 +0200 |
commit | f9d490dbb910cdd05ca0a0fa38331708181e4b1e (patch) | |
tree | 0329bd87db08ee068d816646adfd48f8b623d608 /spec | |
parent | 3e26b0dcd113ade77dc8304137c6733cab4c8718 (diff) | |
download | gitlab-ce-f9d490dbb910cdd05ca0a0fa38331708181e4b1e.tar.gz |
Improve redirect uri state and fix all remaining tests
Diffstat (limited to 'spec')
4 files changed, 19 insertions, 26 deletions
diff --git a/spec/controllers/google_api/authorizations_controller_spec.rb b/spec/controllers/google_api/authorizations_controller_spec.rb index 253cfab64d1..80d553f0f34 100644 --- a/spec/controllers/google_api/authorizations_controller_spec.rb +++ b/spec/controllers/google_api/authorizations_controller_spec.rb @@ -24,20 +24,19 @@ describe GoogleApi::AuthorizationsController do .to eq(expires_at) end - context 'when second redirection url key is stored in state' do + context 'when redirect uri key is stored in state' do set(:project) { create(:project) } - let(:second_redirect_uri) { project_clusters_url(project).to_s } + let(:redirect_uri) { project_clusters_url(project).to_s } before do - GoogleApi::CloudPlatform::Client - .session_key_for_second_redirect_uri.tap do |key, secure| - @state = secure - session[key] = second_redirect_uri + @state = GoogleApi::CloudPlatform::Client + .new_session_key_for_redirect_uri do |key| + session[key] = redirect_uri end end it 'redirects to the URL stored in state param' do - expect(subject).to redirect_to(second_redirect_uri) + expect(subject).to redirect_to(redirect_uri) end end diff --git a/spec/controllers/projects/clusters_controller_spec.rb b/spec/controllers/projects/clusters_controller_spec.rb index b34702370e8..7985028d73b 100644 --- a/spec/controllers/projects/clusters_controller_spec.rb +++ b/spec/controllers/projects/clusters_controller_spec.rb @@ -190,7 +190,7 @@ describe Projects::ClustersController do subject expect(response).to have_http_status(:ok) - expect(response.body).to include("Save changes") + expect(response.body).to include("Save") end it "allows remove integration" do diff --git a/spec/features/projects/clusters_spec.rb b/spec/features/projects/clusters_spec.rb index 7f33629c938..810f2c39b43 100644 --- a/spec/features/projects/clusters_spec.rb +++ b/spec/features/projects/clusters_spec.rb @@ -69,14 +69,14 @@ feature 'Clusters', :js do end it 'user sees an cluster details page' do - expect(page).to have_button('Save changes') + expect(page).to have_button('Save') expect(page.find(:css, '.cluster-name').value).to eq(cluster.gcp_cluster_name) end context 'when user disables the cluster' do before do page.find(:css, '.js-toggle-cluster').click - click_button 'Save changes' + click_button 'Save' end it 'user sees the succeccful message' do diff --git a/spec/lib/google_api/cloud_platform/client_spec.rb b/spec/lib/google_api/cloud_platform/client_spec.rb index e770f2e9edc..acc5bd1da35 100644 --- a/spec/lib/google_api/cloud_platform/client_spec.rb +++ b/spec/lib/google_api/cloud_platform/client_spec.rb @@ -4,26 +4,20 @@ describe GoogleApi::CloudPlatform::Client do let(:token) { 'token' } let(:client) { described_class.new(token, nil) } - describe '.session_key_for_second_redirect_uri' do - subject { described_class.session_key_for_second_redirect_uri(secure: secure) } + describe '.session_key_for_redirect_uri' do + let(:state) { 'random_string' } - context 'when pass a postfix' do - let(:secure) { SecureRandom.hex } + subject { described_class.session_key_for_redirect_uri(state) } - it 'creates a required session key' do - key, _ = described_class.session_key_for_second_redirect_uri(secure: secure) - expect(key).to eq("cloud_platform_second_redirect_uri_#{secure}") - end + it 'creates a new session key' do + is_expected.to eq('cloud_platform_second_redirect_uri_random_string') end + end - context 'when pass a postfix' do - let(:secure) { nil } - - it 'creates a new session key' do - key, secure = described_class.session_key_for_second_redirect_uri - expect(key).to include('cloud_platform_second_redirect_uri_') - expect(secure).not_to be_nil - end + describe '.new_session_key_for_redirect_uri' do + it 'generates a new session key' do + expect { |b| described_class.new_session_key_for_redirect_uri(&b) } + .to yield_with_args(String) end end |