(t *testing.T)
| 80 | } |
| 81 | |
| 82 | func TestMemoryStoreWithoutFallback(t *testing.T) { |
| 83 | config := map[string]types.AuthConfig{ |
| 84 | "https://example.test": { |
| 85 | Username: "something-something", |
| 86 | ServerAddress: "https://example.test", |
| 87 | Auth: "super_secret_token", |
| 88 | }, |
| 89 | } |
| 90 | |
| 91 | memoryStore, err := New(WithAuthConfig(config)) |
| 92 | assert.NilError(t, err) |
| 93 | |
| 94 | t.Run("get credentials from memory store without fallback", func(t *testing.T) { |
| 95 | c, err := memoryStore.Get("https://example.test") |
| 96 | assert.NilError(t, err) |
| 97 | assert.Equal(t, c, config["https://example.test"]) |
| 98 | }) |
| 99 | |
| 100 | t.Run("get non-existing credentials from memory store should error", func(t *testing.T) { |
| 101 | _, err := memoryStore.Get("https://not-in-store.example.test") |
| 102 | assert.Check(t, is.ErrorIs(err, errValueNotFound)) |
| 103 | }) |
| 104 | |
| 105 | t.Run("case store credentials", func(t *testing.T) { |
| 106 | err := memoryStore.Store(types.AuthConfig{ |
| 107 | Username: "not-in-store", |
| 108 | ServerAddress: "https://not-in-store.example.test", |
| 109 | Auth: "not-in-store_token", |
| 110 | }) |
| 111 | assert.NilError(t, err) |
| 112 | c, err := memoryStore.Get("https://not-in-store.example.test") |
| 113 | assert.NilError(t, err) |
| 114 | assert.Equal(t, c.Username, "not-in-store") |
| 115 | assert.Equal(t, c.ServerAddress, "https://not-in-store.example.test") |
| 116 | assert.Equal(t, c.Auth, "not-in-store_token") |
| 117 | }) |
| 118 | |
| 119 | t.Run("delete credentials should remove credentials from memory store", func(t *testing.T) { |
| 120 | err := memoryStore.Store(types.AuthConfig{ |
| 121 | Username: "a-new-credential", |
| 122 | ServerAddress: "https://a-new-credential.example.test", |
| 123 | Auth: "a-new-credential_token", |
| 124 | }) |
| 125 | assert.NilError(t, err) |
| 126 | err = memoryStore.Erase("https://a-new-credential.example.test") |
| 127 | assert.NilError(t, err) |
| 128 | _, err = memoryStore.Get("https://a-new-credential.example.test") |
| 129 | assert.Check(t, is.ErrorIs(err, errValueNotFound)) |
| 130 | }) |
| 131 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…