Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeneas Rekkas committed Jan 17, 2016
1 parent 3e3bc96 commit ea5d75e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions handler/core/explicit/explicit_token_test.go
Expand Up @@ -19,13 +19,15 @@ func TestHandleTokenEndpointRequest(t *testing.T) {
store := internal.NewMockAuthorizeCodeGrantStorage(ctrl)
ach := internal.NewMockAccessTokenStrategy(ctrl)
rch := internal.NewMockRefreshTokenStrategy(ctrl)
auch := internal.NewMockAuthorizeCodeStrategy(ctrl)
areq := internal.NewMockAccessRequester(ctrl)
aresp := internal.NewMockAccessResponder(ctrl)
//mockcl := internal.NewMockClient(ctrl)
defer ctrl.Finish()

h := AuthorizeExplicitGrantTypeHandler{
Store: store,
AuthorizeCodeStrategy: auch,
AccessTokenStrategy: ach,
RefreshTokenStrategy: rch,
}
Expand Down Expand Up @@ -53,6 +55,8 @@ func TestHandleTokenEndpointRequest(t *testing.T) {
ach.EXPECT().GenerateAccessToken(gomock.Any(), gomock.Any(), gomock.Any()).Return("", "", nil)
rch.EXPECT().GenerateRefreshToken(gomock.Any(), gomock.Any(), gomock.Any()).Return("", "", nil)

auch.EXPECT().ValidateAuthorizeCode(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return("signature", nil)

store.EXPECT().GetAuthorizeCodeSession(gomock.Any(), gomock.Any()).Return(nil, errors.New(""))
},
expectErr: fosite.ErrServerError,
Expand All @@ -65,6 +69,8 @@ func TestHandleTokenEndpointRequest(t *testing.T) {
ach.EXPECT().GenerateAccessToken(gomock.Any(), gomock.Any(), gomock.Any()).Return("", "", nil)
rch.EXPECT().GenerateRefreshToken(gomock.Any(), gomock.Any(), gomock.Any()).Return("", "", nil)

auch.EXPECT().ValidateAuthorizeCode(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return("signature", nil)

store.EXPECT().GetAuthorizeCodeSession(gomock.Any(), gomock.Any()).Return(&fosite.AuthorizeRequest{}, nil)
store.EXPECT().CreateAccessTokenSession(gomock.Any(), gomock.Any()).Return(errors.New(""))
},
Expand All @@ -78,6 +84,8 @@ func TestHandleTokenEndpointRequest(t *testing.T) {
ach.EXPECT().GenerateAccessToken(gomock.Any(), gomock.Any(), gomock.Any()).Return("", "", nil)
rch.EXPECT().GenerateRefreshToken(gomock.Any(), gomock.Any(), gomock.Any()).Return("", "", nil)

auch.EXPECT().ValidateAuthorizeCode(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return("signature", nil)

store.EXPECT().GetAuthorizeCodeSession(gomock.Any(), gomock.Any()).Return(&fosite.AuthorizeRequest{}, nil)
store.EXPECT().CreateAccessTokenSession(gomock.Any(), gomock.Any()).Return(nil)
store.EXPECT().CreateRefreshTokenSession(gomock.Any(), gomock.Any()).Return(errors.New(""))
Expand All @@ -93,6 +101,8 @@ func TestHandleTokenEndpointRequest(t *testing.T) {
ach.EXPECT().GenerateAccessToken(gomock.Any(), gomock.Any(), gomock.Any()).Return("access.at", "at", nil)
rch.EXPECT().GenerateRefreshToken(gomock.Any(), gomock.Any(), gomock.Any()).Return("refresh.rt", "rt", nil)

auch.EXPECT().ValidateAuthorizeCode(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return("signature", nil)

aresp.EXPECT().SetAccessToken("access.at")
aresp.EXPECT().SetTokenType("bearer")
aresp.EXPECT().SetExtra("refresh_token", "refresh.rt")
Expand Down
2 changes: 2 additions & 0 deletions handler/core/refresh/refresh_test.go
Expand Up @@ -142,6 +142,7 @@ func TestHandleTokenEndpointRequest(t *testing.T) {
areq.EXPECT().GetGrantType().Return("refresh_token")
acts.EXPECT().GenerateAccessToken(gomock.Any(), gomock.Any(), gomock.Any()).Return("", "access", nil)
rcts.EXPECT().GenerateRefreshToken(gomock.Any(), gomock.Any(), gomock.Any()).Return("", "refresh", nil)
rcts.EXPECT().ValidateRefreshToken(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return("signature", nil)
store.EXPECT().CreateAccessTokenSession("access", gomock.Any()).Return(nil)
store.EXPECT().CreateRefreshTokenSession("refresh", gomock.Any()).Return(nil)
store.EXPECT().DeleteRefreshTokenSession(gomock.Any()).Return(errors.New(""))
Expand All @@ -154,6 +155,7 @@ func TestHandleTokenEndpointRequest(t *testing.T) {
areq.EXPECT().GetGrantType().Return("refresh_token")
acts.EXPECT().GenerateAccessToken(gomock.Any(), gomock.Any(), gomock.Any()).Return("access.token", "access", nil)
rcts.EXPECT().GenerateRefreshToken(gomock.Any(), gomock.Any(), gomock.Any()).Return("refresh.token", "refresh", nil)
rcts.EXPECT().ValidateRefreshToken(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return("signature", nil)
store.EXPECT().CreateAccessTokenSession("access", gomock.Any()).Return(nil)
store.EXPECT().CreateRefreshTokenSession("refresh", gomock.Any()).Return(nil)
store.EXPECT().DeleteRefreshTokenSession(gomock.Any()).Return(nil)
Expand Down

0 comments on commit ea5d75e

Please sign in to comment.