Added AcceptanceTest boolean to logical.TestCase

This commit is contained in:
vishalnayak
2016-04-05 15:10:44 -04:00
parent 254023f55c
commit ac5ceae0bd
16 changed files with 174 additions and 102 deletions

View File

@@ -10,6 +10,7 @@ import (
func TestBackend_basic(t *testing.T) {
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Factory: Factory,
Steps: []logicaltest.TestStep{
testAccStepMapAppId(t),
@@ -25,6 +26,7 @@ func TestBackend_basic(t *testing.T) {
func TestBackend_cidr(t *testing.T) {
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Factory: Factory,
Steps: []logicaltest.TestStep{
testAccStepMapAppIdDisplayName(t),
@@ -38,6 +40,7 @@ func TestBackend_cidr(t *testing.T) {
func TestBackend_displayName(t *testing.T) {
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Factory: Factory,
Steps: []logicaltest.TestStep{
testAccStepMapAppIdDisplayName(t),

View File

@@ -48,6 +48,7 @@ func TestBackend_CertWrites(t *testing.T) {
}
tc := logicaltest.TestCase{
AcceptanceTest: true,
Backend: testFactory(t),
Steps: []logicaltest.TestStep{
testAccStepCert(t, "aaa", ca1, "foo", false),
@@ -68,6 +69,7 @@ func TestBackend_basic_CA(t *testing.T) {
t.Fatalf("err: %v", err)
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Backend: testFactory(t),
Steps: []logicaltest.TestStep{
testAccStepCert(t, "web", ca, "foo", false),
@@ -94,6 +96,7 @@ func TestBackend_CRLs(t *testing.T) {
t.Fatalf("err: %v", err)
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Backend: testFactory(t),
Steps: []logicaltest.TestStep{
testAccStepCertNoLease(t, "web", ca, "foo"),
@@ -116,6 +119,7 @@ func TestBackend_basic_singleCert(t *testing.T) {
t.Fatalf("err: %v", err)
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Backend: testFactory(t),
Steps: []logicaltest.TestStep{
testAccStepCert(t, "web", ca, "foo", false),
@@ -129,6 +133,7 @@ func TestBackend_untrusted(t *testing.T) {
connState := testConnState(t, "test-fixtures/keys/cert.pem",
"test-fixtures/keys/key.pem", "test-fixtures/root/rootcacert.pem")
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Backend: testFactory(t),
Steps: []logicaltest.TestStep{
testAccStepLoginInvalid(t, connState),

View File

@@ -47,6 +47,7 @@ func TestBackend_Config(t *testing.T) {
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: b,
Steps: []logicaltest.TestStep{
@@ -103,6 +104,7 @@ func TestBackend_basic(t *testing.T) {
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: b,
Steps: []logicaltest.TestStep{

View File

@@ -30,6 +30,7 @@ func TestBackend_basic(t *testing.T) {
b := factory(t)
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{
testAccStepConfigUrl(t),
@@ -45,6 +46,7 @@ func TestBackend_basic_authbind(t *testing.T) {
b := factory(t)
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{
testAccStepConfigUrlWithAuthBind(t),
@@ -60,6 +62,7 @@ func TestBackend_basic_discover(t *testing.T) {
b := factory(t)
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{
testAccStepConfigUrlWithDiscover(t),
@@ -75,6 +78,7 @@ func TestBackend_basic_nogroupdn(t *testing.T) {
b := factory(t)
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{
testAccStepConfigUrlNoGroupDN(t),
@@ -90,6 +94,7 @@ func TestBackend_groupCrud(t *testing.T) {
b := factory(t)
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{
testAccStepGroup(t, "g1", "foo"),
@@ -212,6 +217,7 @@ func TestBackend_userCrud(t *testing.T) {
b := Backend()
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{
testAccStepUser(t, "g1", "bar"),

View File

@@ -54,6 +54,7 @@ func TestBackend_TTLDurations(t *testing.T) {
t.Fatalf("Unable to create backend: %s", err)
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{
testUsersWrite(t, "test", data1, true),
@@ -78,6 +79,7 @@ func TestBackend_basic(t *testing.T) {
t.Fatalf("Unable to create backend: %s", err)
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{
testAccStepUser(t, "web", "password", "foo"),
@@ -99,6 +101,7 @@ func TestBackend_userCrud(t *testing.T) {
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{
testAccStepUser(t, "web", "password", "foo"),
@@ -122,6 +125,7 @@ func TestBackend_userCreateOperation(t *testing.T) {
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{
testUserCreateOperation(t, "web", "password", "foo"),
@@ -143,6 +147,7 @@ func TestBackend_passwordUpdate(t *testing.T) {
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{
testAccStepUser(t, "web", "password", "foo"),
@@ -168,6 +173,7 @@ func TestBackend_policiesUpdate(t *testing.T) {
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{
testAccStepUser(t, "web", "password", "foo"),

View File

@@ -26,6 +26,7 @@ func getBackend(t *testing.T) logical.Backend {
func TestBackend_basic(t *testing.T) {
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: getBackend(t),
Steps: []logicaltest.TestStep{
@@ -38,6 +39,7 @@ func TestBackend_basic(t *testing.T) {
func TestBackend_basicSTS(t *testing.T) {
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: getBackend(t),
Steps: []logicaltest.TestStep{
@@ -57,6 +59,7 @@ func TestBackend_policyCrud(t *testing.T) {
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Backend: getBackend(t),
Steps: []logicaltest.TestStep{
testAccStepConfig(t),
@@ -261,6 +264,7 @@ func testAccStepWriteArnPolicyRef(t *testing.T, name string, arn string) logical
func TestBackend_basicPolicyArnRef(t *testing.T) {
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: getBackend(t),
Steps: []logicaltest.TestStep{
@@ -273,6 +277,7 @@ func TestBackend_basicPolicyArnRef(t *testing.T) {
func TestBackend_policyArnCrud(t *testing.T) {
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Backend: getBackend(t),
Steps: []logicaltest.TestStep{
testAccStepConfig(t),

View File

@@ -15,6 +15,7 @@ func TestBackend_basic(t *testing.T) {
b := Backend()
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: b,
Steps: []logicaltest.TestStep{
@@ -29,6 +30,7 @@ func TestBackend_roleCrud(t *testing.T) {
b := Backend()
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: b,
Steps: []logicaltest.TestStep{

View File

@@ -28,6 +28,7 @@ func TestBackend_basic(t *testing.T) {
b, _ := Factory(logical.TestBackendConfig())
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: b,
Steps: []logicaltest.TestStep{
@@ -48,6 +49,7 @@ func TestBackend_management(t *testing.T) {
b, _ := Factory(logical.TestBackendConfig())
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: b,
Steps: []logicaltest.TestStep{
@@ -68,6 +70,7 @@ func TestBackend_crud(t *testing.T) {
b, _ := Factory(logical.TestBackendConfig())
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: b,
Steps: []logicaltest.TestStep{
@@ -88,6 +91,7 @@ func TestBackend_role_lease(t *testing.T) {
b, _ := Factory(logical.TestBackendConfig())
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: b,
Steps: []logicaltest.TestStep{

View File

@@ -15,6 +15,7 @@ func TestBackend_basic(t *testing.T) {
b, _ := Factory(logical.TestBackendConfig())
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: b,
Steps: []logicaltest.TestStep{
@@ -29,6 +30,7 @@ func TestBackend_roleCrud(t *testing.T) {
b := Backend()
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: b,
Steps: []logicaltest.TestStep{
@@ -45,6 +47,7 @@ func TestBackend_leaseWriteRead(t *testing.T) {
b := Backend()
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: b,
Steps: []logicaltest.TestStep{

View File

@@ -21,6 +21,7 @@ func TestBackend_basic(t *testing.T) {
"value": os.Getenv("MYSQL_DSN"),
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: b,
Steps: []logicaltest.TestStep{
@@ -49,6 +50,7 @@ func TestBackend_configConnection(t *testing.T) {
d4 := map[string]interface{}{}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: b,
Steps: []logicaltest.TestStep{
@@ -67,6 +69,7 @@ func TestBackend_roleCrud(t *testing.T) {
"connection_url": os.Getenv("MYSQL_DSN"),
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: b,
Steps: []logicaltest.TestStep{
@@ -86,6 +89,7 @@ func TestBackend_leaseWriteRead(t *testing.T) {
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: b,
Steps: []logicaltest.TestStep{

View File

@@ -54,6 +54,7 @@ func TestBackend_RSAKey(t *testing.T) {
}
testCase := logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{},
}
@@ -88,6 +89,7 @@ func TestBackend_ECKey(t *testing.T) {
}
testCase := logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{},
}
@@ -120,6 +122,7 @@ func TestBackend_CSRValues(t *testing.T) {
}
testCase := logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{},
}
@@ -152,6 +155,7 @@ func TestBackend_URLsCRUD(t *testing.T) {
}
testCase := logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{},
}
@@ -187,6 +191,7 @@ func TestBackend_RSARoles(t *testing.T) {
}
testCase := logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{
logicaltest.TestStep{
@@ -233,6 +238,7 @@ func TestBackend_RSARoles_CSR(t *testing.T) {
}
testCase := logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{
logicaltest.TestStep{
@@ -279,6 +285,7 @@ func TestBackend_ECRoles(t *testing.T) {
}
testCase := logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{
logicaltest.TestStep{
@@ -325,6 +332,7 @@ func TestBackend_ECRoles_CSR(t *testing.T) {
}
testCase := logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{
logicaltest.TestStep{

View File

@@ -24,6 +24,7 @@ func TestBackend_basic(t *testing.T) {
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: b,
Steps: []logicaltest.TestStep{
@@ -45,6 +46,7 @@ func TestBackend_roleCrud(t *testing.T) {
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: b,
Steps: []logicaltest.TestStep{
@@ -72,6 +74,7 @@ func TestBackend_configConnection(t *testing.T) {
d4 := map[string]interface{}{}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
PreCheck: func() { testAccPreCheck(t) },
Backend: b,
Steps: []logicaltest.TestStep{

View File

@@ -99,6 +99,7 @@ func TestSSHBackend_Lookup(t *testing.T) {
resp3 := []string{testDynamicRoleName, testOTPRoleName}
resp4 := []string{testDynamicRoleName}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Factory: testingFactory,
Steps: []logicaltest.TestStep{
testLookupRead(t, data, resp1),
@@ -128,6 +129,7 @@ func TestSSHBackend_DynamicKeyCreate(t *testing.T) {
"ip": testIP,
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Factory: testingFactory,
Steps: []logicaltest.TestStep{
testNamedKeysWrite(t, testKeyName, testSharedPrivateKey),
@@ -150,6 +152,7 @@ func TestSSHBackend_OTPRoleCrud(t *testing.T) {
"cidr_list": testCIDRList,
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Factory: testingFactory,
Steps: []logicaltest.TestStep{
testRoleWrite(t, testOTPRoleName, testOTPRoleData),
@@ -179,6 +182,7 @@ func TestSSHBackend_DynamicRoleCrud(t *testing.T) {
"key_type": testDynamicKeyType,
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Factory: testingFactory,
Steps: []logicaltest.TestStep{
testNamedKeysWrite(t, testKeyName, testSharedPrivateKey),
@@ -192,6 +196,7 @@ func TestSSHBackend_DynamicRoleCrud(t *testing.T) {
func TestSSHBackend_NamedKeysCrud(t *testing.T) {
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Factory: testingFactory,
Steps: []logicaltest.TestStep{
testNamedKeysWrite(t, testKeyName, testSharedPrivateKey),
@@ -211,6 +216,7 @@ func TestSSHBackend_OTPCreate(t *testing.T) {
"ip": testIP,
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Factory: testingFactory,
Steps: []logicaltest.TestStep{
testRoleWrite(t, testOTPRoleName, testOTPRoleData),
@@ -227,6 +233,7 @@ func TestSSHBackend_VerifyEcho(t *testing.T) {
"message": api.VerifyEchoResponse,
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Factory: testingFactory,
Steps: []logicaltest.TestStep{
testVerifyWrite(t, verifyData, expectedData),
@@ -264,6 +271,7 @@ func TestSSHBackend_ConfigZeroAddressCRUD(t *testing.T) {
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Factory: testingFactory,
Steps: []logicaltest.TestStep{
testRoleWrite(t, testOTPRoleName, testOTPRoleData),
@@ -304,6 +312,7 @@ func TestSSHBackend_CredsForZeroAddressRoles(t *testing.T) {
"roles": fmt.Sprintf("%s,%s", testOTPRoleName, testDynamicRoleName),
}
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Factory: testingFactory,
Steps: []logicaltest.TestStep{
testRoleWrite(t, testOTPRoleName, otpRoleData),

View File

@@ -24,6 +24,7 @@ const (
func TestBackend_basic(t *testing.T) {
decryptData := make(map[string]interface{})
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Factory: Factory,
Steps: []logicaltest.TestStep{
testAccStepWritePolicy(t, "test", false),
@@ -47,6 +48,7 @@ func TestBackend_basic(t *testing.T) {
func TestBackend_upsert(t *testing.T) {
decryptData := make(map[string]interface{})
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Factory: Factory,
Steps: []logicaltest.TestStep{
testAccStepReadPolicy(t, "test", true, false),
@@ -60,6 +62,7 @@ func TestBackend_upsert(t *testing.T) {
func TestBackend_datakey(t *testing.T) {
dataKeyInfo := make(map[string]interface{})
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Factory: Factory,
Steps: []logicaltest.TestStep{
testAccStepWritePolicy(t, "test", false),
@@ -75,6 +78,7 @@ func TestBackend_rotation(t *testing.T) {
decryptData := make(map[string]interface{})
encryptHistory := make(map[int]map[string]interface{})
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Factory: Factory,
Steps: []logicaltest.TestStep{
testAccStepWritePolicy(t, "test", false),
@@ -132,6 +136,7 @@ func TestBackend_rotation(t *testing.T) {
func TestBackend_basic_derived(t *testing.T) {
decryptData := make(map[string]interface{})
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Factory: Factory,
Steps: []logicaltest.TestStep{
testAccStepWritePolicy(t, "test", true),

View File

@@ -4,8 +4,8 @@ import (
"testing"
"github.com/hashicorp/vault/logical"
logicaltest "github.com/hashicorp/vault/logical/testing"
"github.com/hashicorp/vault/logical/framework"
logicaltest "github.com/hashicorp/vault/logical/testing"
)
// MakeTestBackend creates a simple MFA enabled backend.
@@ -70,6 +70,7 @@ func TestMFALogin(t *testing.T) {
b := MakeTestBackend()
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{
testAccStepEnableMFA(t),
@@ -82,6 +83,7 @@ func TestMFALoginDenied(t *testing.T) {
b := MakeTestBackend()
logicaltest.Test(t, logicaltest.TestCase{
AcceptanceTest: true,
Backend: b,
Steps: []logicaltest.TestStep{
testAccStepEnableMFA(t),

View File

@@ -43,6 +43,11 @@ type TestCase struct {
// in the case that the test can't guarantee all resources were
// properly cleaned up.
Teardown TestTeardownFunc
// AcceptanceTest, if set, the test case will be run only if
// the environment variable TF_ACC is set. If not this test case
// will be run as a unit test.
AcceptanceTest bool
}
// TestStep is a single step within a TestCase.