Skip to content

Commit

Permalink
tests: increased coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeneas Rekkas committed Jan 11, 2016
1 parent 269c5fa commit 83194b6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
6 changes: 6 additions & 0 deletions authorize_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ func TestAuthorizeRequest(t *testing.T) {
ar *AuthorizeRequest
isRedirValid bool
}{
{
ar: NewAuthorizeRequest(),
isRedirValid: false,
},
{
ar: &AuthorizeRequest{},
isRedirValid: false,
Expand Down Expand Up @@ -83,6 +87,8 @@ func TestAuthorizeRequest(t *testing.T) {
assert.Equal(t, c.ar.State, c.ar.GetState(), "%d", k)
assert.Equal(t, c.isRedirValid, c.ar.IsRedirectURIValid(), "%d", k)
c.ar.GrantScope("foo")
c.ar.SetScopes([]string{"foo"})
assert.True(t, c.ar.GetGrantedScopes().Has("foo"))
assert.True(t, c.ar.GetScopes().Has("foo"))
}
}
8 changes: 8 additions & 0 deletions fosite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@ func TestAuthorizeEndpointHandlers(t *testing.T) {
assert.Len(t, hs, 1)
assert.Equal(t, hs["k"], h)
}

func TestTokenEndpointHandlers(t *testing.T) {
h := &explicit.AuthorizeExplicitEndpointHandler{}
hs := TokenEndpointHandlers{}
hs.Add("k", h)
assert.Len(t, hs, 1)
assert.Equal(t, hs["k"], h)
}
15 changes: 5 additions & 10 deletions oauth2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,11 @@ func TestFosite(t *testing.T) {
Enigma: &enigma.HMACSHAEnigma{GlobalSecret: []byte("super-global-secret")},
Store: mockAuthStore,
}
oauth2 := &Fosite{
Store: mockStore,
Hasher: mockHasher,
AuthorizeEndpointHandlers: AuthorizeEndpointHandlers{
"code": authExplicitHandler,
},
TokenEndpointHandlers: TokenEndpointHandlers{
"code": authExplicitHandler,
},
}

oauth2 := NewFosite(mockStore)
oauth2.Hasher = mockHasher
oauth2.AuthorizeEndpointHandlers.Add("code", authExplicitHandler)
oauth2.TokenEndpointHandlers.Add("code", authExplicitHandler)

oauth2TestAuthorizeCodeWorkFlow(oauth2, t, func() {
mockStore = NewMockStorage(ctrl)
Expand Down

0 comments on commit 83194b6

Please sign in to comment.