mirror of
https://github.com/ssh-vault/ssh-vault.git
synced 2025-07-04 14:22:28 +03:00
modified: cache_test.go
modified: getkey.go modified: getkey_test.go modified: vault.go
This commit is contained in:
@ -7,7 +7,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetKeyFound(t *testing.T) {
|
||||
func TestGetKeyFoundURL(t *testing.T) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
expect(t, "ssh-vault", r.Header.Get("User-agent"))
|
||||
fmt.Fprintln(w, "ssh-rsa ABC")
|
||||
@ -22,6 +22,21 @@ func TestGetKeyFound(t *testing.T) {
|
||||
expect(t, 1, len(s))
|
||||
}
|
||||
|
||||
func TestGetKeyFoundUser(t *testing.T) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
expect(t, "ssh-vault", r.Header.Get("User-agent"))
|
||||
fmt.Fprintln(w, "ssh-rsa ABC")
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
||||
l := Locksmith{ts.URL}
|
||||
s, err := l.GetKey("bob")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
expect(t, 1, len(s))
|
||||
}
|
||||
|
||||
func TestGetKeyNotFound(t *testing.T) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
expect(t, "ssh-vault", r.Header.Get("User-agent"))
|
||||
|
Reference in New Issue
Block a user