generated from broadinstitute/golang-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
11bc7d2
commit 1ed3827
Showing
57 changed files
with
3,194 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package utils | ||
|
||
import "strings" | ||
|
||
func SubstituteSuffix(s string, suffixesToReplace []string, replacement string) string { | ||
for _, suffix := range suffixesToReplace { | ||
if strings.HasSuffix(s, suffix) { | ||
s = strings.TrimSuffix(s, suffix) + replacement | ||
break | ||
} | ||
} | ||
return s | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package utils | ||
|
||
import "testing" | ||
|
||
func TestSubstituteSuffix(t *testing.T) { | ||
type args struct { | ||
s string | ||
replacement string | ||
suffixesToReplace []string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want string | ||
}{ | ||
{ | ||
name: "no old domains", | ||
args: args{ | ||
s: "[email protected]", | ||
replacement: "example.org", | ||
}, | ||
want: "[email protected]", | ||
}, | ||
{ | ||
name: "single old domain", | ||
args: args{ | ||
s: "[email protected]", | ||
suffixesToReplace: []string{"example.com"}, | ||
replacement: "example.org", | ||
}, | ||
want: "[email protected]", | ||
}, | ||
{ | ||
name: "multiple old domains", | ||
args: args{ | ||
s: "[email protected]", | ||
suffixesToReplace: []string{"example.com", "example.net"}, | ||
replacement: "example.org", | ||
}, | ||
want: "[email protected]", | ||
}, | ||
{ | ||
name: "no match", | ||
args: args{ | ||
s: "[email protected]", | ||
suffixesToReplace: []string{"example.net"}, | ||
replacement: "example.org", | ||
}, | ||
want: "[email protected]", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := SubstituteSuffix(tt.args.s, tt.args.suffixesToReplace, tt.args.replacement); got != tt.want { | ||
t.Errorf("SubstituteSuffix() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,3 +53,23 @@ model: | |
self: | ||
overrideEmail: [email protected] | ||
overrideSubjectID: sherlock-test | ||
|
||
rolePropagation: | ||
asynchronous: false | ||
propagators: | ||
devFirecloudGroupTestDisabled: | ||
enable: false | ||
workspaceDomain: test.firecloud.org | ||
|
||
devFirecloudGroupTestDefault: | ||
enable: true | ||
workspaceDomain: test.firecloud.org | ||
|
||
devFirecloudGroupTestConfig: | ||
enable: true | ||
workspaceDomain: test.firecloud.org | ||
timeout: 10s | ||
userEmailDomainsToReplace: | ||
- broadinstitute.org | ||
toleratedUsers: | ||
- email: [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
alter table roles | ||
drop column if exists propagated_at; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
alter table roles | ||
add column if not exists propagated_at timestamp with time zone; |
32 changes: 32 additions & 0 deletions
32
sherlock/db/migrations/000090_role_qa_prod_group_fields.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
drop index if exists roles_grants_qa_firecloud_group_unique; | ||
|
||
alter table roles | ||
drop column if exists grants_qa_firecloud_group; | ||
|
||
alter table role_operations | ||
drop column if exists from_grants_qa_firecloud_group; | ||
|
||
alter table role_operations | ||
drop column if exists to_grants_qa_firecloud_group; | ||
|
||
drop index if exists roles_grants_prod_firecloud_group_unique; | ||
|
||
alter table roles | ||
drop column if exists grants_prod_firecloud_group; | ||
|
||
alter table role_operations | ||
drop column if exists from_grants_prod_firecloud_group; | ||
|
||
alter table role_operations | ||
drop column if exists to_grants_prod_firecloud_group; | ||
|
||
drop index if exists roles_grants_prod_azure_group_unique; | ||
|
||
alter table roles | ||
drop column if exists grants_prod_azure_group; | ||
|
||
alter table role_operations | ||
drop column if exists from_grants_prod_azure_group; | ||
|
||
alter table role_operations | ||
drop column if exists to_grants_prod_azure_group; |
38 changes: 38 additions & 0 deletions
38
sherlock/db/migrations/000090_role_qa_prod_group_fields.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
alter table roles | ||
add column if not exists grants_qa_firecloud_group text; | ||
|
||
create unique index if not exists roles_grants_qa_firecloud_group_unique | ||
on roles (grants_qa_firecloud_group) | ||
where deleted_at is null and grants_qa_firecloud_group is not null and grants_qa_firecloud_group != ''; | ||
|
||
alter table role_operations | ||
add column if not exists from_grants_qa_firecloud_group text; | ||
|
||
alter table role_operations | ||
add column if not exists to_grants_qa_firecloud_group text; | ||
|
||
alter table roles | ||
add column if not exists grants_prod_firecloud_group text; | ||
|
||
create unique index if not exists roles_grants_prod_firecloud_group_unique | ||
on roles (grants_prod_firecloud_group) | ||
where deleted_at is null and grants_prod_firecloud_group is not null and grants_prod_firecloud_group != ''; | ||
|
||
alter table role_operations | ||
add column if not exists from_grants_prod_firecloud_group text; | ||
|
||
alter table role_operations | ||
add column if not exists to_grants_prod_firecloud_group text; | ||
|
||
alter table roles | ||
add column if not exists grants_prod_azure_group text; | ||
|
||
create unique index if not exists roles_grants_prod_azure_group_unique | ||
on roles (grants_prod_azure_group) | ||
where deleted_at is null and grants_prod_azure_group is not null and grants_prod_azure_group != ''; | ||
|
||
alter table role_operations | ||
add column if not exists from_grants_prod_azure_group text; | ||
|
||
alter table role_operations | ||
add column if not exists to_grants_prod_azure_group text; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.