New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added WebhookURL to VCSRepo struct #413
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c36d51f
added WebhookURL attribute to VCSRepo struct
kgns 36b26f4
added WebhookURL to Unmarshal tests
kgns 10e6b11
since we cannot know what webhook url will be in advance, had to brea…
kgns c5a87bd
regex typo
kgns 4b777cf
replaced hostname in webhook url regex to address field of DefaultCon…
kgns File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,15 +165,14 @@ func TestPolicySetsCreate(t *testing.T) { | |
assert.Equal(t, ps.Description, "") | ||
assert.False(t, ps.Global) | ||
assert.Equal(t, ps.PoliciesPath, "/policy-sets/foo") | ||
assert.Equal(t, ps.VCSRepo, &VCSRepo{ | ||
Branch: "policies", | ||
DisplayIdentifier: githubIdentifier, | ||
Identifier: githubIdentifier, | ||
OAuthTokenID: oc.ID, | ||
IngressSubmodules: true, | ||
RepositoryHTTPURL: fmt.Sprintf("https://github.com/%s", githubIdentifier), | ||
ServiceProvider: string(ServiceProviderGithub), | ||
}) | ||
assert.Equal(t, ps.VCSRepo.Branch, "policies") | ||
assert.Equal(t, ps.VCSRepo.DisplayIdentifier, githubIdentifier) | ||
assert.Equal(t, ps.VCSRepo.Identifier, githubIdentifier) | ||
assert.Equal(t, ps.VCSRepo.IngressSubmodules, true) | ||
assert.Equal(t, ps.VCSRepo.OAuthTokenID, oc.ID) | ||
assert.Equal(t, ps.VCSRepo.RepositoryHTTPURL, fmt.Sprintf("https://github.com/%s", githubIdentifier)) | ||
assert.Equal(t, ps.VCSRepo.ServiceProvider, string(ServiceProviderGithub)) | ||
assert.Regexp(t, "^https://app\\.terraform\\.io/webhooks/vcs/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$", ps.VCSRepo.WebhookURL) | ||
}) | ||
|
||
t.Run("with vcs policy updated", func(t *testing.T) { | ||
|
@@ -203,15 +202,14 @@ func TestPolicySetsCreate(t *testing.T) { | |
assert.Equal(t, ps.Description, "") | ||
assert.False(t, ps.Global) | ||
assert.Equal(t, ps.PoliciesPath, "/policy-sets/bar") | ||
assert.Equal(t, ps.VCSRepo, &VCSRepo{ | ||
Branch: "policies", | ||
DisplayIdentifier: githubIdentifier, | ||
Identifier: githubIdentifier, | ||
OAuthTokenID: oc.ID, | ||
IngressSubmodules: false, | ||
RepositoryHTTPURL: fmt.Sprintf("https://github.com/%s", githubIdentifier), | ||
ServiceProvider: string(ServiceProviderGithub), | ||
}) | ||
assert.Equal(t, ps.VCSRepo.Branch, "policies") | ||
assert.Equal(t, ps.VCSRepo.DisplayIdentifier, githubIdentifier) | ||
assert.Equal(t, ps.VCSRepo.Identifier, githubIdentifier) | ||
assert.Equal(t, ps.VCSRepo.IngressSubmodules, false) | ||
assert.Equal(t, ps.VCSRepo.OAuthTokenID, oc.ID) | ||
assert.Equal(t, ps.VCSRepo.RepositoryHTTPURL, fmt.Sprintf("https://github.com/%s", githubIdentifier)) | ||
assert.Equal(t, ps.VCSRepo.ServiceProvider, string(ServiceProviderGithub)) | ||
assert.Regexp(t, "^https://app\\.terraform\\.io/webhooks/vcs/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$", ps.VCSRepo.WebhookURL) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto, here as well! |
||
}) | ||
|
||
t.Run("without a name provided", func(t *testing.T) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing I might change here is the host, given that someone can test against a Terraform Enterprise installation where the host might not necessarily match with
app...terraform...io
. The best choice here would be to stick the value ofTFE_ADDRESS
into the regexp.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I see the problem. Is the rest of the URL for the webhook standard or can the endpoint and/or the UUID part also change on TFE?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find a way to easily access the Config object used to create the test client, so I called DefaultConfig() myself for its Address field. DefaultConfig() function handles all cases with
TFE_ADDRESS
andTFE_HOSTNAME
env variables (or lack thereof) so I thought it would be best to use it instead of justTFE_ADDRESS
. If there is a better/cleaner way, feel free to point me in the right direction