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

deleting secret_references from computed agent policy #2876

Merged
merged 3 commits into from
Aug 15, 2023
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 internal/pkg/policy/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func getPolicyInputsWithSecrets(ctx context.Context, fields map[string]json.RawM
}
result = append(result, newInput)
}
delete(fields, "secret_references")
return result, nil
}

Expand Down
11 changes: 11 additions & 0 deletions internal/pkg/policy/secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ func TestReplaceSecretRefPartial(t *testing.T) {
assert.Equal(t, "partial value1", val)
}

func TestReplaceSecretRefPartial2(t *testing.T) {
secretRefs := map[string]string{
"abcd": "http://localhost",
}
val := replaceSecretRef("$co.elastic.secret{abcd}/services", secretRefs)
assert.Equal(t, "http://localhost/services", val)
}

func TestReplaceSecretRefNotASecret(t *testing.T) {
secretRefs := map[string]string{
"abcd": "value1",
Expand Down Expand Up @@ -97,6 +105,9 @@ func TestGetPolicyInputsWithSecretsAndStreams(t *testing.T) {
result, _ := getPolicyInputsWithSecrets(context.TODO(), fields, bulker)

assert.Equal(t, expectedResult, result)
var refs any
json.Unmarshal(fields["secret_references"], &refs)
assert.Equal(t, nil, refs)
}

func TestGetPolicyInputsNoopWhenNoSecrets(t *testing.T) {
Expand Down
Loading