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); }
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); }
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); }
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)); }
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); }
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()); }