public string GenerateTemporarySession(TemporaryTokenRequest request)
        {
            var httpRequest = new JSONRestRequest("/api/v3/sessions/create-temporary-token", Method.POST);

            httpRequest.AddBody(request);
            var response     = Execute(httpRequest, HttpStatusCode.Created);
            var location     = response.Headers.FirstOrDefault(x => x.Name == "Location").Value as string;
            var sessionToken = location.Split('/').Last();

            return(sessionToken);
        }
Beispiel #2
0
        public void TestGenerateSessionTokenValid()
        {
            var request = new TemporaryTokenRequest()
            {
                AccountID  = Guid.NewGuid(),
                TenantID   = Guid.NewGuid(),
                TimeToLive = 132
            };
            IRestResponse <object> mockedResponse = new RestResponse <object>()
            {
                StatusCode = HttpStatusCode.Created
            };
            var p = new Parameter()
            {
                Name  = "Location",
                Value = "http://test.com/sessions/123123123123"
            };

            mockedResponse.Headers.Add(p);
            mockedClient.Setup(c => c.Execute <object>(It.IsAny <JSONRestRequest>())).Returns(mockedResponse);
            provider.GenerateTemporarySession(request);
            mockedClient.Verify(c => c.Execute <object>(It.IsAny <JSONRestRequest>()), Times.Once);
        }