public void TestWritingResponse()
        {
            TokenResponse response = new TokenResponse
            {
                Body = "body",
                HttpStatusCode = 200
            };

            Mock<HttpResponseBase> mckResponse = new Mock<HttpResponseBase>();
            mckResponse.SetupSet(x => x.ContentType = "application/json");
            mckResponse.SetupSet(x => x.StatusCode = 200);
            mckResponse.Setup(x => x.Write("body"));
            TokenResponseWriter writer = new TokenResponseWriter(mckResponse.Object);
            writer.WriteResponse(response);
            mckResponse.VerifyAll();
        }
Пример #2
0
        public TokenResponse CreateResponse(ITokenContext context)
        {
            if (context.Error != null)
            {
                TokenResponse errorResponse = new TokenResponse();
                errorResponse.HttpStatusCode = 400;
                IDictionary<string, object> errorResults = context.Error.ToResponseValues();
                if (context.Error.Error == Parameters.ErrorParameters.ErrorValues.InvalidClient)
                    errorResponse.HttpStatusCode = 401;
                errorResponse.Body = SerializeResponse(errorResults);

                return errorResponse;
            }
            if (context.Token == null)
                throw new OAuthFatalException(TokenEndpointResources.ContextDoesNotContainToken);

            TokenResponse response = new TokenResponse { HttpStatusCode = 200 };
            response.Body = SerializeResponse(((ITokenizer)context.Token).ToResponseValues());
            return response;
        }
Пример #3
0
		public static void WriteTokenResponse(this HttpResponseBase response, TokenResponse tokenResponse)
		{
			TokenResponseWriter writer = new TokenResponseWriter(response);

			writer.WriteResponse(tokenResponse);
		}
 public TokenResponseActionResult(TokenResponse tokenResponse)
 {
     TokenResponse = tokenResponse;
 }
Пример #5
0
		public static void WriteTokenResponse(this HttpResponse response, TokenResponse tokenResponse)
		{
			WriteTokenResponse(new HttpResponseWrapper(response), tokenResponse);
		}