diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-10 14:52:44 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-10 14:52:44 +0000 |
commit | 86a8eee1b8bd43a1fe962905eb97a1f478cc050b (patch) | |
tree | 439816bbaf4a0caf16d579223eb9465e0b0daebc /spec | |
parent | 1b517a5a19c4aafc6fa6d738b0ee7c1e4a2cce36 (diff) | |
download | gitlab-ce-86a8eee1b8bd43a1fe962905eb97a1f478cc050b.tar.gz |
Add latest changes from gitlab-org/gitlab@13-6-stable-ee
Diffstat (limited to 'spec')
-rw-r--r-- | spec/config/object_store_settings_spec.rb | 1 | ||||
-rw-r--r-- | spec/frontend/registry/explorer/utils_spec.js | 17 | ||||
-rw-r--r-- | spec/frontend/vue_mr_widget/mr_widget_options_spec.js | 14 | ||||
-rw-r--r-- | spec/helpers/members_helper_spec.rb | 10 | ||||
-rw-r--r-- | spec/lib/gitlab/middleware/handle_malformed_strings_spec.rb | 7 | ||||
-rw-r--r-- | spec/requests/api/invitations_spec.rb | 8 | ||||
-rw-r--r-- | spec/requests/git_http_spec.rb | 14 | ||||
-rw-r--r-- | spec/services/members/invite_service_spec.rb | 11 |
8 files changed, 74 insertions, 8 deletions
diff --git a/spec/config/object_store_settings_spec.rb b/spec/config/object_store_settings_spec.rb index 430ba1205cb..1777213f481 100644 --- a/spec/config/object_store_settings_spec.rb +++ b/spec/config/object_store_settings_spec.rb @@ -88,6 +88,7 @@ RSpec.describe ObjectStoreSettings do config['object_store']['objects']['pages'].delete('bucket') expect { subject }.not_to raise_error + expect(settings.pages['object_store']).to eq(nil) end context 'with legacy config' do diff --git a/spec/frontend/registry/explorer/utils_spec.js b/spec/frontend/registry/explorer/utils_spec.js index 0cd4a1cec29..7a5d6958a09 100644 --- a/spec/frontend/registry/explorer/utils_spec.js +++ b/spec/frontend/registry/explorer/utils_spec.js @@ -8,6 +8,10 @@ describe('Utils', () => { id: 1, }; + beforeEach(() => { + window.gon.relative_url_root = null; + }); + it('returns the fetch url when no ending is passed', () => { expect(pathGenerator(imageDetails)).toBe('/foo/bar/registry/repository/1/tags?format=json'); }); @@ -16,7 +20,7 @@ describe('Utils', () => { expect(pathGenerator(imageDetails, '/foo')).toBe('/foo/bar/registry/repository/1/tags/foo'); }); - it.each` + describe.each` path | name | result ${'foo/foo'} | ${''} | ${'/foo/foo/registry/repository/1/tags?format=json'} ${'foo/foo/foo'} | ${'foo'} | ${'/foo/foo/registry/repository/1/tags?format=json'} @@ -26,8 +30,15 @@ describe('Utils', () => { ${'foo/foo/baz/foo/bar'} | ${'foo/bar'} | ${'/foo/foo/baz/registry/repository/1/tags?format=json'} ${'baz/foo/foo'} | ${'foo'} | ${'/baz/foo/registry/repository/1/tags?format=json'} ${'baz/foo/bar'} | ${'foo'} | ${'/baz/foo/bar/registry/repository/1/tags?format=json'} - `('returns the correct path when path is $path and name is $name', ({ name, path, result }) => { - expect(pathGenerator({ id: 1, name, path })).toBe(result); + `('when path is $path and name is $name', ({ name, path, result }) => { + it('returns the correct value', () => { + expect(pathGenerator({ id: 1, name, path })).toBe(result); + }); + + it('produces a correct relative url', () => { + window.gon.relative_url_root = '/gitlab'; + expect(pathGenerator({ id: 1, name, path })).toBe(`/gitlab${result}`); + }); }); it('returns the url unchanged when imageDetails have no name', () => { diff --git a/spec/frontend/vue_mr_widget/mr_widget_options_spec.js b/spec/frontend/vue_mr_widget/mr_widget_options_spec.js index d6f85dcfcc7..cb0006548d4 100644 --- a/spec/frontend/vue_mr_widget/mr_widget_options_spec.js +++ b/spec/frontend/vue_mr_widget/mr_widget_options_spec.js @@ -260,6 +260,20 @@ describe('mrWidgetOptions', () => { }); }); }); + + describe('formattedHumanAccess', () => { + it('when user is a tool admin but not a member of project', () => { + vm.mr.humanAccess = null; + + expect(vm.formattedHumanAccess).toEqual(''); + }); + + it('when user a member of the project', () => { + vm.mr.humanAccess = 'Owner'; + + expect(vm.formattedHumanAccess).toEqual('owner'); + }); + }); }); describe('methods', () => { diff --git a/spec/helpers/members_helper_spec.rb b/spec/helpers/members_helper_spec.rb index 84b3f99b89a..c671379c4b4 100644 --- a/spec/helpers/members_helper_spec.rb +++ b/spec/helpers/members_helper_spec.rb @@ -33,6 +33,16 @@ RSpec.describe MembersHelper do expect(remove_member_message(group_member_invite)).to eq "Are you sure you want to remove this orphaned member from the #{group.name} group and any subresources?" end end + + context 'a pending member invitation with no user associated' do + before do + project_member_invite.update_columns(invite_email: "#{SecureRandom.hex}@example.com", invite_token: 'some-token', user_id: nil) + end + + it 'does not error when there is an invitation for the requestor' do + expect(remove_member_message(project_member_invite)).to eq "Are you sure you want to revoke the invitation for #{project_member_invite.invite_email} to join the #{project.full_name} project?" + end + end end describe '#remove_member_title' do diff --git a/spec/lib/gitlab/middleware/handle_malformed_strings_spec.rb b/spec/lib/gitlab/middleware/handle_malformed_strings_spec.rb index e806f6478b7..cf7b0dbb5fd 100644 --- a/spec/lib/gitlab/middleware/handle_malformed_strings_spec.rb +++ b/spec/lib/gitlab/middleware/handle_malformed_strings_spec.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true - require 'spec_helper' require "rack/test" @@ -104,6 +103,12 @@ RSpec.describe Gitlab::Middleware::HandleMalformedStrings do expect(subject.call(env)).not_to eq error_400 end + + it 'does not reject correct encoded password with special characters' do + env = env_for.merge(auth_env("username", "RçKszEwéC5kFnû∆f243fycGu§Gh9ftDj!U", nil)) + + expect(subject.call(env)).not_to eq error_400 + end end context 'in params' do diff --git a/spec/requests/api/invitations_spec.rb b/spec/requests/api/invitations_spec.rb index 75586970abb..aeb8e3642ed 100644 --- a/spec/requests/api/invitations_spec.rb +++ b/spec/requests/api/invitations_spec.rb @@ -58,7 +58,7 @@ RSpec.describe API::Invitations do it 'does not transform the requester into a proper member' do expect do post api("/#{source_type.pluralize}/#{source.id}/invitations", maintainer), - params: { email: email, access_level: Member::MAINTAINER } + params: { email: access_requester.email, access_level: Member::MAINTAINER } expect(response).to have_gitlab_http_status(:created) end.not_to change { source.members.count } @@ -71,7 +71,7 @@ RSpec.describe API::Invitations do params: { email: email, access_level: Member::DEVELOPER } expect(response).to have_gitlab_http_status(:created) - end.to change { source.requesters.count }.by(1) + end.to change { source.members.invite.count }.by(1) end it 'invites a list of new email addresses' do @@ -82,7 +82,7 @@ RSpec.describe API::Invitations do params: { email: email_list, access_level: Member::DEVELOPER } expect(response).to have_gitlab_http_status(:created) - end.to change { source.requesters.count }.by(2) + end.to change { source.members.invite.count }.by(2) end end @@ -140,7 +140,7 @@ RSpec.describe API::Invitations do it 'invites a member' do expect do subject - end.to change { source.requesters.count }.by(1) + end.to change { source.members.invite.count }.by(1) expect(response).to have_gitlab_http_status(:created) end diff --git a/spec/requests/git_http_spec.rb b/spec/requests/git_http_spec.rb index dc735e3714d..32aeeed43b6 100644 --- a/spec/requests/git_http_spec.rb +++ b/spec/requests/git_http_spec.rb @@ -280,6 +280,20 @@ RSpec.describe 'Git HTTP requests' do project.add_developer(user) end + context 'when user is using credentials with special characters' do + context 'with password with special characters' do + before do + user.update!(password: 'RKszEwéC5kFnû∆f243fycGu§Gh9ftDj!U') + end + + it 'allows clones' do + download(path, user: user.username, password: user.password) do |response| + expect(response).to have_gitlab_http_status(:ok) + end + end + end + end + context 'but the repo is disabled' do let(:project) { create(:project, :wiki_repo, :private, :repository_disabled, :wiki_enabled) } diff --git a/spec/services/members/invite_service_spec.rb b/spec/services/members/invite_service_spec.rb index 12a1a54696b..08cdf0d3ae1 100644 --- a/spec/services/members/invite_service_spec.rb +++ b/spec/services/members/invite_service_spec.rb @@ -63,4 +63,15 @@ RSpec.describe Members::InviteService do expect(result[:status]).to eq(:error) expect(result[:message][invited_member.invite_email]).to eq("Member already invited to #{project.name}") end + + it 'does not add a member with an access_request' do + requested_member = create(:project_member, :access_request, project: project) + + params = { email: requested_member.user.email, + access_level: Gitlab::Access::GUEST } + result = described_class.new(user, params).execute(project) + + expect(result[:status]).to eq(:error) + expect(result[:message][requested_member.user.email]).to eq("Member cannot be invited because they already requested to join #{project.name}") + end end |