diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-13 12:09:23 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-13 12:09:23 +0300 |
commit | 4cb5e5011abfe8d50ac3a7ebd0018c563c6d7af4 (patch) | |
tree | 82591df15758864325897043f855b4e4dfcb6a56 /spec/requests | |
parent | 0301a0cad0063d76b1607358dc6c711ea043fdda (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/internal/base_spec.rb | 31 | ||||
-rw-r--r-- | spec/requests/api/keys_spec.rb | 3 |
2 files changed, 20 insertions, 14 deletions
diff --git a/spec/requests/api/internal/base_spec.rb b/spec/requests/api/internal/base_spec.rb index 95513776f39..be592ac6a5c 100644 --- a/spec/requests/api/internal/base_spec.rb +++ b/spec/requests/api/internal/base_spec.rb @@ -575,30 +575,35 @@ describe API::Internal::Base do project.add_developer(user) end - context "git pull" do - context "with no console message" do - it "has the correct payload" do + context 'git pull' do + context 'with a key that has expired' do + let(:key) { create(:key, user: user, expires_at: 2.days.ago) } + + it 'includes the `key expired` message in the response' do pull(key, project) expect(response).to have_gitlab_http_status(:ok) - expect(json_response['gl_console_messages']).to eq([]) + expect(json_response['gl_console_messages']).to eq(['INFO: Your SSH key has expired. Please generate a new key.']) end end - context "with a console message" do - let(:console_messages) { ['message for the console'] } + context 'with a key that will expire in the next 7 days' do + let(:key) { create(:key, user: user, expires_at: 2.days.from_now) } - it "has the correct payload" do - expect_next_instance_of(Gitlab::GitAccess) do |access| - expect(access).to receive(:check_for_console_messages) - .with('git-upload-pack') - .and_return(console_messages) - end + it 'includes the `key expiring soon` message in the response' do + pull(key, project) + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['gl_console_messages']).to eq(['INFO: Your SSH key is expiring soon. Please generate a new key.']) + end + end + + context 'with a key that has no expiry' do + it 'does not include any message in the response' do pull(key, project) expect(response).to have_gitlab_http_status(:ok) - expect(json_response['gl_console_messages']).to eq(console_messages) + expect(json_response['gl_console_messages']).to eq([]) end end end diff --git a/spec/requests/api/keys_spec.rb b/spec/requests/api/keys_spec.rb index df0bae603b1..089ee22982c 100644 --- a/spec/requests/api/keys_spec.rb +++ b/spec/requests/api/keys_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' describe API::Keys do let(:user) { create(:user) } let(:admin) { create(:admin) } - let(:key) { create(:key, user: user) } + let(:key) { create(:key, user: user, expires_at: 1.day.from_now) } let(:email) { create(:email, user: user) } describe 'GET /keys/:uid' do @@ -28,6 +28,7 @@ describe API::Keys do get api("/keys/#{key.id}", admin) expect(response).to have_gitlab_http_status(:ok) expect(json_response['title']).to eq(key.title) + expect(Time.parse(json_response['expires_at'])).to be_like_time(key.expires_at) expect(json_response['user']['id']).to eq(user.id) expect(json_response['user']['username']).to eq(user.username) end |