-
Notifications
You must be signed in to change notification settings - Fork 0
feat(credstore): expose 1Password backends #63
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
eb0e0b7
feat(credstore): support 1password backends
rianjs 421ac60
fix(credstore): harden 1password backend defaults
rianjs c8f5169
docs(credstore): clarify 1password backend auth env vars
rianjs bc08bb7
test(credstore): pin 1password build modes
rianjs 410e43f
docs(credstore): document 1password build tradeoffs
rianjs 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package credstore | ||
|
|
||
| import "testing" | ||
|
|
||
| func TestUnsupportedOnePasswordBackendInBuild_NonOnePasswordBackendsPass(t *testing.T) { | ||
| for _, kind := range []Backend{BackendKeychain, BackendWinCred, BackendSecretService, BackendFile, BackendPass, BackendMemory} { | ||
| if err := unsupportedOnePasswordBackendInBuild(kind); err != nil { | ||
| t.Fatalf("unsupportedOnePasswordBackendInBuild(%q) = %v, want nil", kind, err) | ||
| } | ||
| } | ||
| } |
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,14 @@ | ||
| //go:build keyring_no1password | ||
|
|
||
| package credstore | ||
|
|
||
| import "fmt" | ||
|
|
||
| func unsupportedOnePasswordBackendInBuild(kind Backend) error { | ||
| switch kind { | ||
| case BackendOP, BackendOPConnect, BackendOPDesktop: | ||
| return fmt.Errorf("%w: backend %q was compiled out of this build via keyring_no1password", ErrBackendNotImplemented, kind) | ||
| default: | ||
| return nil | ||
| } | ||
| } |
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,28 @@ | ||
| //go:build keyring_no1password | ||
|
|
||
| package credstore | ||
|
|
||
| import ( | ||
| "errors" | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestUnsupportedOnePasswordBackendInBuild_DisabledBuildRejectsOnePasswordBackends(t *testing.T) { | ||
| for _, kind := range []Backend{BackendOP, BackendOPConnect, BackendOPDesktop} { | ||
| err := unsupportedOnePasswordBackendInBuild(kind) | ||
| if !errors.Is(err, ErrBackendNotImplemented) { | ||
| t.Fatalf("unsupportedOnePasswordBackendInBuild(%q) = %v, want ErrBackendNotImplemented", kind, err) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func TestOpen_OnePasswordDisabledBuildRejectsOnePasswordBackends(t *testing.T) { | ||
| for _, kind := range []Backend{BackendOP, BackendOPConnect, BackendOPDesktop} { | ||
| t.Run(string(kind), func(t *testing.T) { | ||
| _, err := Open("credstore-optest", &Options{Backend: kind}) | ||
| if !errors.Is(err, ErrBackendNotImplemented) { | ||
| t.Fatalf("Open(%q) = %v, want ErrBackendNotImplemented", kind, err) | ||
| } | ||
| }) | ||
| } | ||
| } |
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,7 @@ | ||
| //go:build !keyring_no1password | ||
|
|
||
| package credstore | ||
|
|
||
| func unsupportedOnePasswordBackendInBuild(Backend) error { | ||
| return nil | ||
| } |
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,25 @@ | ||
| //go:build !keyring_no1password && !freebsd && (cgo || windows) | ||
|
|
||
| package credstore | ||
|
|
||
| import ( | ||
| "errors" | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestOpenOSBackend_OnePasswordEnabledBuildReachesBackendValidation(t *testing.T) { | ||
| t.Setenv("OP_VAULT_ID", "") | ||
| t.Setenv("OP_CONNECT_HOST", "") | ||
| t.Setenv("OP_DESKTOP_ACCOUNT_ID", "") | ||
| for _, kind := range []Backend{BackendOP, BackendOPConnect, BackendOPDesktop} { | ||
| t.Run(string(kind), func(t *testing.T) { | ||
| _, err := openOSBackend(kind, "credstore-optest", &Options{}, func(string) string { return "" }) | ||
| if err == nil { | ||
| t.Fatal("openOSBackend unexpectedly succeeded without required 1Password configuration") | ||
| } | ||
| if errors.Is(err, ErrBackendNotImplemented) { | ||
| t.Fatalf("openOSBackend(%q) = %v, want enabled backend validation error, not ErrBackendNotImplemented", kind, err) | ||
| } | ||
| }) | ||
| } | ||
| } |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.