public void Saml2AuthenticationRequest_ToXElement_Scoping_ZeroProxyCount_AttributeAdded() { var subject = new Saml2AuthenticationRequest() { AssertionConsumerServiceUrl = new Uri("http://destination.example.com"), Scoping = new Saml2Scoping() { ProxyCount = 0 } }; var actual = subject.ToXElement().Element(Saml2Namespaces.Saml2P + "Scoping"); var expected = new XElement(Saml2Namespaces.Saml2P + "root", new XAttribute(XNamespace.Xmlns + "saml2p", Saml2Namespaces.Saml2P), new XElement(Saml2Namespaces.Saml2P + "Scoping", new XAttribute("ProxyCount", "0"))) .Elements().Single(); actual.Should().BeEquivalentTo(expected); }
public void Saml2AuthenticationRequest_ToXElement_AddsScoping() { var requesterId = "urn://requesterid/"; var location = "http://location"; var name = "name"; var providerId = "urn:providerId"; var subject = new Saml2AuthenticationRequest() { AssertionConsumerServiceUrl = new Uri("http://destination.example.com"), Scoping = new Saml2Scoping() { ProxyCount = 5 } .With(new Saml2IdpEntry(new EntityId(providerId)) { Name = name, Location = new Uri(location) }) .WithRequesterId(new EntityId(requesterId)) }; var actual = subject.ToXElement().Element(Saml2Namespaces.Saml2P + "Scoping"); var expected = new XElement(Saml2Namespaces.Saml2P + "Scoping", new XAttribute("ProxyCount", "5"), new XElement(Saml2Namespaces.Saml2P + "IDPList", new XElement(Saml2Namespaces.Saml2P + "IDPEntry", new XAttribute("ProviderID", providerId), new XAttribute("Name", name), new XAttribute("Loc", location))), new XElement(Saml2Namespaces.Saml2P + "RequesterID", requesterId.ToString())); actual.Should().BeEquivalentTo(expected); }