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
a6268d30
Commit
a6268d30
authored
Aug 02, 2018
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix deploy tokens without `expire_at` crashes
parent
367e7520
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
app/models/deploy_token.rb
app/models/deploy_token.rb
+7
-1
spec/models/deploy_token_spec.rb
spec/models/deploy_token_spec.rb
+8
-0
No files found.
app/models/deploy_token.rb
View file @
a6268d30
...
...
@@ -30,7 +30,7 @@ class DeployToken < ActiveRecord::Base
end
def
active?
!
revoked
&&
expires_at
>
Date
.
today
!
revoked
&&
!
expired?
end
def
scopes
...
...
@@ -63,6 +63,12 @@ class DeployToken < ActiveRecord::Base
private
def
expired?
return
false
unless
expires_at
expires_at
<
Date
.
today
end
def
ensure_at_least_one_scope
errors
.
add
(
:base
,
"Scopes can't be blank"
)
unless
read_repository
||
read_registry
end
...
...
spec/models/deploy_token_spec.rb
View file @
a6268d30
...
...
@@ -74,6 +74,14 @@ describe DeployToken do
expect
(
deploy_token
.
active?
).
to
be_falsy
end
end
context
"when it hasn't been revoked and has no expiry"
do
let
(
:deploy_token
)
{
create
(
:deploy_token
,
expires_at:
nil
)
}
it
'should return true'
do
expect
(
deploy_token
.
active?
).
to
be_truthy
end
end
end
describe
'#username'
do
...
...
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