Add browser search and richer URL matching
This commit is contained in:
@@ -149,6 +149,27 @@ func TestHandleRequestGetLogin(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleRequestSearchLogins(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client := &fakeClient{
|
||||
entries: []*keepassgov1.Entry{
|
||||
{Id: "rusty-gitlab", Title: "Rusty GitLab", Username: "rustyryan", Url: "gitlab.com", Path: []string{"Joe", "Internet"}},
|
||||
},
|
||||
}
|
||||
resp := HandleRequest(context.Background(), Request{
|
||||
Action: "search-logins",
|
||||
BearerToken: "secret",
|
||||
Query: "GitLab",
|
||||
}, "", client)
|
||||
if !resp.Success {
|
||||
t.Fatalf("HandleRequest(search-logins) success = false, error = %q", resp.Error)
|
||||
}
|
||||
if len(resp.SearchResults) != 1 || resp.SearchResults[0].ID != "rusty-gitlab" {
|
||||
t.Fatalf("HandleRequest(search-logins).SearchResults = %#v, want rusty-gitlab", resp.SearchResults)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleRequestFindLoginsInfersLockedStatusFromRPC(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -309,9 +330,11 @@ func TestEnsureNativeHostManifestsInstallsFirefoxAndDiscoveredChromium(t *testin
|
||||
type fakeClient struct {
|
||||
status *keepassgov1.GetSessionStatusResponse
|
||||
matches []*keepassgov1.BrowserLoginMatch
|
||||
entries []*keepassgov1.Entry
|
||||
credential *keepassgov1.GetBrowserCredentialResponse
|
||||
err error
|
||||
matchesErr error
|
||||
entriesErr error
|
||||
credentialErr error
|
||||
statusCalls int
|
||||
}
|
||||
@@ -382,6 +405,16 @@ func (f *fakeClient) FindBrowserLogins(context.Context, string) ([]*keepassgov1.
|
||||
return f.matches, nil
|
||||
}
|
||||
|
||||
func (f *fakeClient) ListEntries(context.Context, []string, string) ([]*keepassgov1.Entry, error) {
|
||||
if f.entriesErr != nil {
|
||||
return nil, f.entriesErr
|
||||
}
|
||||
if f.err != nil {
|
||||
return nil, f.err
|
||||
}
|
||||
return f.entries, nil
|
||||
}
|
||||
|
||||
func (f *fakeClient) GetBrowserCredential(context.Context, string, string) (*keepassgov1.GetBrowserCredentialResponse, error) {
|
||||
if f.credentialErr != nil {
|
||||
return nil, f.credentialErr
|
||||
|
||||
Reference in New Issue
Block a user