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
ce8b0a4c
Commit
ce8b0a4c
authored
Oct 16, 2015
by
Joe Bowers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: fix user tests with for new behavior
parent
85113748
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
9 deletions
+19
-9
email_verification_test.go
user/email_verification_test.go
+5
-4
password_test.go
user/password_test.go
+14
-5
No files found.
user/email_verification_test.go
View file @
ce8b0a4c
...
...
@@ -59,7 +59,7 @@ func TestNewEmailVerification(t *testing.T) {
}
ev
:=
NewEmailVerification
(
tt
.
user
,
tt
.
clientID
,
tt
.
issuer
,
*
cbURL
,
tt
.
expires
)
if
diff
:=
pretty
.
Compare
(
tt
.
want
,
ev
.
c
laims
);
diff
!=
""
{
if
diff
:=
pretty
.
Compare
(
tt
.
want
,
ev
.
C
laims
);
diff
!=
""
{
t
.
Errorf
(
"case %d: Compare(want, got): %v"
,
i
,
diff
)
}
...
...
@@ -127,10 +127,11 @@ func TestEmailVerificationParseAndVerify(t *testing.T) {
for
i
,
tt
:=
range
tests
{
token
,
err
:=
tt
.
ev
.
Token
(
tt
.
signer
)
jwt
,
err
:=
jose
.
NewSignedJWT
(
tt
.
ev
.
Claims
,
tt
.
signer
)
if
err
!=
nil
{
t
.
Errorf
(
"case %d: non-nil error creating token: %v"
,
i
,
err
)
t
.
Fatalf
(
"Failed to generate JWT, error=%v"
,
err
)
}
token
:=
jwt
.
Encode
()
ev
,
err
:=
ParseAndVerifyEmailVerificationToken
(
token
,
*
issuer
,
[]
key
.
PublicKey
{
*
key
.
NewPublicKey
(
privKey
.
JWK
())})
...
...
@@ -148,7 +149,7 @@ func TestEmailVerificationParseAndVerify(t *testing.T) {
}
if
diff
:=
pretty
.
Compare
(
tt
.
ev
.
claims
,
ev
.
c
laims
);
diff
!=
""
{
if
diff
:=
pretty
.
Compare
(
tt
.
ev
.
Claims
,
ev
.
C
laims
);
diff
!=
""
{
t
.
Errorf
(
"case %d: Compare(want, got): %v"
,
i
,
diff
)
}
}
...
...
user/password_test.go
View file @
ce8b0a4c
...
...
@@ -124,7 +124,7 @@ func TestNewPasswordReset(t *testing.T) {
}
ev
:=
NewPasswordReset
(
tt
.
user
,
tt
.
password
,
tt
.
issuer
,
tt
.
clientID
,
*
cbURL
,
tt
.
expires
)
if
diff
:=
pretty
.
Compare
(
tt
.
want
,
ev
.
c
laims
);
diff
!=
""
{
if
diff
:=
pretty
.
Compare
(
tt
.
want
,
ev
.
C
laims
);
diff
!=
""
{
t
.
Errorf
(
"case %d: Compare(want, got): %v"
,
i
,
diff
)
}
...
...
@@ -145,12 +145,13 @@ func TestPasswordResetParseAndVerify(t *testing.T) {
password
:=
Password
(
"passy"
)
goodPR
:=
NewPasswordReset
(
user
,
password
,
*
issuer
,
client
,
*
callback
,
expires
)
goodPRNoCB
:=
NewPasswordReset
(
user
,
password
,
*
issuer
,
""
,
url
.
URL
{},
expires
)
goodPRNoCB
:=
NewPasswordReset
(
user
,
password
,
*
issuer
,
client
,
url
.
URL
{},
expires
)
expiredPR
:=
NewPasswordReset
(
user
,
password
,
*
issuer
,
client
,
*
callback
,
-
expires
)
wrongIssuerPR
:=
NewPasswordReset
(
user
,
password
,
*
otherIssuer
,
client
,
*
callback
,
expires
)
noSubPR
:=
NewPasswordReset
(
User
{},
password
,
*
issuer
,
client
,
*
callback
,
expires
)
noPWPR
:=
NewPasswordReset
(
user
,
Password
(
""
),
*
issuer
,
client
,
*
callback
,
expires
)
noClientPR
:=
NewPasswordReset
(
user
,
password
,
*
issuer
,
""
,
*
callback
,
expires
)
noClientNoCBPR
:=
NewPasswordReset
(
user
,
password
,
*
issuer
,
""
,
url
.
URL
{},
expires
)
privKey
,
err
:=
key
.
GeneratePrivateKey
()
if
err
!=
nil
{
...
...
@@ -211,14 +212,22 @@ func TestPasswordResetParseAndVerify(t *testing.T) {
signer
:
signer
,
wantErr
:
true
,
},
{
ev
:
noClientNoCBPR
,
signer
:
signer
,
wantErr
:
true
,
},
}
for
i
,
tt
:=
range
tests
{
token
,
err
:=
tt
.
ev
.
Token
(
tt
.
signer
)
t
.
Logf
(
"TODO claims are %v"
,
tt
.
ev
.
Claims
)
jwt
,
err
:=
jose
.
NewSignedJWT
(
tt
.
ev
.
Claims
,
tt
.
signer
)
if
err
!=
nil
{
t
.
Errorf
(
"case %d: non-nil error creating token: %v"
,
i
,
err
)
t
.
Fatalf
(
"Failed to generate JWT, error=%v"
,
err
)
}
token
:=
jwt
.
Encode
()
ev
,
err
:=
ParseAndVerifyPasswordResetToken
(
token
,
*
issuer
,
[]
key
.
PublicKey
{
*
key
.
NewPublicKey
(
privKey
.
JWK
())})
...
...
@@ -236,7 +245,7 @@ func TestPasswordResetParseAndVerify(t *testing.T) {
}
if
diff
:=
pretty
.
Compare
(
tt
.
ev
.
claims
,
ev
.
c
laims
);
diff
!=
""
{
if
diff
:=
pretty
.
Compare
(
tt
.
ev
.
Claims
,
ev
.
C
laims
);
diff
!=
""
{
t
.
Errorf
(
"case %d: Compare(want, got): %v"
,
i
,
diff
)
}
}
...
...
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