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
bbaea52e
Commit
bbaea52e
authored
May 16, 2016
by
Bobby Rullo
Committed by
Frode Nordahl
May 26, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
alternate approach to fixing tests
parent
58f1bb45
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
13 deletions
+36
-13
invitation_test.go
server/invitation_test.go
+3
-3
session_test.go
session/session_test.go
+6
-6
email_verification_test.go
user/email_verification_test.go
+2
-2
password_test.go
user/password_test.go
+2
-2
user.go
user/user.go
+23
-0
No files found.
server/invitation_test.go
View file @
bbaea52e
...
...
@@ -159,9 +159,9 @@ func TestInvitationHandler(t *testing.T) {
t
.
Errorf
(
"case %d: password token is invalid: %v"
,
i
,
err
)
}
expTime
:=
pwrReset
.
Claims
[
"exp"
]
.
(
floa
t64
)
if
expTime
>
float64
(
tZero
.
Add
(
handler
.
redirectValidityWindow
)
.
Unix
()
)
||
expTime
<
float64
(
tZero
.
Unix
()
)
{
expTime
:=
pwrReset
.
Claims
[
"exp"
]
.
(
in
t64
)
if
expTime
>
tZero
.
Add
(
handler
.
redirectValidityWindow
)
.
Unix
(
)
||
expTime
<
tZero
.
Unix
(
)
{
t
.
Errorf
(
"case %d: funny expiration time detected: %d"
,
i
,
pwrReset
.
Claims
[
"exp"
])
}
...
...
session/session_test.go
View file @
bbaea52e
...
...
@@ -34,8 +34,8 @@ func TestSessionClaims(t *testing.T) {
"iss"
:
issuerURL
,
"sub"
:
"elroy-id"
,
"aud"
:
"XXX"
,
"iat"
:
float64
(
now
.
Unix
()
),
"exp"
:
float64
(
now
.
Add
(
time
.
Hour
)
.
Unix
()
),
"iat"
:
now
.
Unix
(
),
"exp"
:
now
.
Add
(
time
.
Hour
)
.
Unix
(
),
},
},
...
...
@@ -57,8 +57,8 @@ func TestSessionClaims(t *testing.T) {
"iss"
:
issuerURL
,
"sub"
:
"elroy-id"
,
"aud"
:
"XXX"
,
"iat"
:
float64
(
now
.
Unix
()
),
"exp"
:
float64
(
now
.
Add
(
time
.
Hour
)
.
Unix
()
),
"iat"
:
now
.
Unix
(
),
"exp"
:
now
.
Add
(
time
.
Hour
)
.
Unix
(
),
},
},
// Nonce gets propagated.
...
...
@@ -79,8 +79,8 @@ func TestSessionClaims(t *testing.T) {
"iss"
:
issuerURL
,
"sub"
:
"elroy-id"
,
"aud"
:
"XXX"
,
"iat"
:
float64
(
now
.
Unix
()
),
"exp"
:
float64
(
now
.
Add
(
time
.
Hour
)
.
Unix
()
),
"iat"
:
now
.
Unix
(
),
"exp"
:
now
.
Add
(
time
.
Hour
)
.
Unix
(
),
"nonce"
:
"oncenay"
,
},
},
...
...
user/email_verification_test.go
View file @
bbaea52e
...
...
@@ -45,9 +45,9 @@ func TestNewEmailVerification(t *testing.T) {
"aud"
:
clientID
,
ClaimEmailVerificationCallback
:
callback
,
ClaimEmailVerificationEmail
:
usr
.
Email
,
"exp"
:
float64
(
now
.
Add
(
expires
)
.
Unix
()
),
"exp"
:
now
.
Add
(
expires
)
.
Unix
(
),
"sub"
:
usr
.
ID
,
"iat"
:
float64
(
now
.
Unix
()
),
"iat"
:
now
.
Unix
(
),
},
},
}
...
...
user/password_test.go
View file @
bbaea52e
...
...
@@ -106,9 +106,9 @@ func TestNewPasswordReset(t *testing.T) {
"aud"
:
clientID
,
ClaimPasswordResetCallback
:
callback
,
ClaimPasswordResetPassword
:
string
(
password
),
"exp"
:
float64
(
now
.
Add
(
expires
)
.
Unix
()
),
"exp"
:
now
.
Add
(
expires
)
.
Unix
(
),
"sub"
:
usr
.
ID
,
"iat"
:
float64
(
now
.
Unix
()
),
"iat"
:
now
.
Unix
(
),
},
},
}
...
...
user/user.go
View file @
bbaea52e
...
...
@@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"math"
"time"
"net/mail"
...
...
@@ -259,5 +260,27 @@ func parseAndVerifyTokenClaims(token string, issuer url.URL, keys []key.PublicKe
return
TokenClaims
{},
err
}
timeClaimsToInt
(
claims
)
return
TokenClaims
{
claims
},
nil
}
// timeClaimsToInt converts float64 time claims to ints.
// This is unfortunately neccessary for interop as some clients incorrectly fail
// to marshal floats as times.
func
timeClaimsToInt
(
claims
jose
.
Claims
)
{
for
_
,
k
:=
range
[]
string
{
"exp"
,
"iat"
}
{
v
,
ok
:=
claims
[
k
]
if
!
ok
{
continue
}
fVal
,
ok
:=
v
.
(
float64
)
if
!
ok
{
continue
}
// round
claims
[
k
]
=
int64
(
fVal
+
math
.
Copysign
(
0.5
,
fVal
))
}
}
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