Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
63ade4b8
Commit
63ade4b8
authored
Jul 12, 2019
by
Etienne Baqué
Committed by
Stan Hu
Aug 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added EncryptDeployTokensTokens spec file
parent
3394c653
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
spec/migrations/encrypt_deploy_tokens_tokens_spec.rb
spec/migrations/encrypt_deploy_tokens_tokens_spec.rb
+47
-0
No files found.
spec/migrations/encrypt_deploy_tokens_tokens_spec.rb
0 → 100644
View file @
63ade4b8
# frozen_string_literal: true
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20190711201818_encrypt_deploy_tokens_tokens.rb'
)
describe
EncryptDeployTokensTokens
,
:migration
do
let
(
:migration
)
{
described_class
.
new
}
let
(
:deployment_tokens
)
{
table
(
:deploy_tokens
)
}
let
(
:plaintext
)
{
"secret-token"
}
let
(
:expires_at
)
{
DateTime
.
now
+
1
.
year
}
let
(
:ciphertext
)
{
Gitlab
::
CryptoHelper
.
aes256_gcm_encrypt
(
plaintext
)
}
describe
'#up'
do
it
'keeps plaintext token the same and populates token_encrypted if not present'
do
deploy_token
=
deployment_tokens
.
create!
(
name:
'test_token'
,
read_repository:
true
,
expires_at:
expires_at
,
username:
'gitlab-token-1'
,
token:
plaintext
)
migration
.
up
expect
(
deploy_token
.
reload
.
token
).
to
eq
(
plaintext
)
expect
(
deploy_token
.
reload
.
token_encrypted
).
to
eq
(
ciphertext
)
end
end
describe
'#down'
do
it
'decrypts encrypted token and saves it'
do
deploy_token
=
deployment_tokens
.
create!
(
name:
'test_token'
,
read_repository:
true
,
expires_at:
expires_at
,
username:
'gitlab-token-1'
,
token_encrypted:
ciphertext
)
migration
.
down
expect
(
deploy_token
.
reload
.
token
).
to
eq
(
plaintext
)
expect
(
deploy_token
.
reload
.
token_encrypted
).
to
eq
(
ciphertext
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment