public async Task ParseLogoutRequest_post_binding()
        {
            //ARRANGE
            var form = await SamlPostRequestProviderMock.BuildLogoutRequestPostForm();

            Func <Type, IMetadataHandler> metadataHandlerFactory = t => new MetadataEntitityDescriptorHandler();
            var xmlSerialiser    = new XMLSerialiser();
            var compressor       = new DeflateCompressor();
            var encoder          = new MessageEncoding(compressor);
            var logger           = new LogProviderMock();
            var serialiser       = new RequestSerialiser(xmlSerialiser, encoder, logger) as IRequestSerialiser;
            var certManager      = new CertificateManager(logger);
            var signatureManager = new XmlSignatureManager();
            Func <IEnumerable <RequestValidationRule> > rulesResolver = () => new[] { new SignatureValidRule(logger, certManager, signatureManager) };
            var requestValidator                  = new Federation.Protocols.Request.Validation.RequestValidator(logger, new RuleFactory(rulesResolver));
            var configurationRetrieverMock        = new ConfigurationRetrieverMock();
            var federationPartyContextBuilderMock = new FederationPartyContextBuilderMock();
            var configurationManger               = new ConfigurationManager <MetadataBase>(federationPartyContextBuilderMock, configurationRetrieverMock);
            var requestParser = new RequestParser(metadataHandlerFactory, t => new LogoutRequestParser(serialiser, logger),
                                                  configurationManger, logger, requestValidator);
            var postBindingDecoder = new PostBindingDecoder(logger);
            var message            = await postBindingDecoder.Decode(form.HiddenControls.ToDictionary(k => k.Key, v => v.Value));

            var context = new SamlInboundContext
            {
                Message            = message,
                DescriptorResolver = m => metadataHandlerFactory(typeof(object)).GetIdentityProviderSingleSignOnDescriptor(m).Single().Roles.Single()
            };
            //ACT
            var result = await requestParser.Parse(context);

            //ASSERT
            Assert.IsTrue(result.IsValidated);
            Assert.IsInstanceOf <LogoutRequest>(result.SamlRequest);
        }
Esempio n. 2
0
        public async Task VerifyAuthRequestSignature()
        {
            //ARRANGE
            var signatureManager = new XmlSignatureManager();
            var document         = new XmlDocument();
            var request          = await SamlPostRequestProviderMock.BuildAuthnRequest();

            document.LoadXml(request.Item1);
            var cert = CertificateProviderMock.GetMockCertificate();

            //ACT

            var isValid = signatureManager.VerifySignature(document, cert.PublicKey.Key);

            //ASSERT
            Assert.True(isValid);
        }