summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-05-31 15:23:54 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2016-06-02 13:39:56 +0200
commit1d94757c1a0305a7cd9a053d5c9ed21bd5d056dc (patch)
treec8a1629fb596f11a9a2da73f804df187cc867b1d /spec
parent0df4fa78e7e9a41f3d057eb13b8a9bd014a6e9ff (diff)
downloadgitlab-ce-1d94757c1a0305a7cd9a053d5c9ed21bd5d056dc.tar.gz
Merge branch 'container-registry-token-ttl' into 'master'
Add Application Setting to configure Container Registry token expire delay (default 5min) This adds an option to configure Container Registry token expire delay. The default is set to 5mins (something that is also used by Docker Hub). What is left: * [x] Write test to check the expire_delay Fixes: https://gitlab.com/gitlab-org/gitlab-ce/issues/17890 @stanhu I think that this should land in patch release of 8.8. See merge request !4364
Diffstat (limited to 'spec')
-rw-r--r--spec/services/auth/container_registry_authentication_service_spec.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/services/auth/container_registry_authentication_service_spec.rb b/spec/services/auth/container_registry_authentication_service_spec.rb
index 11858301844..4d4f5a0a303 100644
--- a/spec/services/auth/container_registry_authentication_service_spec.rb
+++ b/spec/services/auth/container_registry_authentication_service_spec.rb
@@ -17,6 +17,21 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
shared_examples 'a valid token' do
it { is_expected.to include(:token) }
it { expect(payload).to include('access') }
+
+ context 'a expirable' do
+ let(:expires_at) { Time.at(payload['exp']) }
+ let(:expire_delay) { 10 }
+
+ context 'for default configuration' do
+ it { expect(expires_at).not_to be_within(2.seconds).of(Time.now + expire_delay.minutes) }
+ end
+
+ context 'for changed configuration' do
+ before { stub_application_setting(container_registry_token_expire_delay: expire_delay) }
+
+ it { expect(expires_at).to be_within(2.seconds).of(Time.now + expire_delay.minutes) }
+ end
+ end
end
shared_examples 'a accessible' do