Commit 2a0cccc1 authored by Douwe Maan's avatar Douwe Maan

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
parents fbeaa751 cfd0d66c
......@@ -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')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment