コード例 #1
0
        public void NoRealm()
        {
            var client = new HttpClient();
            client.SetBasicAuthenticationHeader(Constants.Credentials.ValidUserName, Constants.Credentials.ValidPassword);

            var result = client.GetAsync(new Uri(baseAddress)).Result;
            Assert.AreEqual<HttpStatusCode>(HttpStatusCode.BadRequest, result.StatusCode);
        }
コード例 #2
0
        public void MalformedRealm()
        {
            var values = new Dictionary<string, string>
            {
                { "realm", "malformed" }
            };

            var client = new HttpClient();
            client.SetBasicAuthenticationHeader(Constants.Credentials.ValidUserName, Constants.Credentials.ValidPassword);

            var result = client.GetAsync(baseAddress + values.ToQueryString()).Result;
            Assert.AreEqual<HttpStatusCode>(HttpStatusCode.BadRequest, result.StatusCode);
        }
コード例 #3
0
        public void ValidUserNameCredential()
        {
            var values = new Dictionary<string, string>
            {
                { "realm", rp }
            };

            var client = new HttpClient();
            client.SetBasicAuthenticationHeader(Constants.Credentials.ValidUserName, Constants.Credentials.ValidPassword);

            var result = client.GetAsync(baseAddress + values.ToQueryString()).Result;
            
            Assert.AreEqual<HttpStatusCode>(HttpStatusCode.OK, result.StatusCode);
            Assert.AreEqual<string>("application/json", result.Content.Headers.ContentType.MediaType);
        }
コード例 #4
0
        public void ValidUserNameCredentialSaml11()
        {
            var values = new Dictionary<string, string>
            {
                { "realm", rp },
                { "tokentype", TokenTypes.Saml11TokenProfile11 }
            };

            var client = new HttpClient();
            client.SetBasicAuthenticationHeader(Constants.Credentials.ValidUserName, Constants.Credentials.ValidPassword);

            var result = client.GetAsync(baseAddress + values.ToQueryString()).Result;
            
            Assert.AreEqual<HttpStatusCode>(HttpStatusCode.OK, result.StatusCode);
            Assert.AreEqual<string>("application/json", result.Content.Headers.ContentType.MediaType);

            Trace.WriteLine(HttpUtility.UrlDecode(result.Content.ReadAsStringAsync().Result));
        }
コード例 #5
0
        public void InvalidUserNameCredential()
        {
            var values = new Dictionary<string, string>
            {
                { "realm", rp }
            };

            var client = new HttpClient();
            client.SetBasicAuthenticationHeader(Constants.Credentials.ValidUserName, "invalid");

            var result = client.GetAsync(baseAddress + values.ToQueryString()).Result;
            Assert.AreEqual<HttpStatusCode>(HttpStatusCode.Unauthorized, result.StatusCode);
        }
コード例 #6
0
        public void ValidUserNameCredentialSaml2()
        {
            var values = new Dictionary<string, string>
            {
                { "realm", rp },
                { "tokentype", SecurityTokenTypes.Saml2TokenProfile11 }
            };

            var client = new HttpClient();
            client.SetBasicAuthenticationHeader(Constants.Credentials.ValidUserName, Constants.Credentials.ValidPassword);

            var result = client.GetAsync(baseAddress + values.ToQueryString()).Result;
            
            Assert.AreEqual<HttpStatusCode>(HttpStatusCode.OK, result.StatusCode);
            Assert.AreEqual<string>(MediaTypeNames.Text.Xml, result.Content.Headers.ContentType.MediaType);

            Trace.Write(XElement.Parse(result.Content.ReadAsStringAsync().Result).ToString());
        }