Skip to content

Commit 80db007

Browse files
committed
make linter complain more
1 parent c5bf25f commit 80db007

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

scripts/rules.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func testingWithOwnerUser(m dsl.Matcher) {
5454
m.Import("github.com/coder/coder/v2/cli/clitest")
5555
m.Import("github.com/coder/coder/v2/enterprise/coderd/coderenttest")
5656

57-
// For the AGPL code, we just check for SetupConfig being called with a
57+
// For both AGPL and enterprise code, we check for SetupConfig being called with a
5858
// client authenticated as the Owner user.
5959
m.Match(`
6060
$_ := coderdtest.CreateFirstUser($t, $client)
@@ -67,6 +67,16 @@ func testingWithOwnerUser(m dsl.Matcher) {
6767
At(m["SetupConfig"]).
6868
Report(`The CLI will be operating as the owner user, which has unrestricted permissions. Consider creating a different user.`)
6969

70+
m.Match(`
71+
$client, $_ := coderdenttest.New($t, $*_)
72+
$*_
73+
clitest.$SetupConfig($t, $client, $_)
74+
`).Where(m["t"].Type.Implements("testing.TB") &&
75+
m["SetupConfig"].Text.Matches("^SetupConfig$") &&
76+
m.File().Name.Matches(`_test\.go$`)).
77+
At(m["SetupConfig"]).
78+
Report(`The CLI will be operating as the owner user, which has unrestricted permissions. Consider creating a different user.`)
79+
7080
// For the enterprise code, we check for any method called on the client.
7181
// While we want to be a bit stricter here, some methods are known to require
7282
// the owner user, so we exclude them.
@@ -78,7 +88,7 @@ func testingWithOwnerUser(m dsl.Matcher) {
7888
m.File().Name.Matches(`_test\.go$`) &&
7989
!m["Method"].Text.Matches(`^(UpdateAppearance|Licenses|AddLicense|InsertLicense|DeleteLicense|CreateWorkspaceProxy|Replicas|Regions)$`)).
8090
At(m["Method"]).
81-
Report(`The CLI will be operating as the owner user, which has unrestricted permissions. Consider creating a different user.`)
91+
Report(`This client is operating as the owner user, which has unrestricted permissions. Consider creating a different user.`)
8292

8393
// Sadly, we need to match both one- and two-valued assignments separately.
8494
m.Match(`
@@ -89,7 +99,7 @@ func testingWithOwnerUser(m dsl.Matcher) {
8999
m.File().Name.Matches(`_test\.go$`) &&
90100
!m["Method"].Text.Matches(`^(UpdateAppearance|Licenses|AddLicense|InsertLicense|DeleteLicense|CreateWorkspaceProxy|Replicas|Regions)$`)).
91101
At(m["Method"]).
92-
Report(`The CLI will be operating as the owner user, which has unrestricted permissions. Consider creating a different user.`)
102+
Report(`This client is operating as the owner user, which has unrestricted permissions. Consider creating a different user.`)
93103
}
94104

95105
// Use xerrors everywhere! It provides additional stacktrace info!

0 commit comments

Comments
 (0)