コード例 #1
0
        public async Task BitbucketHandlerReturnsNoOpForCommitsThatAreNotTheTargetBranch()
        {
            // Arrange
            string payloadContent = null;
            using (var reader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("Kudu.Services.Test.BitbucketDeployment.BitbucketV2Payload.json")))
            {
                payloadContent = await reader.ReadToEndAsync();
            }

            var httpRequest = new Mock<HttpRequestBase>();
            httpRequest.SetupGet(r => r.UserAgent).Returns("Bitbucket-Webhooks/2.0");
            var bitbucketHandler = new BitbucketHandlerV2();

            // Act
            DeploymentInfo deploymentInfo;
            DeployAction result = bitbucketHandler.TryParseDeploymentInfo(
                httpRequest.Object,
                payload: JObject.Parse(payloadContent),
                targetBranch: "not-default",
                deploymentInfo: out deploymentInfo);

            // Assert
            Assert.Equal(DeployAction.NoOp, result);
            Assert.Null(deploymentInfo);
        }
コード例 #2
0
        public async Task BitbucketHandlerAllowsPayloadsWithNullBranch()
        {
            // Arrange
            string payloadContent = null;
            using (var reader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("Kudu.Services.Test.BitbucketDeployment.BitbucketV2Payload.json")))
            {
                payloadContent = await reader.ReadToEndAsync();
            }

            payloadContent = payloadContent.Replace("\"name\": \"master\"", "\"name\": null");

            var httpRequest = new Mock<HttpRequestBase>();
            httpRequest.SetupGet(r => r.UserAgent).Returns("Bitbucket-Webhooks/2.0");
            var bitbucketHandler = new BitbucketHandlerV2();

            // Act
            DeploymentInfo deploymentInfo;
            DeployAction result = bitbucketHandler.TryParseDeploymentInfo(httpRequest.Object, payload: JObject.Parse(payloadContent), targetBranch: "not-default", deploymentInfo: out deploymentInfo);

            // Assert
            Assert.Equal(DeployAction.ProcessDeployment, result);
            Assert.Equal("Bitbucket", deploymentInfo.Deployer);
            Assert.Equal(RepositoryType.Git, deploymentInfo.RepositoryType);
            Assert.Equal("https://bitbucket.org/shrimpywu/hello", deploymentInfo.RepositoryUrl);
            Assert.Equal("Xiaomin Wu", deploymentInfo.TargetChangeset.AuthorName);
            Assert.Equal("*****@*****.**", deploymentInfo.TargetChangeset.AuthorEmail);
            Assert.Equal("65f2a62d05ccb7d605ae36f18a11d3557ed552a9", deploymentInfo.TargetChangeset.Id);
            Assert.Equal("Another check in\n", deploymentInfo.TargetChangeset.Message);
        }
コード例 #3
0
        public void BitbucketHandlerV2IgnoresNonBitbucketPayloads()
        {
            // Arrange
            var httpRequest = new Mock<HttpRequestBase>();
            httpRequest.SetupGet(r => r.UserAgent).Returns("Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)");
            var bitbucketHandler = new BitbucketHandlerV2();

            // Act
            DeploymentInfo deploymentInfo;
            DeployAction result = bitbucketHandler.TryParseDeploymentInfo(httpRequest.Object, payload: null, targetBranch: null, deploymentInfo: out deploymentInfo);

            // Assert
            Assert.Equal(DeployAction.UnknownPayload, result);
        }