示例#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");
            }
示例#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));
            }
示例#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");
            }
示例#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");
            }
示例#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");
            }