Skip to content

Commit

Permalink
all: clean up, resolve broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeneas Rekkas (arekkas) authored and arekkas committed Oct 16, 2016
1 parent f193012 commit 1041e67
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 3 deletions.
2 changes: 1 addition & 1 deletion handler/oauth2/revocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (r *TokenRevocationHandler) RevokeToken(ctx context.Context, token string,
ar, err = discoveryFuncs[1]()
}
if err != nil {
return nil
return err
}

requestID := ar.GetID()
Expand Down
4 changes: 2 additions & 2 deletions handler/oauth2/revocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestRevokeToken(t *testing.T) {
},
{
description: "should pass - refresh token discovery first; both tokens not found",
expectErr: nil,
expectErr: fosite.ErrNotFound,
mock: func() {
token = "foo"
tokenType = fosite.RefreshToken
Expand All @@ -105,7 +105,7 @@ func TestRevokeToken(t *testing.T) {
},
{
description: "should pass - access token discovery first; both tokens not found",
expectErr: nil,
expectErr: fosite.ErrNotFound,
mock: func() {
token = "foo"
tokenType = fosite.AccessToken
Expand Down
7 changes: 7 additions & 0 deletions integration/revoke_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ func runRevokeTokenTest(t *testing.T, strategy oauth2.AccessTokenStrategy) {
assert.Nil(t, err)

resp, _, errs := gorequest.New().Post(ts.URL+"/revoke").
SetBasicAuth(oauthClient.ClientID, oauthClient.ClientSecret).
Type("form").
SendStruct(map[string]string{"token": "asdf"}).End()
assert.Len(t, errs, 0)
assert.Equal(t, 200, resp.StatusCode)

resp, _, errs = gorequest.New().Post(ts.URL+"/revoke").
SetBasicAuth(oauthClient.ClientID, oauthClient.ClientSecret).
Type("form").
SendStruct(map[string]string{"token": token.AccessToken}).End()
Expand Down
41 changes: 41 additions & 0 deletions internal/introspector.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Automatically generated by MockGen. DO NOT EDIT!
// Source: github.com/ory-am/fosite (interfaces: TokenIntrospector)

package internal

import (
gomock "github.com/golang/mock/gomock"
fosite "github.com/ory-am/fosite"
context "golang.org/x/net/context"
)

// Mock of TokenIntrospector interface
type MockTokenIntrospector struct {
ctrl *gomock.Controller
recorder *_MockTokenIntrospectorRecorder
}

// Recorder for MockTokenIntrospector (not exported)
type _MockTokenIntrospectorRecorder struct {
mock *MockTokenIntrospector
}

func NewMockTokenIntrospector(ctrl *gomock.Controller) *MockTokenIntrospector {
mock := &MockTokenIntrospector{ctrl: ctrl}
mock.recorder = &_MockTokenIntrospectorRecorder{mock}
return mock
}

func (_m *MockTokenIntrospector) EXPECT() *_MockTokenIntrospectorRecorder {
return _m.recorder
}

func (_m *MockTokenIntrospector) IntrospectToken(_param0 context.Context, _param1 string, _param2 fosite.TokenType, _param3 fosite.AccessRequester, _param4 []string) error {
ret := _m.ctrl.Call(_m, "IntrospectToken", _param0, _param1, _param2, _param3, _param4)
ret0, _ := ret[0].(error)
return ret0
}

func (_mr *_MockTokenIntrospectorRecorder) IntrospectToken(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "IntrospectToken", arg0, arg1, arg2, arg3, arg4)
}

0 comments on commit 1041e67

Please sign in to comment.