Пример #1
0
        public void KilnHgHandlerParsesKilnPayloadsForRepositoriesWithMultipleCommitsAccrossBranches()
        {
            // Arrange
            const string payload = @"{ ""commits"": ["
                                   + @"{ ""author"": ""Brian Surowiec <*****@*****.**>"", ""branch"": ""non-default"", ""id"": ""f1525c29206072f6565e6ba70831afb65b55e9a0"", ""message"": ""commit message 14"", ""revision"": 14, ""timestamp"": ""1/15/2013 2:23:37 AM"" },"
                                   + @"{ ""author"": ""Brian Surowiec <*****@*****.**>"", ""branch"": ""default"", ""id"": ""58df029b9891bed6be1516971b50dc0eda58ce38"", ""message"": ""commit message 13"", ""revision"": 13, ""timestamp"": ""1/15/2013 2:23:20 AM"" },"
                                   + @"{ ""author"": ""Brian Surowiec <*****@*****.**>"", ""branch"": ""default"", ""id"": ""cb6ea738f5ec16d53c06a2f5823c34b396922c13"", ""message"": ""commit message 12"", ""revision"": 12, ""timestamp"": ""1/15/2013 2:23:04 AM"" }"
                                   + @"], ""repository"": { ""url"": ""https://kudutest.kilnhg.com/Code/Test/Group/KuduApp"" } }";
            var httpRequest     = new Mock <HttpRequestBase>();
            var settingsManager = new MockDeploymentSettingsManager();

            settingsManager.SetValue("kiln.accesstoken", "hg-user");
            var kilnHandler = new KilnHgHandler(settingsManager);

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

            // Assert
            Assert.Equal(DeployAction.ProcessDeployment, result);
            Assert.Equal("Kiln", deploymentInfo.Deployer);
            Assert.Equal("https://*****:*****@kudutest.kilnhg.com/Code/Test/Group/KuduApp", deploymentInfo.RepositoryUrl);
            Assert.Equal("Brian Surowiec", deploymentInfo.TargetChangeset.AuthorName);
            Assert.Equal("*****@*****.**", deploymentInfo.TargetChangeset.AuthorEmail);
            Assert.Equal("58df029b9891bed6be1516971b50dc0eda58ce38", deploymentInfo.TargetChangeset.Id);
            Assert.Equal("commit message 13", deploymentInfo.TargetChangeset.Message);
            Assert.Equal(new DateTimeOffset(2013, 1, 15, 2, 23, 20, TimeSpan.Zero), deploymentInfo.TargetChangeset.Timestamp);
        }
Пример #2
0
        public void IsKilnRequestWithCustomDomainPatterns(bool expectedResult, string domainPattern)
        {
            // Arrange
            const string payload = @"{ ""repository"": { ""url"": ""https://kudu.kilnhg.com/Code/Test/Group/KuduApp"" } } ";

            var settingsManager = new MockDeploymentSettingsManager();

            settingsManager.SetValue("kiln.domain", domainPattern);

            var kilnHandler = new KilnHgHandler(settingsManager);

            // Act
            bool result = kilnHandler.IsKilnRequest(JObject.Parse(payload));

            // Assert
            Assert.Equal(expectedResult, result);
        }
Пример #3
0
        public void KilnHgHandlerParsesKilnPayloadsForPrivateRepositories(string repositoryUrl)
        {
            // Arrange
            string payload         = @"{ ""commits"": [ { ""author"": ""Brian Surowiec <*****@*****.**>"", ""branch"": ""default"", ""id"": ""771363bfb8e6e2b76a3da8d156c6a3db0ea9a9c4"", ""message"": ""commit message"", ""revision"": 1, ""timestamp"": ""1/7/2013 6:54:25 AM"" } ], ""repository"": { ""url"": """ + repositoryUrl + @""" } } ";
            var    httpRequest     = new Mock <HttpRequestBase>();
            var    settingsManager = new MockDeploymentSettingsManager();

            settingsManager.SetValue("kiln.accesstoken", "hg-user");
            var kilnHandler = new KilnHgHandler(settingsManager);

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

            // Assert
            Assert.Equal(DeployAction.ProcessDeployment, result);
            Assert.Equal("Kiln", deploymentInfo.Deployer);
            Assert.Equal("https://*****:*****@kudutest.kilnhg.com/Code/Test/Group/KuduApp", deploymentInfo.RepositoryUrl);
            Assert.Equal("Brian Surowiec", deploymentInfo.TargetChangeset.AuthorName);
            Assert.Equal("*****@*****.**", deploymentInfo.TargetChangeset.AuthorEmail);
            Assert.Equal("771363bfb8e6e2b76a3da8d156c6a3db0ea9a9c4", deploymentInfo.TargetChangeset.Id);
            Assert.Equal("commit message", deploymentInfo.TargetChangeset.Message);
            Assert.Equal(new DateTimeOffset(2013, 1, 7, 6, 54, 25, TimeSpan.Zero), deploymentInfo.TargetChangeset.Timestamp);
        }