Example #1
0
        public void can_use_client_created_with_getsecretfromkey_implementation_to_set_signature()
        {
            var mockGetSecretFromKey = new Mock <IGetSecretFromUsername>();

            mockGetSecretFromKey.Setup(x => x.Secret("anyusername"))
            .Returns("secret");

            client             = HeimdallClientFactory.Create("anyusername", mockGetSecretFromKey.Object);
            client.BaseAddress = new Uri("http://localhost:8080");

            testSignature();
        }
Example #2
0
        private static HttpResponseMessage SendSignedPostRequest()
        {
            HttpClient client = HeimdallClientFactory.Create("myusername", "mysecret");

            var content = new FormUrlEncodedContent(
                new[]
            {
                new KeyValuePair <string, string>("firstName", "Alex"),
                new KeyValuePair <string, string>("lastName", "Brown")
            });

            return(client.PostAsync("http://requestb.in/14nmm871", content).Result);
        }
Example #3
0
        private static void Unsuccesful_Authentication()
        {
            Console.WriteLine("***** Showing a message signed with a different key and not authenticated server side... *****");

            var client = HeimdallClientFactory.Create("username", "different_secret");

            var response = client.PostAsync("http://localhost:8080/api/values",
                                            new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("a", "b"), })).Result;

            Console.WriteLine("Request: ");
            Console.WriteLine(response.RequestMessage);
            Console.WriteLine("Response: ");
            Console.WriteLine(response);
            Console.WriteLine();
        }
Example #4
0
        private static HttpClient CreateClient()
        {
            var client = HeimdallClientFactory.Create("username", "secret");

            return(client);
        }
Example #5
0
 public void SetUp()
 {
     client             = HeimdallClientFactory.Create("anyusername", "secret");
     client.BaseAddress = new Uri("http://localhost:8080");
 }
Example #6
0
        public static HttpClient CreateSignedClient()
        {
            var client = HeimdallClientFactory.Create("username", "secret");

            return(client);
        }