public void TestNoTokenInContext() { TokenContext context = new TokenContext(); TokenResponseBuilder builder = new TokenResponseBuilder(); TokenResponse response = builder.CreateResponse(context); }
private static ITokenResponseBuilder GetResponseBuilder() { ITokenResponseBuilder builder; try { builder = ServiceLocator.Current.GetInstance <ITokenResponseBuilder>(); } catch (Exception x) { Log.Info("Failed to inject ITokenResponseBuilder, using default", x); builder = new TokenResponseBuilder(); } return(builder); }
public void TestInvalidGrantContext() { TokenContext context = new TokenContext { Error = new ErrorResponse { Error = Parameters.ErrorParameters.ErrorValues.InvalidGrant } }; TokenResponseBuilder builder = new TokenResponseBuilder(); TokenResponse response = builder.CreateResponse(context); Assert.AreEqual(400, response.HttpStatusCode); Assert.AreEqual("{\"error\":\"invalid_grant\"}", response.Body); }
public void TestInvalidClientContext() { TokenContext context = new TokenContext { Error = new ErrorResponse { Error = Parameters.ErrorParameters.ErrorValues.InvalidClient, ErrorDescription = string.Empty } }; TokenResponseBuilder builder = new TokenResponseBuilder(); TokenResponse response = builder.CreateResponse(context); Assert.AreEqual(401, response.HttpStatusCode); Assert.AreEqual("{\"error\":\"invalid_client\"}", response.Body); }
public void TestValidClientContext() { TokenContext context = new TokenContext { Token = new AccessTokenBase { ExpiresIn = 3600, Token = "token", RefreshToken = "refresh", TokenType = "bearer" } }; TokenResponseBuilder builder = new TokenResponseBuilder(); TokenResponse response = builder.CreateResponse(context); Assert.AreEqual(200, response.HttpStatusCode); Assert.AreEqual("{\"access_token\":\"token\",\"expires_in\":3600,\"refresh_token\":\"refresh\",\"token_type\":\"bearer\"}", response.Body); }