-
Notifications
You must be signed in to change notification settings - Fork 127
Feat/infisical recursive sync #327
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
Open
JRoppert
wants to merge
6
commits into
Infisical:main
Choose a base branch
from
RSE23:feat/infisical-recursive-sync
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9c867d3
feat(infisical): recursive secret sync with cross-folder duplicate-ke…
JRoppert 66a3874
feat(server): surface recursive-sync duplicate keys as external_store…
JRoppert f521886
feat(cli): add --infisical-recursive to vault create and credential-s…
JRoppert d51d8fd
feat(web): recursive sync toggle for Infisical-backed vaults
JRoppert 321914e
docs: recursive Infisical sync option
JRoppert 6595940
Merge branch 'main' into feat/infisical-recursive-sync
JRoppert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| package infisical | ||
|
|
||
| import ( | ||
| "errors" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/infisical/go-sdk/packages/models" | ||
| ) | ||
|
|
||
| func TestListSecretsOptions_NonRecursiveUnchanged(t *testing.T) { | ||
| opts := listSecretsOptions(VaultConfig{ProjectID: "p", Environment: "dev", SecretPath: "/app"}) | ||
| if opts.ProjectID != "p" || opts.Environment != "dev" || opts.SecretPath != "/app" { | ||
| t.Fatalf("config fields not passed through: %+v", opts) | ||
| } | ||
| if !opts.ExpandSecretReferences { | ||
| t.Fatalf("ExpandSecretReferences must stay enabled") | ||
| } | ||
| if opts.Recursive || opts.SkipUniqueValidation { | ||
| t.Fatalf("non-recursive config must not set Recursive/SkipUniqueValidation: %+v", opts) | ||
| } | ||
| } | ||
|
|
||
| // TestListSecretsOptions_RecursiveSetsSkipUniqueValidation: SkipUniqueValidation | ||
| // must accompany Recursive — without it the SDK dedups cross-folder duplicates | ||
| // by key with an arbitrary winner before we can detect and reject them. | ||
| func TestListSecretsOptions_RecursiveSetsSkipUniqueValidation(t *testing.T) { | ||
| opts := listSecretsOptions(VaultConfig{ProjectID: "p", Environment: "dev", SecretPath: "/", Recursive: true}) | ||
| if !opts.Recursive { | ||
| t.Fatalf("Recursive not set") | ||
| } | ||
| if !opts.SkipUniqueValidation { | ||
| t.Fatalf("SkipUniqueValidation must be set when Recursive is") | ||
| } | ||
| } | ||
|
|
||
| func TestSecretsFromList_MapsKeysAndValues(t *testing.T) { | ||
| raw := []models.Secret{ | ||
| {SecretKey: "ALPHA", SecretValue: "a", SecretPath: "/"}, | ||
| {SecretKey: "BETA", SecretValue: "b", SecretPath: "/sub"}, | ||
| } | ||
| secs, err := secretsFromList(raw, true) | ||
| if err != nil { | ||
| t.Fatalf("unexpected error: %v", err) | ||
| } | ||
| if len(secs) != 2 || secs[0] != (Secret{Key: "ALPHA", Value: "a"}) || secs[1] != (Secret{Key: "BETA", Value: "b"}) { | ||
| t.Fatalf("bad mapping: %+v", secs) | ||
| } | ||
| } | ||
|
|
||
| func TestSecretsFromList_DuplicateAcrossFolders(t *testing.T) { | ||
| raw := []models.Secret{ | ||
| {SecretKey: "TOKEN", SecretValue: "1", SecretPath: "/stripe"}, | ||
| {SecretKey: "TOKEN", SecretValue: "2", SecretPath: "/github"}, | ||
| {SecretKey: "OTHER", SecretValue: "3", SecretPath: "/"}, | ||
| } | ||
| _, err := secretsFromList(raw, true) | ||
| if !errors.Is(err, ErrDuplicateKey) { | ||
| t.Fatalf("expected ErrDuplicateKey, got %v", err) | ||
| } | ||
| for _, want := range []string{`"TOKEN"`, "/github", "/stripe"} { | ||
| if !strings.Contains(err.Error(), want) { | ||
| t.Errorf("error %q missing %q", err, want) | ||
| } | ||
| } | ||
|
|
||
| // The SDK refills its result slice from a map, so input order is | ||
| // nondeterministic — the formatted error must not depend on it. | ||
| reversed := []models.Secret{raw[2], raw[1], raw[0]} | ||
| _, err2 := secretsFromList(reversed, true) | ||
| if err2 == nil || err2.Error() != err.Error() { | ||
| t.Fatalf("error text must be deterministic:\n%v\n%v", err, err2) | ||
| } | ||
| } | ||
|
|
||
| // Defensive: in non-recursive mode the SDK already dedups by key, so the | ||
| // collision check must not run (and must not reject) there. | ||
| func TestSecretsFromList_NonRecursiveSkipsDuplicateCheck(t *testing.T) { | ||
| raw := []models.Secret{ | ||
| {SecretKey: "TOKEN", SecretValue: "1"}, | ||
| {SecretKey: "TOKEN", SecretValue: "2"}, | ||
| } | ||
| secs, err := secretsFromList(raw, false) | ||
| if err != nil { | ||
| t.Fatalf("unexpected error: %v", err) | ||
| } | ||
| if len(secs) != 2 { | ||
| t.Fatalf("expected passthrough of 2 secrets, got %d", len(secs)) | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
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.
When
vault credential-store setupdates an existing recursive store without repeating--infisical-recursive,GetBoolreturns the flag default and the payload sendsrecursive: false. Existing scripts that only change another setting therefore silently disable recursive sync and drop subfolder secrets from the next snapshot.