From 96e4b1cdba346de9458bbd5fc38311376353b6e3 Mon Sep 17 00:00:00 2001 From: Jim Date: Mon, 7 Sep 2020 13:20:49 -0400 Subject: [PATCH] add option db.WithSkipVetForWrite(true) so the db tests don't get intercepted by app validation (#332) --- internal/host/static/immutable_fields_test.go | 8 ++++---- internal/iam/immutable_fields_test.go | 8 ++++---- internal/kms/immutable_fields_test.go | 8 ++++---- internal/target/immutable_fields_test.go | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/internal/host/static/immutable_fields_test.go b/internal/host/static/immutable_fields_test.go index d91d261c2..ddbe2cc89 100644 --- a/internal/host/static/immutable_fields_test.go +++ b/internal/host/static/immutable_fields_test.go @@ -64,7 +64,7 @@ func TestHostCatalog_ImmutableFields(t *testing.T) { err := w.LookupById(context.Background(), orig) require.NoError(err) - rowsUpdated, err := w.Update(context.Background(), tt.update, tt.fieldMask, nil) + rowsUpdated, err := w.Update(context.Background(), tt.update, tt.fieldMask, nil, db.WithSkipVetForWrite(true)) require.Error(err) assert.Equal(0, rowsUpdated) @@ -132,7 +132,7 @@ func TestStaticHost_ImmutableFields(t *testing.T) { err := w.LookupById(context.Background(), orig) require.NoError(err) - rowsUpdated, err := w.Update(context.Background(), tt.update, tt.fieldMask, nil) + rowsUpdated, err := w.Update(context.Background(), tt.update, tt.fieldMask, nil, db.WithSkipVetForWrite(true)) require.Error(err) assert.Equal(0, rowsUpdated) @@ -207,7 +207,7 @@ func TestStaticHostSet_ImmutableFields(t *testing.T) { err := w.LookupById(context.Background(), orig) require.NoError(err) - rowsUpdated, err := w.Update(context.Background(), tt.update, tt.fieldMask, nil) + rowsUpdated, err := w.Update(context.Background(), tt.update, tt.fieldMask, nil, db.WithSkipVetForWrite(true)) require.Error(err) assert.Equal(0, rowsUpdated) @@ -276,7 +276,7 @@ func TestStaticHostSetMember_ImmutableFields(t *testing.T) { err = w.LookupWhere(context.Background(), orig, "host_id = ? and set_id = ?", orig.HostId, orig.SetId) require.NoError(err) - rowsUpdated, err := w.Update(context.Background(), tt.update, tt.fieldMask, nil) + rowsUpdated, err := w.Update(context.Background(), tt.update, tt.fieldMask, nil, db.WithSkipVetForWrite(true)) require.Error(err) assert.Equal(0, rowsUpdated) diff --git a/internal/iam/immutable_fields_test.go b/internal/iam/immutable_fields_test.go index ee1e41a4e..12b93ef9c 100644 --- a/internal/iam/immutable_fields_test.go +++ b/internal/iam/immutable_fields_test.go @@ -73,7 +73,7 @@ func TestScope_ImmutableFields(t *testing.T) { err := w.LookupById(context.Background(), orig) require.NoError(err) - rowsUpdated, err := w.Update(context.Background(), tt.update, tt.fieldMask, nil) + rowsUpdated, err := w.Update(context.Background(), tt.update, tt.fieldMask, nil, db.WithSkipVetForWrite(true)) require.Error(err) assert.Equal(0, rowsUpdated) @@ -196,7 +196,7 @@ func TestUser_ImmutableFields(t *testing.T) { err := w.LookupById(context.Background(), orig) require.NoError(err) - rowsUpdated, err := w.Update(context.Background(), tt.update, tt.fieldMask, nil) + rowsUpdated, err := w.Update(context.Background(), tt.update, tt.fieldMask, nil, db.WithSkipVetForWrite(true)) require.Error(err) assert.Equal(0, rowsUpdated) @@ -263,7 +263,7 @@ func TestRole_ImmutableFields(t *testing.T) { err := w.LookupById(context.Background(), orig) require.NoError(err) - rowsUpdated, err := w.Update(context.Background(), tt.update, tt.fieldMask, nil) + rowsUpdated, err := w.Update(context.Background(), tt.update, tt.fieldMask, nil, db.WithSkipVetForWrite(true)) require.Error(err) assert.Equal(0, rowsUpdated) @@ -330,7 +330,7 @@ func TestGroup_ImmutableFields(t *testing.T) { err := w.LookupById(context.Background(), orig) require.NoError(err) - rowsUpdated, err := w.Update(context.Background(), tt.update, tt.fieldMask, nil) + rowsUpdated, err := w.Update(context.Background(), tt.update, tt.fieldMask, nil, db.WithSkipVetForWrite(true)) require.Error(err) assert.Equal(0, rowsUpdated) diff --git a/internal/kms/immutable_fields_test.go b/internal/kms/immutable_fields_test.go index 1d965e3d6..a0dedeaec 100644 --- a/internal/kms/immutable_fields_test.go +++ b/internal/kms/immutable_fields_test.go @@ -96,7 +96,7 @@ func TestRootKeyVersion_ImmutableFields(t *testing.T) { err = tt.update.Encrypt(context.Background(), wrapper) require.NoError(err) - rowsUpdated, err := rw.Update(context.Background(), tt.update, tt.fieldMask, nil) + rowsUpdated, err := rw.Update(context.Background(), tt.update, tt.fieldMask, nil, db.WithSkipVetForWrite(true)) require.Error(err) assert.Equal(0, rowsUpdated) @@ -163,7 +163,7 @@ func TestRootKey_ImmutableFields(t *testing.T) { err := rw.LookupById(context.Background(), orig) require.NoError(err) - rowsUpdated, err := rw.Update(context.Background(), tt.update, tt.fieldMask, nil) + rowsUpdated, err := rw.Update(context.Background(), tt.update, tt.fieldMask, nil, db.WithSkipVetForWrite(true)) require.Error(err) assert.Equal(0, rowsUpdated) @@ -232,7 +232,7 @@ func TestDatabaseKey_ImmutableFields(t *testing.T) { err := rw.LookupById(context.Background(), orig) require.NoError(err) - rowsUpdated, err := rw.Update(context.Background(), tt.update, tt.fieldMask, nil) + rowsUpdated, err := rw.Update(context.Background(), tt.update, tt.fieldMask, nil, db.WithSkipVetForWrite(true)) require.Error(err) assert.Equal(0, rowsUpdated) @@ -331,7 +331,7 @@ func TestDatabaseKeyVersion_ImmutableFields(t *testing.T) { err = tt.update.Encrypt(context.Background(), wrapper) require.NoError(err) - rowsUpdated, err := rw.Update(context.Background(), tt.update, tt.fieldMask, nil) + rowsUpdated, err := rw.Update(context.Background(), tt.update, tt.fieldMask, nil, db.WithSkipVetForWrite(true)) require.Error(err) assert.Equal(0, rowsUpdated) diff --git a/internal/target/immutable_fields_test.go b/internal/target/immutable_fields_test.go index 1a9eeff12..6f0befc3e 100644 --- a/internal/target/immutable_fields_test.go +++ b/internal/target/immutable_fields_test.go @@ -70,7 +70,7 @@ func TestTarget_ImmutableFields(t *testing.T) { require.NoError(err) tt.update.SetTableName("target") - rowsUpdated, err := rw.Update(context.Background(), tt.update, tt.fieldMask, nil) + rowsUpdated, err := rw.Update(context.Background(), tt.update, tt.fieldMask, nil, db.WithSkipVetForWrite(true)) require.Error(err) assert.Equal(0, rowsUpdated) @@ -137,7 +137,7 @@ func TestTcpTarget_ImmutableFields(t *testing.T) { err := rw.LookupById(context.Background(), orig) require.NoError(err) - rowsUpdated, err := rw.Update(context.Background(), tt.update, tt.fieldMask, nil) + rowsUpdated, err := rw.Update(context.Background(), tt.update, tt.fieldMask, nil, db.WithSkipVetForWrite(true)) require.Error(err) assert.Equal(0, rowsUpdated) @@ -218,7 +218,7 @@ func TestTargetHostSet_ImmutableFields(t *testing.T) { err := rw.LookupWhere(context.Background(), orig, "target_id = ? and host_set_id = ?", new.TargetId, new.HostSetId) require.NoError(err) - rowsUpdated, err := rw.Update(context.Background(), tt.update, tt.fieldMask, nil) + rowsUpdated, err := rw.Update(context.Background(), tt.update, tt.fieldMask, nil, db.WithSkipVetForWrite(true)) require.Error(err) assert.Equal(0, rowsUpdated)