public void SecureServiceProxyClientBaseAddressShouldBeSet()
        {
            string baseAddress = "http://localhost:8989/";
            SecureServiceProxyClient <Echo> sspc = new SecureServiceProxyClient <Echo>(baseAddress);

            Expect.AreEqual(baseAddress, sspc.BaseAddress);
        }
Ejemplo n.º 2
0
        public static void StartSecureChannelTestServerGetClient <T>(out BamServer server, out SecureServiceProxyClient <T> sspc)
        {
            string baseAddress;

            StartTestServer <SecureChannel, T>(out baseAddress, out server);
            sspc = new SecureServiceProxyClient <T>(baseAddress);
        }
Ejemplo n.º 3
0
        public static void StartSecureChannelTestServerGetApiKeyRequiredEchoClient(out BamServer server, out SecureServiceProxyClient <ApiKeyRequiredEcho> sspc)
        {
            string baseAddress;

            StartTestServer <SecureChannel, ApiKeyRequiredEcho>(out baseAddress, out server);
            sspc = new SecureServiceProxyClient <ApiKeyRequiredEcho>(baseAddress);
        }
Ejemplo n.º 4
0
        // TODO: this crap needs to be refactored, oh my
        public static void StartTestServerGetEchoClient(out BamServer server, out SecureServiceProxyClient <Echo> sspc)
        {
            string baseAddress;

            StartTestServer(out baseAddress, out server);
            sspc = new SecureServiceProxyClient <Echo>(baseAddress);
        }
Ejemplo n.º 5
0
        private static void StartSecureChannelTestServerGetEncryptedEchoClient(out BamServer server, out SecureServiceProxyClient <EncryptedEcho> sspc)
        {
            string baseAddress;

            StartTestServer <SecureChannel, EncryptedEcho>(out baseAddress, out server);
            sspc = new SecureServiceProxyClient <EncryptedEcho>(baseAddress);
        }
Ejemplo n.º 6
0
 public static SecureClientSessionInfo GetSecureClientSessionInfo <T>(this SecureServiceProxyClient <T> client)
 {
     return(new SecureClientSessionInfo
     {
         ClientSessionInfo = client.SessionInfo,
         SessionCookie = client.SessionCookie,
         SessionKey = client.SessionKey,
         SessionIV = client.SessionIV
     });
 }
Ejemplo n.º 7
0
        public void Securesession_ShouldBeAbleToSetSessionKey()
        {
            InitializeSecureChannelSchema();

            SecureChannel server = new SecureChannel();

            server.HttpContext         = A.Fake <IHttpContext>();
            server.HttpContext.Request = new ServiceProxyTestHelpers.FormUrlEncodedTestRequest();
            SecureChannelMessage <ClientSessionInfo> msg = server.InitSession(new Instant());

            AesKeyVectorPair                kvp;
            SetSessionKeyRequest            request;
            SecureServiceProxyClient <Echo> client = new SecureServiceProxyClient <Echo>("http://localhost:8080");

            client.SessionInfo = msg.Data;
            client.CreateSetSessionKeyRequest(out kvp, out request);

            server.SetSessionKey(request);
        }
        public void SecureServiceProxyInvokeWithApiKeyShouldSucceed()
        {
            CleanUp();
            string    methodName = MethodBase.GetCurrentMethod().Name;
            BamServer server;

            SecureChannel.Debug = true;

            string baseAddress;

            ServiceProxyTestHelpers.CreateServer(out baseAddress, out server);
            ServiceProxyTestHelpers.Servers.Add(server); // makes sure it gets stopped after test run
            SecureServiceProxyClient <ApiKeyRequiredEcho> sspc = new SecureServiceProxyClient <ApiKeyRequiredEcho>(baseAddress);

            IApplicationNameProvider nameProvider = new TestApplicationNameProvider(methodName);
            IApiKeyProvider          keyProvider  = new LocalApiKeyProvider();
            ApiKeyResolver           keyResolver  = new ApiKeyResolver(keyProvider, nameProvider);

            SecureChannel channel = new SecureChannel();

            channel.ApiKeyResolver = keyResolver;

            server.AddCommonService <SecureChannel>(channel);
            server.AddCommonService <ApiKeyRequiredEcho>();

            server.Start();

            string value  = "InputValue_".RandomLetters(8);
            bool?  thrown = false;

            sspc.InvocationException += (client, ex) =>
            {
                thrown = true;
            };

            sspc.ApiKeyResolver = keyResolver;
            string result = sspc.Invoke <string>("Send", new object[] { value });

            Expect.IsFalse(thrown.Value, "Exception was thrown");
            Expect.AreEqual(value, result);
            CleanUp();
        }
Ejemplo n.º 9
0
        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));
        }