From 7afb609c2adce81bbfa733df01c77434ba624874 Mon Sep 17 00:00:00 2001 From: Alok Menghrajani Date: Tue, 12 Jul 2016 13:11:36 -0700 Subject: [PATCH] Adds a test to illustrate bug with listing deleted secrets with no content. --- cache_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cache_test.go b/cache_test.go index 28bb093..d530690 100644 --- a/cache_test.go +++ b/cache_test.go @@ -375,6 +375,25 @@ func TestCacheSecretListDoesNotOverrideWithEmptyContent(t *testing.T) { assert.Equal(1, cache.Len()) } +func TestCacheSecretListDoesNotReturnDeletedEmptyContentSecrets(t *testing.T) { + assert := assert.New(t) + + secretFixture, _ := ParseSecret(fixture("secret.json")) + secretFixture.Content = []byte{} + + fake_clock := time.Now() + cache := NewCache(DeletedBackend{}, timeouts, logConfig, func() time.Time { return fake_clock }) + secret, ok := cache.Secret(secretFixture.Name) + assert.False(ok) + assert.Nil(secret) + + cache.Add(*secretFixture) + + list := cache.SecretList() + assert.Len(list, 0) +} + + // An interesting test to write might be a combination of data being returned and deleted. // E.g. // Get content A.