Пример #1
0
        public void Token19Test()
        {
            NameValueCollection headers = new NameValueCollection()
            {
                { "X-Version", "1.9" },
                { "X-AUTHENTICATE-participantId", "AT:L6:1234789" },
                { "X-AUTHENTICATE-UserId", "*****@*****.**" },
                { "X-AUTHENTICATE-cn", "Max Mustermann" },
                { "X-AUTHENTICATE-gvGid", "AT:B:0:LxXnvpcYZesiqVXsZG0bB==" },
                { "X-AUTHENTICATE-gvOuId", "AT:GGA-60420:0815" },
                { "X-AUTHENTICATE-Ou", "Meldeamt" },
                { "X-AUTHENTICATE-gvOuOKZ", "AT:GGA-60420-Abt13" },
                { "X-AUTHENTICATE-mail", "*****@*****.**" },
                { "X-AUTHENTICATE-tel", "+43 3155 5153" },
                { "X-AUTHENTICATE-gvSecClass", "2" },
                { "X-AUTHORIZE-roles", "Beispielrolle(GKZ=60420)" },
                { "X-AUTHORIZE-roles", "Beispielrolle2(ABC=XYZ, DEF=4711)" },
            };
            PvpToken token = new PvpToken(headers);

            Assert.AreEqual(PvpVersion.Version19, token.Version);
            Assert.AreEqual("*****@*****.**", token.GetAttributeValue(PvpAttributes.USERID));
            Assert.AreEqual("Beispielrolle(GKZ=60420);Beispielrolle2(ABC=XYZ, DEF=4711)",
                            token.GetAttributeValue(PvpAttributes.ROLES));
        }
Пример #2
0
        public void Token21Test()
        {
            NameValueCollection headers = GetNameValueCollection21();
            PvpToken            token   = new PvpToken(headers);

            Assert.AreEqual(PvpVersion.Version21, token.Version);
            Assert.AreEqual("*****@*****.**", token.GetAttributeValue(PvpAttributes.USERID));
            Assert.AreEqual("Beispielrolle(GKZ=60420);Beispielrolle2(ABC=XYZ, DEF=4711)",
                            token.GetAttributeValue(PvpAttributes.ROLES));
        }
Пример #3
0
        public void ParseTokenTest()
        {
            NameValueCollection headers     = GetNameValueCollection21();
            PvpToken            token       = new PvpToken(headers);
            PvpToken            parsedToken = new PvpToken(token.GetSamlAttributeStatement());

            Assert.AreEqual(PvpVersion.Version21, parsedToken.Version);
            Assert.AreEqual("*****@*****.**", parsedToken.GetAttributeValue(PvpAttributes.USERID));
            Assert.AreEqual("Beispielrolle(GKZ=60420);Beispielrolle2(ABC=XYZ, DEF=4711)",
                            parsedToken.GetAttributeValue(PvpAttributes.ROLES));
            foreach (HttpHeader header in parsedToken.GetHeaders())
            {
                if (header.Name.Equals("X-PVP-roles", StringComparison.InvariantCultureIgnoreCase))
                {
                    continue;
                }

                Assert.AreEqual(headers[header.Name], header.Value, "Fehler bei " + header.Name);
            }
        }
Пример #4
0
        public void NewToken18Test()
        {
            PvpToken token18 = new PvpToken(PvpVersion.Version18);

            Assert.AreEqual(PvpVersion.Version18, token18.Version);
            var userId = new PvpAttributeUserId();

            userId.Value = "abc";
            token18.Attributes.Add(userId);
            Assert.AreEqual(PvpVersion.Version18, userId.CurrentVersion);
            Assert.AreEqual("abc", userId.Value);
            Assert.AreEqual("X-AUTHENTICATE-UserID", userId.GetHeaderName());
            Assert.AreEqual("1.8", token18.GetAttributeValue(PvpAttributes.VERSION));
        }
Пример #5
0
        public void NewToken20Test()
        {
            PvpToken token20 = new PvpToken(PvpVersion.Version20);

            Assert.AreEqual(PvpVersion.Version20, token20.Version);
            var userId = new PvpAttributeUserId();

            userId.Value = "abc";
            token20.Attributes.Add(userId);
            Assert.AreEqual(PvpVersion.Version20, userId.CurrentVersion);
            Assert.AreEqual("abc", userId.Value);
            Assert.AreEqual("X-PVP-USERID", userId.GetHeaderName());
            Assert.AreEqual("2.0", token20.GetAttributeValue(PvpAttributes.VERSION));
        }
Пример #6
0
        public void ParseSamlValuesTest()
        {
            NameValueCollection headers   = GetNameValueCollection21();
            PvpToken            token     = new PvpToken(headers);
            XElement            statement = XElement.Parse(token.GetSamlAttributeStatement().OuterXml);
            var values = statement.Elements(PvpToken.SamlXNamespace + "Attribute").ToDictionary(a => a.Attribute("Name").Value,
                                                                                                a =>
                                                                                                a.Elements(PvpToken.SamlXNamespace + "AttributeValue").Select(v => v.Value).ToList());
            PvpToken parsedToken = new PvpToken(values);

            Assert.AreEqual(PvpVersion.Version21, parsedToken.Version);
            Assert.AreEqual("*****@*****.**", parsedToken.GetAttributeValue(PvpAttributes.USERID));
            Assert.AreEqual("Beispielrolle(GKZ=60420);Beispielrolle2(ABC=XYZ, DEF=4711)",
                            parsedToken.GetAttributeValue(PvpAttributes.ROLES));
            foreach (HttpHeader header in parsedToken.GetHeaders())
            {
                if (header.Name.Equals("X-PVP-roles", StringComparison.InvariantCultureIgnoreCase))
                {
                    continue;
                }

                Assert.AreEqual(headers[header.Name], header.Value, "Fehler bei " + header.Name);
            }
        }
Пример #7
0
        public void MultipleAttributesTest()
        {
            NameValueCollection headers = new NameValueCollection()
            {
                { "X-Version", "1.9" },
                { "X-AUTHENTICATE-participantId", "AT:L6:1234789" },
            };
            PvpToken             token    = new PvpToken(headers);
            PvpAttributeFunction function = new PvpAttributeFunction("SachbearbeiterIn");

            token.Attributes.Add(function);
            Assert.AreEqual(3, token.Attributes.Count);
            Assert.AreEqual("SachbearbeiterIn", token.GetAttributeValue(PvpAttributes.FUNCTION));

            PvpAttributeParticipantId participantId = new PvpAttributeParticipantId("AT:L9:Wien");

            token.Attributes.Add(participantId);
        }