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
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-10-14 13:57:18 +0300
committerDouwe Maan <douwe@gitlab.com>2016-10-14 13:57:18 +0300
commit2a0cccc13e37669e9488b955e6006a30562651be (patch)
tree41a1f5dea238d18360ddb5a0b8b80f72e2eaf3a7 /lib
parentfbeaa7518d8cf86ad62e94e9bc86ffe63715dffd (diff)
parentcfd0d66c8308c0f259e39322193c8ddb34ec28f9 (diff)
Merge branch 'fix/reassign-secret-token-on-generate' into 'master'
Reassign secret token when regenerating one ## What does this MR do? This is an attempt to fix intermittent errors in out test suite. ```text Failures: 1) Gitlab::Shell memoized secret_token creates and links the secret token file Failure/Error: expect(File.read(secret_file).chomp).to eq(secret_token) expected: "690f959e206ab91acc54e1c605c7ff90" got: "cccb4e8df9360600271e61114d4e6e68" (compared using ==) # ./spec/lib/gitlab/backend/shell_spec.rb:47:in `block (3 levels) in <top (required)>' ``` It appears that `spec/lib/gitlab/backend/shell_spec.rb` tries to change the file that stores secret token, but `Gitlab::Shell` memoizes `@secret_token` on class level, so when it was already created by other tests (`spec/requests/api/internal_spec.rb` in this case), memoized token is not reassigned even if it was generated again with `ensure_secret_token!`. See merge request !6844
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/backend/shell.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/gitlab/backend/shell.rb b/lib/gitlab/backend/shell.rb
index d0060fbaca1..9cec71a3222 100644
--- a/lib/gitlab/backend/shell.rb
+++ b/lib/gitlab/backend/shell.rb
@@ -47,8 +47,8 @@ module Gitlab
unless File.size?(secret_file)
# Generate a new token of 16 random hexadecimal characters and store it in secret_file.
- token = SecureRandom.hex(16)
- File.write(secret_file, token)
+ @secret_token = SecureRandom.hex(16)
+ File.write(secret_file, @secret_token)
end
link_path = File.join(shell_path, '.gitlab_shell_secret')