1
0
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:
nbari
2016-10-24 12:23:58 +02:00
parent cc008b463c
commit 83692b27d1
4 changed files with 28 additions and 7 deletions

View File

@ -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"))