Skip to content

Commit

Permalink
feat(secret): add logic for handling allow command
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockopp committed Nov 13, 2019
1 parent f3593a5 commit a350a15
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 80 deletions.
1 change: 1 addition & 0 deletions database/ddl/postgres/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ secrets (
value BYTEA,
images VARCHAR(1000),
events VARCHAR(1000),
allow_command BOOLEAN,
UNIQUE(type, org, repo, name),
UNIQUE(type, org, team, name)
);
Expand Down
1 change: 1 addition & 0 deletions database/ddl/sqlite/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ secrets (
value TEXT,
images TEXT,
events TEXT,
allow_command BOOLEAN,
UNIQUE(type, org, repo, name),
UNIQUE(type, org, team, name)
);
Expand Down
20 changes: 11 additions & 9 deletions database/secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,15 +628,17 @@ func testSecret() *library.Secret {
i64 := int64(0)
str := ""
arr := []string{}
booL := false
return &library.Secret{
ID: &i64,
Org: &str,
Repo: &str,
Team: &str,
Name: &str,
Value: &str,
Type: &str,
Images: &arr,
Events: &arr,
ID: &i64,
Org: &str,
Repo: &str,
Team: &str,
Name: &str,
Value: &str,
Type: &str,
Images: &arr,
Events: &arr,
AllowCommand: &booL,
}
}
78 changes: 43 additions & 35 deletions secret/native/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@ func TestNative_Create_Org(t *testing.T) {
value := "baz"
typee := "org"
arr := []string{"foo", "bar"}
booL := false
want := &library.Secret{
ID: &one,
Org: &org,
Repo: &repo,
Team: &team,
Name: &name,
Value: &value,
Type: &typee,
Images: &arr,
Events: &arr,
ID: &one,
Org: &org,
Repo: &repo,
Team: &team,
Name: &name,
Value: &value,
Type: &typee,
Images: &arr,
Events: &arr,
AllowCommand: &booL,
}

// setup database
Expand Down Expand Up @@ -70,16 +72,18 @@ func TestNative_Create_Repo(t *testing.T) {
value := "foob"
typee := "repo"
arr := []string{"foo", "bar"}
booL := false
want := &library.Secret{
ID: &one,
Org: &org,
Repo: &repo,
Team: &team,
Name: &name,
Value: &value,
Type: &typee,
Images: &arr,
Events: &arr,
ID: &one,
Org: &org,
Repo: &repo,
Team: &team,
Name: &name,
Value: &value,
Type: &typee,
Images: &arr,
Events: &arr,
AllowCommand: &booL,
}

// setup database
Expand Down Expand Up @@ -117,16 +121,18 @@ func TestNative_Create_Shared(t *testing.T) {
value := "foob"
typee := "shared"
arr := []string{"foo", "bar"}
booL := false
want := &library.Secret{
ID: &one,
Org: &org,
Repo: &repo,
Team: &team,
Name: &name,
Value: &value,
Type: &typee,
Images: &arr,
Events: &arr,
ID: &one,
Org: &org,
Repo: &repo,
Team: &team,
Name: &name,
Value: &value,
Type: &typee,
Images: &arr,
Events: &arr,
AllowCommand: &booL,
}

// setup database
Expand Down Expand Up @@ -163,15 +169,17 @@ func TestNative_Create_Invalid(t *testing.T) {
value := "foob"
typee := "invalid"
arr := []string{"foo", "bar"}
booL := false
sec := &library.Secret{
ID: &one,
Org: &org,
Repo: &repo,
Name: &name,
Value: &value,
Type: &typee,
Images: &arr,
Events: &arr,
ID: &one,
Org: &org,
Repo: &repo,
Name: &name,
Value: &value,
Type: &typee,
Images: &arr,
Events: &arr,
AllowCommand: &booL,
}

// setup database
Expand Down
20 changes: 11 additions & 9 deletions secret/native/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@ func TestNative_Get(t *testing.T) {
value := "foob"
typee := "repo"
arr := []string{"foo", "bar"}
booL := false
want := &library.Secret{
ID: &one,
Org: &org,
Repo: &repo,
Team: &team,
Name: &name,
Value: &value,
Type: &typee,
Images: &arr,
Events: &arr,
ID: &one,
Org: &org,
Repo: &repo,
Team: &team,
Name: &name,
Value: &value,
Type: &typee,
Images: &arr,
Events: &arr,
AllowCommand: &booL,
}

// setup database
Expand Down
39 changes: 21 additions & 18 deletions secret/native/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,31 @@ func TestNative_List(t *testing.T) {
value := "foob"
typee := "repo"
arr := []string{"foo", "bar"}
booL := false
sOne := &library.Secret{
ID: &one,
Org: &org,
Repo: &repo,
Team: &team,
Name: &name,
Value: &value,
Type: &typee,
Images: &arr,
Events: &arr,
ID: &one,
Org: &org,
Repo: &repo,
Team: &team,
Name: &name,
Value: &value,
Type: &typee,
Images: &arr,
Events: &arr,
AllowCommand: &booL,
}
two := int64(2)
sTwo := &library.Secret{
ID: &two,
Org: &org,
Repo: &repo,
Team: &team,
Name: &value,
Value: &name,
Type: &typee,
Images: &arr,
Events: &arr,
ID: &two,
Org: &org,
Repo: &repo,
Team: &team,
Name: &value,
Value: &name,
Type: &typee,
Images: &arr,
Events: &arr,
AllowCommand: &booL,
}
want := []*library.Secret{sTwo, sOne}

Expand Down
20 changes: 11 additions & 9 deletions secret/native/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@ func TestNative_Update(t *testing.T) {
value := "foob"
typee := "repo"
arr := []string{"foo", "bar"}
booL := false
want := &library.Secret{
ID: &one,
Org: &org,
Repo: &repo,
Team: &team,
Name: &name,
Value: &value,
Type: &typee,
Images: &arr,
Events: &arr,
ID: &one,
Org: &org,
Repo: &repo,
Team: &team,
Name: &name,
Value: &value,
Type: &typee,
Images: &arr,
Events: &arr,
AllowCommand: &booL,
}

// setup database
Expand Down

0 comments on commit a350a15

Please sign in to comment.