示例#1
0
        public void CreateJwtTokenTest()
        {
            var payload    = GetPayload();
            var fileName   = ConfigurationManager.AppSettings["privateKeyFileName"];
            var privateKey = File.ReadAllText(fileName);
            var token      = WebServiceExchangeHelper.CreateJwtToken(privateKey, payload);

            Assert.IsNotNull(token);
        }
示例#2
0
        private HttpRequestMessage CreateRequest(JsonWebTokenPayload payload)
        {
            var fileName   = ConfigurationManager.AppSettings["privateKeyFileName"];
            var privateKey = File.ReadAllText(fileName);

            var token = WebServiceExchangeHelper.CreateJwtToken(privateKey, payload);
            HttpRequestMessage request = new HttpRequestMessage();

            request.Headers.Add("Authorization", "Bearer " + token);
            return(request);
        }
示例#3
0
        public void SendHttpRequestTest()
        {
            var fileName   = ConfigurationManager.AppSettings["privateKeyFileName"];
            var privateKey = File.ReadAllText(fileName);
            var payload    = GetPayload();
            var token      = WebServiceExchangeHelper.CreateJwtToken(privateKey, payload);

            Assert.IsNotNull(token);
            var data = WebServiceExchangeHelper.GetCustomerTravelPlannerJson();

            Assert.IsNotNull(data);
            var serviceUrl = ConfigurationManager.AppSettings["serviceUrl"];
            var content    = WebServiceExchangeHelper.SendHttpRequest(serviceUrl, token, data);
        }
示例#4
0
        public void CallSsoService()
        {
            var login            = GetSsoDetails();
            var privateKey       = GetPrivateInfo();
            var expiredSeconds   = GetConfig(DataKey.SsoTokenExpired);
            var notBeforeSeconds = GetConfig(DataKey.SsoTokenNotBefore);
            var payload          = GetPayload(login, expiredSeconds, notBeforeSeconds);
            var token            = WebServiceExchangeHelper.CreateJwtToken(privateKey, payload);
            var data             = WebServiceExchangeHelper.GetCustomerTravelPlannerJson();
            var serviceUrl       = GetConfig(DataKey.OwrUrlConfigName);
            var content          = WebServiceExchangeHelper.SendHttpRequest(serviceUrl, token, data);
            var eventParams      = WebServiceExchangeHelper.ContentToEventParams(content);

            FireEvent(EventName.SsoCompleteEvent, eventParams);
        }