Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [Issue #309](https://github.com/manheim/terraform-pipeline/issues/309) Add the ability to specify terraform-pipeline starting execution workspace directory
- [Issue #283](https://github.com/manheim/terraform-pipeline/issues/283) Remove CrqPlugin, as it relies on a Manheim internal tool that is deprecated. Users of CrqPlugin will find a replacement in the Manheim internal ``terraform-pipeline-cai-plugins`` project.
- [Issue #409](https://github.com/manheim/terraform-pipeline/issues/409) Update Github Action CI build to run on Java 11
- [Issue #407](https://github.com/manheim/terraform-pipeline/issues/407) GithubPRPlugin support for HTTP/2 response headers.

# v5.17

Expand Down
2 changes: 1 addition & 1 deletion src/GithubPRPlanPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class GithubPRPlanPlugin implements TerraformPlanCommandPlugin, TerraformEnviron
def output = sh(script: cmd, returnStdout: true).trim()

def headers = readFile('comment.headers').trim()
if (! headers.contains('HTTP/1.1 201 Created')) {
if (! (headers.contains('HTTP/1.1 201 Created') || headers.contains('HTTP/2 201'))) {
error("Creating GitHub comment failed: ${headers}\n")
}
// ok, success
Expand Down
47 changes: 32 additions & 15 deletions test/GithubPRPlanPluginTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -431,22 +431,39 @@ class GithubPRPlanPluginTest {

@Nested
class PostPullRequestComment {
// This needs to be tested better than 'do not blow up'
@Test
void doesNotBlowUp() {
MockJenkinsfile.withParsedScmUrl([protocol: 'git', domain: 'my.github.com'])
Jenkinsfile.original = spy(new MockWorkflowScript())
def plugin = spy(new GithubPRPlanPlugin())
doReturn('HTTP/1.1 201 Created').when(plugin).readFile('comment.headers')
doReturn('{ "id": "someId", "html_url": "some_url" }').when(Jenkinsfile.original).sh(anyObject())
// This needs to be tested better than 'do not blow up x 2'
@Nested
class doesNotBlowUp {
@Test
void forHttp1_1() {
MockJenkinsfile.withParsedScmUrl([protocol: 'git', domain: 'my.github.com'])
Jenkinsfile.original = spy(new MockWorkflowScript())
def plugin = spy(new GithubPRPlanPlugin())
doReturn('HTTP/1.1 201 Created').when(plugin).readFile('comment.headers')
doReturn('{ "id": "someId", "html_url": "some_url" }').when(Jenkinsfile.original).sh(anyObject())

plugin.postPullRequestComment('someUrl', 'myPrComment')
}
plugin.postPullRequestComment('someUrl', 'myPrComment')
}
// Test executes passed closure
// Test raises error on non HTTP/1.1 201 Created
// Uses the correct pullRequestUrl
// Uses the correct git auth token
// Chunks requests correct if over 65536

void forHttp2() {
MockJenkinsfile.withParsedScmUrl([protocol: 'git', domain: 'my.github.com'])
Jenkinsfile.original = spy(new MockWorkflowScript())
def plugin = spy(new GithubPRPlanPlugin())
doReturn('HTTP/2 201').when(plugin).readFile('comment.headers')
doReturn('{ "id": "someId", "html_url": "some_url" }').when(Jenkinsfile.original).sh(anyObject())

// Test executes passed closure
// Test raises error on non HTTP/1.1 201 Created
// Uses the correct pullRequestUrl
// Uses the correct git auth token
// Chunks requests correct if over 65536
plugin.postPullRequestComment('someUrl', 'myPrComment')
}
// Test executes passed closure
// Test raises error on non HTTP/2 201 Created
// Uses the correct pullRequestUrl
// Uses the correct git auth token
// Chunks requests correct if over 65536
}
}
}