Example #1
0
        public void Securesession_ShouldBeAbleToSetValidationToken()
        {
            ConsoleLogger logger = new ConsoleLogger();

            SecureChannel.InitializeDatabase(logger);

            IRequest      request = CreateFakeRequest();
            SecureSession session = SecureSession.Get(request);

            ApiEncryptionValidation.SetEncryptedValidationToken(request.Headers, "Some random data", session.PublicKey);

            Expect.IsNotNull(request.Headers[CustomHeaders.ValidationToken]);

            OutLine(request.Headers[CustomHeaders.ValidationToken]);
        }
        public void Validation_ShouldBeAbleToSetAndValidateValidationToken()
        {
            Prepare();

            SecureSession session = SecureSession.Get(SecureSession.GenerateId());

            string postString = ApiParameters.ParametersToJsonParamsObjectString("random info");
            SecureServiceProxyClient <Echo> client = new SecureServiceProxyClient <Echo>("http://blah.com");

            HttpWebRequest request = client.GetServiceProxyRequest("Send");

            ApiEncryptionValidation.SetEncryptedValidationToken(request.Headers, postString, session.PublicKey);

            Cookie cookie = new Cookie(SecureSession.CookieName, session.Identifier, "", "blah.cxm");

            request.CookieContainer.Add(cookie);
            request.Headers[Headers.SecureSession] = session.Identifier;

            Expect.IsNotNull(request.Headers);
            Expect.IsNotNull(request.Headers[Headers.Nonce]);
            Expect.IsNotNull(request.Headers[Headers.ValidationToken]);

            Expect.AreEqual(EncryptedTokenValidationStatus.Success, ApiEncryptionValidation.ValidateEncryptedToken(request.Headers, postString));
        }