Skip to content
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

make sure pki IDs are unique #1611

Merged
merged 1 commit into from
Aug 1, 2022
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
2 changes: 1 addition & 1 deletion dependency/vault_pki.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (d *VaultPKIQuery) Stop() {

// String returns the human-friendly version of this dependency.
func (d *VaultPKIQuery) String() string {
return fmt.Sprintf("vault.pki(%s)", d.pkiPath)
return fmt.Sprintf("vault.pki(%s->%s)", d.pkiPath, d.filePath)
}

// Type returns the type of this dependency.
Expand Down
10 changes: 10 additions & 0 deletions dependency/vault_pki_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ import (
"github.com/hashicorp/vault/api"
)

func Test_VaultPKI_uniqueID(t *testing.T) {
d1, _ := NewVaultPKIQuery("pki/issue/example-dot-com", "/unique_1", nil)
id1 := d1.String()
d2, _ := NewVaultPKIQuery("pki/issue/example-dot-com", "/unique_2", nil)
id2 := d2.String()
if id1 == id2 {
t.Errorf("IDs should be unique.\n%s\n%s", id1, id2)
}
}

func Test_VaultPKI_notGoodFor(t *testing.T) {
// only test the negation, postive is tested below with pemsificates
// fetched in Vault integration tests (creating pemss is non-trivial)
Expand Down
6 changes: 4 additions & 2 deletions template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1964,7 +1964,8 @@ func TestTemplate_Execute(t *testing.T) {
{
"func_pkiCert",
&NewTemplateInput{
Contents: `{{ with pkiCert "pki/issue/egs-dot-com" }}{{.Cert}}{{end}}`,
Contents: `{{ with pkiCert "pki/issue/egs-dot-com" }}{{.Cert}}{{end}}`,
Destination: "/dev/null",
},
&ExecuteInput{
Brain: func() *Brain {
Expand All @@ -1983,7 +1984,8 @@ func TestTemplate_Execute(t *testing.T) {
{
"func_pkiCert_Data_compat",
&NewTemplateInput{
Contents: `{{ with pkiCert "pki/issue/egs-dot-com" }}{{.Data.Cert}}{{end}}`,
Contents: `{{ with pkiCert "pki/issue/egs-dot-com" }}{{.Data.Cert}}{{end}}`,
Destination: "/dev/null",
},
&ExecuteInput{
Brain: func() *Brain {
Expand Down