diff --git a/auth/credential_store_test.go b/auth/credential_store_test.go index eb9cee97..ba1b143b 100644 --- a/auth/credential_store_test.go +++ b/auth/credential_store_test.go @@ -62,6 +62,32 @@ func Test_HashCache(t *testing.T) { } } +func Test_AuthLoadEmpty(t *testing.T) { + const jsonStream = `[]` + + store := NewCredentialsStore() + if err := store.Load(strings.NewReader(jsonStream)); err != nil { + t.Fatalf("failed to load empty JSON: %s", err.Error()) + } +} + +func Test_AuthLoadMalformed(t *testing.T) { + const jsonStream = ` + [ + { + "username": "username1", + "password": "password1", + "perms": ["foo", "bar" + } + ] + ` + + store := NewCredentialsStore() + if err := store.Load(strings.NewReader(jsonStream)); err == nil { + t.Fatalf("expected error for malformed JSON input") + } +} + func Test_AuthLoadSingle(t *testing.T) { const jsonStream = ` [