Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-05-15 16:53:18 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2016-05-15 16:53:18 +0300
commit3d18b3a0e7e69924d6a5cf39b180b1b133f8c9b0 (patch)
tree8bb913a8a3f6795e257d9e4fb4fdc02f0c616cdd /spec/services/auth
parentb575b2f1ef10c44a59151567aa1aa390f4a94ab1 (diff)
parentdfd0e2450aabc3b5c322c4a4382edb84caa7101b (diff)
Merge branch 'docker-registry' into docker-registry-view
Diffstat (limited to 'spec/services/auth')
-rw-r--r--spec/services/auth/container_registry_authentication_service_spec.rb43
1 files changed, 36 insertions, 7 deletions
diff --git a/spec/services/auth/container_registry_authentication_service_spec.rb b/spec/services/auth/container_registry_authentication_service_spec.rb
index bae576f1670..409d08e49f1 100644
--- a/spec/services/auth/container_registry_authentication_service_spec.rb
+++ b/spec/services/auth/container_registry_authentication_service_spec.rb
@@ -57,15 +57,28 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
end
end
- shared_examples 'a forbidden' do
+ shared_examples 'a unauthorized' do
it { is_expected.to include(http_status: 401) }
it { is_expected.to_not include(:token) }
end
+ shared_examples 'a forbidden' do
+ it { is_expected.to include(http_status: 403) }
+ it { is_expected.to_not include(:token) }
+ end
+
context 'user authorization' do
let(:project) { create(:project) }
let(:current_user) { create(:user) }
+ context 'allow to use offline_token' do
+ let(:current_params) do
+ { offline_token: true }
+ end
+
+ it_behaves_like 'an authenticated'
+ end
+
context 'allow developer to push images' do
before { project.team << [current_user, :developer] }
@@ -103,13 +116,21 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
{ scope: "repository:#{project.path_with_namespace}:pull,push" }
end
- it_behaves_like 'a forbidden'
+ it_behaves_like 'a unauthorized'
end
end
context 'project authorization' do
let(:current_project) { create(:empty_project) }
+ context 'disallow to use offline_token' do
+ let(:current_params) do
+ { offline_token: true }
+ end
+
+ it_behaves_like 'a forbidden'
+ end
+
context 'allow to pull and push images' do
let(:current_params) do
{ scope: "repository:#{current_project.path_with_namespace}:pull,push" }
@@ -133,7 +154,7 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
context 'disallow for private' do
let(:project) { create(:empty_project, :private) }
- it_behaves_like 'a forbidden'
+ it_behaves_like 'a unauthorized'
end
end
@@ -144,7 +165,7 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
context 'disallow for all' do
let(:project) { create(:empty_project, :public) }
- it_behaves_like 'a forbidden'
+ it_behaves_like 'a unauthorized'
end
end
end
@@ -165,12 +186,20 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
end
context 'unauthorized' do
+ context 'disallow to use offline_token' do
+ let(:current_params) do
+ { offline_token: true }
+ end
+
+ it_behaves_like 'a forbidden'
+ end
+
context 'for invalid scope' do
let(:current_params) do
{ scope: 'invalid:aa:bb' }
end
- it_behaves_like 'a forbidden'
+ it_behaves_like 'a unauthorized'
end
context 'for private project' do
@@ -180,7 +209,7 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
{ scope: "repository:#{project.path_with_namespace}:pull" }
end
- it_behaves_like 'a forbidden'
+ it_behaves_like 'a unauthorized'
end
context 'for public project' do
@@ -199,7 +228,7 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
{ scope: "repository:#{project.path_with_namespace}:push" }
end
- it_behaves_like 'a forbidden'
+ it_behaves_like 'a unauthorized'
end
end
end