diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
commit | 0c872e02b2c822e3397515ec324051ff540f0cd5 (patch) | |
tree | ce2fb6ce7030e4dad0f4118d21ab6453e5938cdd /spec/requests/api/users_spec.rb | |
parent | f7e05a6853b12f02911494c4b3fe53d9540d74fc (diff) |
Add latest changes from gitlab-org/gitlab@15-7-stable-eev15.7.0-rc42
Diffstat (limited to 'spec/requests/api/users_spec.rb')
-rw-r--r-- | spec/requests/api/users_spec.rb | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index 6688a998a1a..bfb71d95f5e 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe API::Users do +RSpec.describe API::Users, feature_category: :users do include WorkhorseHelpers let_it_be(:admin) { create(:admin) } @@ -1988,11 +1988,19 @@ RSpec.describe API::Users do expect(json_response['error']).to eq('title is missing') end - it "creates ssh key" do - key_attrs = attributes_for :key + it "creates ssh key", :aggregate_failures do + key_attrs = attributes_for(:key, usage_type: :signing) + expect do post api("/users/#{user.id}/keys", admin), params: key_attrs end.to change { user.keys.count }.by(1) + + expect(response).to have_gitlab_http_status(:created) + + key = user.keys.last + expect(key.title).to eq(key_attrs[:title]) + expect(key.key).to eq(key_attrs[:key]) + expect(key.usage_type).to eq(key_attrs[:usage_type].to_s) end it 'creates SSH key with `expires_at` attribute' do @@ -2848,12 +2856,19 @@ RSpec.describe API::Users do end describe "POST /user/keys" do - it "creates ssh key" do - key_attrs = attributes_for :key + it "creates ssh key", :aggregate_failures do + key_attrs = attributes_for(:key, usage_type: :signing) + expect do post api("/user/keys", user), params: key_attrs end.to change { user.keys.count }.by(1) + expect(response).to have_gitlab_http_status(:created) + + key = user.keys.last + expect(key.title).to eq(key_attrs[:title]) + expect(key.key).to eq(key_attrs[:key]) + expect(key.usage_type).to eq(key_attrs[:usage_type].to_s) end it 'creates SSH key with `expires_at` attribute' do |