TestNew - valid token | Request with valid Bearer token | Returns 200 OK, token validated |
TestNew - invalid token | Request with invalid Bearer token | Returns 401 Unauthorized |
TestNew - missing token | Request without Authorization header | Returns 401 Unauthorized |
TestWithOptions_RequiredScopes | Token with insufficient scopes | Returns 403 Forbidden |
TestWithOptions_ExpiredToken | Token with past expiration time | Returns 401 Unauthorized |
TestGet | Retrieve token from context | Token object accessible via Get() |
TestSubject | Extract subject from token | Subject field returned correctly |
TestHasScope | Check for specific scope | Returns true/false based on presence |
TestRequireScopes | Scope enforcement middleware | Blocks request if scopes missing |
TestWWWAuthenticateHeader | Invalid token response | WWW-Authenticate header present |
TestExtractToken_Query | Token in query parameter | Token extracted from URL query |
TestExtractToken_Form | Token in form body | Token extracted from form data |
TestExtractToken_InvalidLookup | Malformed TokenLookup config | Returns 401, no token found |
TestExtractToken_UnknownSource | Unknown token source type | Returns 401, no token found |
TestExtractToken_HeaderWithoutBearer | Plain token without Bearer prefix | Token extracted and validated |
TestWithOptions_NoValidator | No validator configured | Returns 401 with ErrNoValidator |
TestWithOptions_CustomErrorHandler | Custom error handler set | Custom handler invoked on error |
TestIntrospectToken - active | Introspection returns active token | Returns 200 OK |
TestIntrospectToken - inactive | Introspection returns inactive token | Returns 401 Unauthorized |
TestIntrospectToken_ServerError | Introspection endpoint error | Returns 401 Unauthorized |
TestIntrospectToken_InvalidJSON | Malformed introspection response | Returns 401 Unauthorized |
TestIntrospectToken_ConnectionError | Cannot connect to endpoint | Returns 401 Unauthorized |
TestGet_NoToken | Get() without middleware | Returns nil |
TestSubject_NoToken | Subject() without token | Returns empty string |
TestScopes | Retrieve scopes list | Returns all token scopes |
TestScopes_NoToken | Scopes() without token | Returns nil |
TestRequireScopes_NoToken | RequireScopes without auth | Returns 401 Unauthorized |
TestRequireScopes_Sufficient | Token has required scopes | Returns 200 OK, access granted |
TestHasScope_NoToken | HasScope() without token | Returns false |
TestErrorTypes | Error message strings | All error types return correct messages |
TestWithOptions_IntrospectionWithoutClientCreds | Introspection without client auth | No Basic auth sent, request succeeds |