Ejemplo n.º 1
0
            public void IfPullRequestIsNotSignedAndEntriesExistInAuthorizationMap()
            {
                var provider = new StubAuthorizationMapProvider(new[]
                {
                    new PullRequestAuthorizationEntry("mpc1", "ABCDEFGHIJKLM", true), new PullRequestAuthorizationEntry("mpc2", "ABCDEFGHIJKLM", true)
                });

                var pullRequest = CreatePullRequest("mpc1");

                var service = new PullAuthorizationMapService(provider);

                Assert.False(service.IsPullRequestAuthorized(pullRequest), "PullRequest should not be allowed since PullRequest is not signed");
            }
Ejemplo n.º 2
0
            public void IfPullRequestIsNotSignedAndNoEntriesExistForMpcInAuthorizationMap()
            {
                var certificate = GetSigningCertificate();

                var provider = new StubAuthorizationMapProvider(new[]
                {
                    new PullRequestAuthorizationEntry("mpc1", certificate.Thumbprint, false), new PullRequestAuthorizationEntry("mpc2", certificate.Thumbprint, false)
                });

                var pullRequest = CreatePullRequest("mpc3");

                var service = new PullAuthorizationMapService(provider);

                Assert.True(service.IsPullRequestAuthorized(pullRequest));
            }
Ejemplo n.º 3
0
            public void IfCertificateIsNotPresentInAuthorizationMap()
            {
                var certificate = GetSigningCertificate();

                var provider = new StubAuthorizationMapProvider(new[]
                {
                    new PullRequestAuthorizationEntry("mpc1", "ABCDEFGHIJKLM", true), new PullRequestAuthorizationEntry("mpc2", certificate.Thumbprint, true)
                });

                var as4Message = CreatePullRequest("mpc1");

                var signedPullRequest = SignAS4MessageWithCertificate(as4Message, certificate);

                var service = new PullAuthorizationMapService(provider);

                Assert.False(service.IsPullRequestAuthorized(signedPullRequest), "PullRequest should not be allowed since certificate is not present in PullAuthorizationMap");
            }
Ejemplo n.º 4
0
            public void IfNoEntriesExistForMpcInAuthorizationMap()
            {
                var certificate = GetSigningCertificate();

                var provider = new StubAuthorizationMapProvider(new[]
                {
                    new PullRequestAuthorizationEntry("mpc1", certificate.Thumbprint, false), new PullRequestAuthorizationEntry("mpc2", certificate.Thumbprint, false)
                });

                var as4Message = CreatePullRequest("mpc3");

                var signedPullRequest = SignAS4MessageWithCertificate(as4Message, certificate);

                var service = new PullAuthorizationMapService(provider);

                Assert.True(service.IsPullRequestAuthorized(signedPullRequest), "PullRequest should be allowed since no entries are present for MPC3 in Authorization Map");
            }
Ejemplo n.º 5
0
            public void IfMpcMatchesCertificate()
            {
                var certificate = GetSigningCertificate();

                var provider = new StubAuthorizationMapProvider(new[]
                {
                    new PullRequestAuthorizationEntry("mpc1", certificate.Thumbprint, true), new PullRequestAuthorizationEntry("mpc2", certificate.Thumbprint, false)
                });

                var as4Message = CreatePullRequest("mpc1");

                var signedPullRequest = SignAS4MessageWithCertificate(as4Message, certificate);

                var service = new PullAuthorizationMapService(provider);

                Assert.True(service.IsPullRequestAuthorized(signedPullRequest), "PullRequest should be allowed since entry exists for MPC and cert-thumbprint");
            }