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/api/internal | |
parent | 0301a0cad0063d76b1607358dc6c711ea043fdda (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api/internal')
-rw-r--r-- | spec/requests/api/internal/base_spec.rb | 31 |
1 files changed, 18 insertions, 13 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 |