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); }
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); }
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); }
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); }