github.com/RichardKnop/go-oauth2-server@v1.0.5-0.20201019163316-d02a401490d0/oauth/routes_test.go (about) 1 package oauth_test 2 3 import ( 4 "net/http" 5 6 "github.com/gorilla/mux" 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func (suite *OauthTestSuite) TestTokensRouteIsValid() { 11 r, err := http.NewRequest( 12 "POST", 13 "http://1.2.3.4/v1/oauth/tokens", 14 nil, 15 ) 16 assert.NoError(suite.T(), err, "New request should not cause an error") 17 18 // Check the routing 19 match := new(mux.RouteMatch) 20 suite.router.Match(r, match) 21 if assert.NotNil(suite.T(), match.Route, "Expected to find a route match") { 22 assert.Equal(suite.T(), "oauth_tokens", match.Route.GetName(), "Expected route to be matched") 23 } 24 } 25 26 func (suite *OauthTestSuite) TestIntrospectRouteIsValid() { 27 r, err := http.NewRequest( 28 "POST", 29 "http://1.2.3.4/v1/oauth/introspect", 30 nil, 31 ) 32 assert.NoError(suite.T(), err, "New request should not cause an error") 33 34 // Check the routing 35 match := new(mux.RouteMatch) 36 suite.router.Match(r, match) 37 if assert.NotNil(suite.T(), match.Route, "Expected to find a route match") { 38 assert.Equal(suite.T(), "oauth_introspect", match.Route.GetName(), "Expected route to be matched") 39 } 40 }