From 42aa2d3b5114c78fff64ff97eebb6cec53a44585 Mon Sep 17 00:00:00 2001 From: Ty Lange-Smith Date: Wed, 3 Nov 2021 09:35:06 +1100 Subject: [PATCH] Remove redundant tests --- access/resource_secret_acl_test.go | 197 ----------------------------- 1 file changed, 197 deletions(-) diff --git a/access/resource_secret_acl_test.go b/access/resource_secret_acl_test.go index e47d8a4eaf..2845a2bb1e 100644 --- a/access/resource_secret_acl_test.go +++ b/access/resource_secret_acl_test.go @@ -79,74 +79,6 @@ func TestSecretsScopesAclsIntegration(t *testing.T) { assert.NoError(t, err, err) } -func TestSecretsScopesAclsIntegration_ScopeWithSlash(t *testing.T) { - cloud := os.Getenv("CLOUD_ENV") - if cloud == "" { - t.Skip("Acceptance tests skipped unless env 'CLOUD_ENV' is set") - } - client := common.NewClientFromEnvironment() - ctx := context.Background() - scopesAPI := NewSecretScopesAPI(ctx, client) - secretsAPI := NewSecretsAPI(ctx, client) - secretAclsAPI := NewSecretAclsAPI(ctx, client) - - testScope := "myapplication/branch" - testKey := "my-test-key" - testSecret := "my-test-secret" - initialManagePrincipal := "" - // TODO: on random group - testPrincipal := "users" - - err := scopesAPI.Create(SecretScope{ - Name: testScope, - InitialManagePrincipal: initialManagePrincipal, - }) - assert.NoError(t, err, err) - - defer func() { - // Deleting scope deletes everything else - err := scopesAPI.Delete(testScope) - assert.NoError(t, err, err) - }() - - scopes, err := scopesAPI.List() - assert.NoError(t, err, err) - assert.True(t, len(scopes) >= 1, "Scopes are empty list") - - scope, err := scopesAPI.Read(testScope) - assert.NoError(t, err, err) - assert.Equal(t, testScope, scope.Name, "Scope lookup does not yield same scope") - - err = secretsAPI.Create(testSecret, testScope, testKey) - assert.NoError(t, err, err) - - secrets, err := secretsAPI.List(testScope) - assert.NoError(t, err, err) - assert.True(t, len(secrets) > 0, "Secrets are empty list") - - secret, err := secretsAPI.Read(testScope, testKey) - assert.NoError(t, err, err) - assert.Equal(t, testKey, secret.Key, "Secret lookup does not yield same key") - - err = secretAclsAPI.Create(testScope, testPrincipal, ACLPermissionManage) - assert.NoError(t, err, err) - - secretAcls, err := secretAclsAPI.List(testScope) - assert.NoError(t, err, err) - assert.True(t, len(secretAcls) > 0, "Secrets acls are empty list") - - secretACL, err := secretAclsAPI.Read(testScope, testPrincipal) - assert.NoError(t, err, err) - assert.Equal(t, testPrincipal, secretACL.Principal, "Secret lookup does not yield same key") - assert.Equal(t, ACLPermissionManage, secretACL.Permission, "Secret lookup does not yield same key") - - err = secretsAPI.Delete(testScope, testKey) - assert.NoError(t, err, err) - - err = secretAclsAPI.Delete(testScope, testPrincipal) - assert.NoError(t, err, err) -} - func TestResourceSecretACLRead(t *testing.T) { d, err := qa.ResourceFixture{ Fixtures: []qa.HTTPFixture{ @@ -169,28 +101,6 @@ func TestResourceSecretACLRead(t *testing.T) { assert.Equal(t, "global", d.Get("scope")) } -func TestResourceSecretACLRead_ScopeWithSlash(t *testing.T) { - d, err := qa.ResourceFixture{ - Fixtures: []qa.HTTPFixture{ - { - Method: "GET", - Resource: "/api/2.0/secrets/acls/get?principal=something&scope=myapplication%2Fbranch", - Response: ACLItem{ - Permission: "CAN_MANAGE", - }, - }, - }, - Resource: ResourceSecretACL(), - Read: true, - ID: "myapplication/branch|||something", - }.Apply(t) - assert.NoError(t, err, err) - assert.Equal(t, "myapplication/branch|||something", d.Id(), "Id should not be empty") - assert.Equal(t, "CAN_MANAGE", d.Get("permission")) - assert.Equal(t, "something", d.Get("principal")) - assert.Equal(t, "myapplication/branch", d.Get("scope")) -} - func TestResourceSecretACLRead_NotFound(t *testing.T) { qa.ResourceFixture{ Fixtures: []qa.HTTPFixture{ @@ -211,26 +121,6 @@ func TestResourceSecretACLRead_NotFound(t *testing.T) { }.ApplyNoError(t) } -func TestResourceSecretACLRead_ScopeWithSlash_NotFound(t *testing.T) { - qa.ResourceFixture{ - Fixtures: []qa.HTTPFixture{ - { - Method: "GET", - Resource: "/api/2.0/secrets/acls/get?principal=something&scope=myapplication%2Fbranch", - Response: common.APIErrorBody{ - ErrorCode: "NOT_FOUND", - Message: "Item not found", - }, - Status: 404, - }, - }, - Resource: ResourceSecretACL(), - Read: true, - Removed: true, - ID: "myapplication/branch|||something", - }.ApplyNoError(t) -} - func TestResourceSecretACLRead_Error(t *testing.T) { d, err := qa.ResourceFixture{ Fixtures: []qa.HTTPFixture{ @@ -252,27 +142,6 @@ func TestResourceSecretACLRead_Error(t *testing.T) { assert.Equal(t, "global|||something", d.Id(), "Id should not be empty for error reads") } -func TestResourceSecretACLRead_ScopeWithSlash_Error(t *testing.T) { - d, err := qa.ResourceFixture{ - Fixtures: []qa.HTTPFixture{ - { - Method: "GET", - Resource: "/api/2.0/secrets/acls/get?principal=something&scope=myapplication%2Fbranch", - Response: common.APIErrorBody{ - ErrorCode: "INVALID_REQUEST", - Message: "Internal error happened", - }, - Status: 400, - }, - }, - Resource: ResourceSecretACL(), - Read: true, - ID: "myapplication/branch|||something", - }.Apply(t) - qa.AssertErrorStartsWith(t, err, "Internal error happened") - assert.Equal(t, "myapplication/branch|||something", d.Id(), "Id should not be empty for error reads") -} - func TestResourceSecretACLCreate(t *testing.T) { d, err := qa.ResourceFixture{ Fixtures: []qa.HTTPFixture{ @@ -362,31 +231,6 @@ func TestResourceSecretACLCreate_Error(t *testing.T) { assert.Equal(t, "", d.Id(), "Id should be empty for error creates") } -func TestResourceSecretACLCreate_ScopeWithSlash_Error(t *testing.T) { - d, err := qa.ResourceFixture{ - Fixtures: []qa.HTTPFixture{ - { // read log output for better stub url... - Method: "POST", - Resource: "/api/2.0/secrets/acls/put", - Response: common.APIErrorBody{ - ErrorCode: "INVALID_REQUEST", - Message: "Internal error happened", - }, - Status: 400, - }, - }, - Resource: ResourceSecretACL(), - State: map[string]interface{}{ - "permission": "CAN_MANAGE", - "principal": "something", - "scope": "myapplication/branch", - }, - Create: true, - }.Apply(t) - qa.AssertErrorStartsWith(t, err, "Internal error happened") - assert.Equal(t, "", d.Id(), "Id should be empty for error creates") -} - func TestResourceSecretACLDelete(t *testing.T) { d, err := qa.ResourceFixture{ Fixtures: []qa.HTTPFixture{ @@ -407,26 +251,6 @@ func TestResourceSecretACLDelete(t *testing.T) { assert.Equal(t, "global|||something", d.Id()) } -func TestResourceSecretACLDelete_ScopeWithSlash(t *testing.T) { - d, err := qa.ResourceFixture{ - Fixtures: []qa.HTTPFixture{ - { - Method: "POST", - Resource: "/api/2.0/secrets/acls/delete", - ExpectedRequest: map[string]string{ - "scope": "myapplication/branch", - "principal": "something", - }, - }, - }, - Resource: ResourceSecretACL(), - Delete: true, - ID: "myapplication/branch|||something", - }.Apply(t) - assert.NoError(t, err, err) - assert.Equal(t, "myapplication/branch|||something", d.Id()) -} - func TestResourceSecretACLDelete_Error(t *testing.T) { d, err := qa.ResourceFixture{ Fixtures: []qa.HTTPFixture{ @@ -447,24 +271,3 @@ func TestResourceSecretACLDelete_Error(t *testing.T) { qa.AssertErrorStartsWith(t, err, "Internal error happened") assert.Equal(t, "global|||something", d.Id()) } - -func TestResourceSecretACLDelete_ScopeWithSlash_Error(t *testing.T) { - d, err := qa.ResourceFixture{ - Fixtures: []qa.HTTPFixture{ - { - Method: "POST", - Resource: "/api/2.0/secrets/acls/delete", - Response: common.APIErrorBody{ - ErrorCode: "INVALID_REQUEST", - Message: "Internal error happened", - }, - Status: 400, - }, - }, - Resource: ResourceSecretACL(), - Delete: true, - ID: "myapplication/branch|||something", - }.Apply(t) - qa.AssertErrorStartsWith(t, err, "Internal error happened") - assert.Equal(t, "myapplication/branch|||something", d.Id()) -}