public static void AddMockHandlerSuccessfulClientCredentialTokenResponseMessage(this MockHttpManager httpManager)
 {
     httpManager.AddMockHandler(
         new MockHttpMessageHandler()
     {
         ExpectedMethod  = HttpMethod.Post,
         ResponseMessage = MockHelpers.CreateSuccessfulClientCredentialTokenResponseMessage()
     });
 }
        public static MockHttpMessageHandler AddMockHandlerSuccessfulClientCredentialTokenResponseMessage(this MockHttpManager httpManager)
        {
            var handler = new MockHttpMessageHandler()
            {
                ExpectedMethod  = HttpMethod.Post,
                ResponseMessage = MockHelpers.CreateSuccessfulClientCredentialTokenResponseMessage()
            };

            httpManager.AddMockHandler(handler);

            return(handler);
        }
Exemplo n.º 3
0
        public static MockHttpMessageHandler AddTokenResponse(
            this MockHttpManager httpManager,
            TokenResponseType responseType,
            IDictionary <string, string> expectedRequestHeaders = null)
        {
            HttpResponseMessage responseMessage;

            switch (responseType)
            {
            case TokenResponseType.Valid_UserFlows:
                responseMessage = MockHelpers.CreateSuccessTokenResponseMessage(
                    TestConstants.Uid,
                    TestConstants.DisplayableId,
                    TestConstants.s_scope.ToArray());

                break;

            case TokenResponseType.Valid_ClientCredentials:
                responseMessage = MockHelpers.CreateSuccessfulClientCredentialTokenResponseMessage();

                break;

            case TokenResponseType.Invalid_AADUnavailable503:
                responseMessage = MockHelpers.CreateFailureMessage(
                    System.Net.HttpStatusCode.ServiceUnavailable, "service down");

                break;

            case TokenResponseType.InvalidGrant:
                responseMessage = MockHelpers.CreateInvalidGrantTokenResponseMessage();
                break;

            case TokenResponseType.InvalidClient:

                responseMessage = MockHelpers.CreateInvalidClientResponseMessage();
                break;

            default:
                throw new NotImplementedException();
            }

            var responseHandler = new MockHttpMessageHandler()
            {
                ExpectedMethod         = HttpMethod.Post,
                ExpectedRequestHeaders = expectedRequestHeaders,
                ResponseMessage        = responseMessage,
            };

            httpManager.AddMockHandler(responseHandler);

            return(responseHandler);
        }
Exemplo n.º 4
0
        public static MockHttpMessageHandler AddMockHandlerSuccessfulClientCredentialTokenResponseMessage(
            this MockHttpManager httpManager, string token = "header.payload.signature", string expiresIn = "3599", IList <string> unexpectedHttpHeaders = null)
        {
            var handler = new MockHttpMessageHandler()
            {
                ExpectedMethod           = HttpMethod.Post,
                ResponseMessage          = MockHelpers.CreateSuccessfulClientCredentialTokenResponseMessage(token, expiresIn),
                UnexpectedRequestHeaders = unexpectedHttpHeaders
            };

            httpManager.AddMockHandler(handler);

            return(handler);
        }