Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
d8625611
Commit
d8625611
authored
Nov 18, 2016
by
rithu leena john
Committed by
GitHub
Nov 18, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #700 from ericchiang/fix-expiry-test-flake
server: fix expiry test flake
parents
a7db2957
5c602d36
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
server_test.go
server/server_test.go
+7
-3
No files found.
server/server_test.go
View file @
d8625611
...
@@ -137,7 +137,7 @@ func TestOAuth2CodeFlow(t *testing.T) {
...
@@ -137,7 +137,7 @@ func TestOAuth2CodeFlow(t *testing.T) {
clientSecret
:=
"testclientsecret"
clientSecret
:=
"testclientsecret"
requestedScopes
:=
[]
string
{
oidc
.
ScopeOpenID
,
"email"
,
"offline_access"
}
requestedScopes
:=
[]
string
{
oidc
.
ScopeOpenID
,
"email"
,
"offline_access"
}
t0
:=
time
.
Now
()
.
Round
(
time
.
Second
)
t0
:=
time
.
Now
()
// Always have the time function used by the server return the same time so
// Always have the time function used by the server return the same time so
// we can predict expected values of "expires_in" fields exactly.
// we can predict expected values of "expires_in" fields exactly.
...
@@ -171,7 +171,11 @@ func TestOAuth2CodeFlow(t *testing.T) {
...
@@ -171,7 +171,11 @@ func TestOAuth2CodeFlow(t *testing.T) {
handleToken
:
func
(
ctx
context
.
Context
,
p
*
oidc
.
Provider
,
config
*
oauth2
.
Config
,
token
*
oauth2
.
Token
)
error
{
handleToken
:
func
(
ctx
context
.
Context
,
p
*
oidc
.
Provider
,
config
*
oauth2
.
Config
,
token
*
oauth2
.
Token
)
error
{
expectedExpiry
:=
now
()
.
Add
(
idTokensValidFor
)
expectedExpiry
:=
now
()
.
Add
(
idTokensValidFor
)
if
!
token
.
Expiry
.
Round
(
time
.
Second
)
.
Equal
(
expectedExpiry
)
{
timeEq
:=
func
(
t1
,
t2
time
.
Time
,
within
time
.
Duration
)
bool
{
return
t1
.
Sub
(
t2
)
<
within
}
if
!
timeEq
(
token
.
Expiry
,
expectedExpiry
,
time
.
Second
)
{
return
fmt
.
Errorf
(
"expected expired_in to be %s, got %s"
,
expectedExpiry
,
token
.
Expiry
)
return
fmt
.
Errorf
(
"expected expired_in to be %s, got %s"
,
expectedExpiry
,
token
.
Expiry
)
}
}
...
@@ -183,7 +187,7 @@ func TestOAuth2CodeFlow(t *testing.T) {
...
@@ -183,7 +187,7 @@ func TestOAuth2CodeFlow(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to verify id token: %v"
,
err
)
return
fmt
.
Errorf
(
"failed to verify id token: %v"
,
err
)
}
}
if
!
idToken
.
Expiry
.
Round
(
time
.
Second
)
.
Equal
(
expectedExpiry
)
{
if
!
timeEq
(
idToken
.
Expiry
,
expectedExpiry
,
time
.
Second
)
{
return
fmt
.
Errorf
(
"expected id token expiry to be %s, got %s"
,
expectedExpiry
,
token
.
Expiry
)
return
fmt
.
Errorf
(
"expected id token expiry to be %s, got %s"
,
expectedExpiry
,
token
.
Expiry
)
}
}
return
nil
return
nil
...
...
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