-
Notifications
You must be signed in to change notification settings - Fork 3
VAULT-38191/use artifactory identity token in tests #34
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
Changes from all commits
f9ae8cf
bb3c0b9
df0a0e6
63fac7e
e3225a5
f7ad6ed
836b173
c89fb3e
9d9cedf
05b469b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 0.6.1 | ||
| 0.6.2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,12 +15,12 @@ import ( | |
| "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
| ) | ||
|
|
||
| // TestAccDataSourceArtifacotoryItemProperties is an integration test that uses the | ||
| // TestAccDataSourceArtifactoryItemProperties is an integration test that uses the | ||
| // actual HashiCorp artifactory service to resolve items based on the search | ||
| // criteria. | ||
| // | ||
| //nolint:paralleltest// because our resource handles it | ||
| func TestAccDataSourceArtifacotoryItemProperties(t *testing.T) { | ||
|
Collaborator
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. Hey now, fixing typos that are like 4 years old.
Collaborator
Author
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. 😎 🧹 |
||
| func TestAccDataSourceArtifactoryItemProperties(t *testing.T) { | ||
| for name, props := range map[string]map[string]string{ | ||
| "vault-1.18.5-1.x86_64.rpm": { | ||
| "commit": "06a36557c4904c52f720bafb71866d389385f5ad", | ||
|
|
@@ -35,11 +35,20 @@ func TestAccDataSourceArtifacotoryItemProperties(t *testing.T) { | |
| t.Run(name, func(t *testing.T) { | ||
| state := newArtifactoryItemStateV1() | ||
| _, okacc := os.LookupEnv("TF_ACC") | ||
| username, _ := os.LookupEnv("ARTIFACTORY_USER") | ||
| token, oktoken := os.LookupEnv("ARTIFACTORY_TOKEN") | ||
| var token string | ||
| var okbearertoken, oktoken bool | ||
| username, okuser := os.LookupEnv("ARTIFACTORY_USER") | ||
| if !okuser { | ||
| token, okbearertoken = os.LookupEnv("ARTIFACTORY_BEARER_TOKEN") | ||
| } else { | ||
| token, oktoken = os.LookupEnv("ARTIFACTORY_TOKEN") | ||
| } | ||
|
|
||
| if !okacc || !oktoken { | ||
| t.Log(`skipping data "enos_artifactory_item" test because either TF_ACC or ARTIFACTORY_TOKEN are not set`) | ||
| t.Logf(`skipping data "enos_artifactory_item" test because one or more of the following isn't set: | ||
| TF_ACC(%t), ARTIFACTORY_TOKEN(%t), ARTIFACTORY_BEARER_TOKEN(%t)`, | ||
| okacc, oktoken, okbearertoken, | ||
| ) | ||
| t.Skip() | ||
|
|
||
| return | ||
|
|
@@ -95,12 +104,12 @@ output "name" { | |
| } | ||
| } | ||
|
|
||
| // TestAccDataSourceArtifacotoryItemQueryTemplate is an integration test that | ||
| // TestAccDataSourceArtifactoryItemQueryTemplate is an integration test that | ||
| // uses the actual HashiCorp artifactory service to resolve items based on the | ||
| // search criteria. | ||
| // | ||
| //nolint:paralleltest// because our resource handles it | ||
| func TestAccDataSourceArtifacotoryItemQueryTemplate(t *testing.T) { | ||
| func TestAccDataSourceArtifactoryItemQueryTemplate(t *testing.T) { | ||
| orQueryTemplate := template.Must(template.New("or").Parse(` | ||
| items.find( | ||
| { | ||
|
|
@@ -137,11 +146,20 @@ items.find( | |
| t.Run(name, func(t *testing.T) { | ||
| state := newArtifactoryItemStateV1() | ||
| _, okacc := os.LookupEnv("TF_ACC") | ||
| username, _ := os.LookupEnv("ARTIFACTORY_USER") | ||
| token, oktoken := os.LookupEnv("ARTIFACTORY_TOKEN") | ||
| var token string | ||
| var okbearertoken, oktoken bool | ||
| username, okuser := os.LookupEnv("ARTIFACTORY_USER") | ||
| if !okuser { | ||
| token, okbearertoken = os.LookupEnv("ARTIFACTORY_BEARER_TOKEN") | ||
| } else { | ||
| token, oktoken = os.LookupEnv("ARTIFACTORY_TOKEN") | ||
| } | ||
|
|
||
| if !okacc || !oktoken { | ||
| t.Log(`skipping data "enos_artifactory_item" test because either TF_ACC or ARTIFACTORY_TOKEN are not set`) | ||
| if !okacc || (okuser && !oktoken) || (!okuser && !okbearertoken) { | ||
| t.Logf(`skipping data "enos_artifactory_item" test because one or more of the following isn't set: | ||
| TF_ACC(%t), ARTIFACTORY_TOKEN(%t), ARTIFACTORY_BEARER_TOKEN(%t)`, | ||
| okacc, oktoken, okbearertoken, | ||
| ) | ||
| t.Skip() | ||
|
|
||
| return | ||
|
|
@@ -163,7 +181,9 @@ items.find( | |
| state.QueryTemplate.Set(qbuf.String()) | ||
|
|
||
| cfg := template.Must(template.New("enos_data_artifactory_item").Parse(`data "enos_artifactory_item" "vault" { | ||
| {{if .Username.Value -}} | ||
| username = "{{ .Username.Value }}" | ||
|
Collaborator
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. Sorta surprised that this works. I would have expected us to require setting username to null when the value doesn't exist.
Collaborator
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. Ah, the datasource has the username marked as optional, as it should: https://github.com/hashicorp-forge/terraform-provider-enos/blob/main/internal/plugin/datasource_artifactory_item.go#L208 |
||
| {{end -}} | ||
| token = "{{ .Token.Value }}" | ||
| host = "{{ .Host.Value }}" | ||
| query_template = <<EOT | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.