@@ -54,7 +54,7 @@ func testingWithOwnerUser(m dsl.Matcher) {
54
54
m .Import ("github.com/coder/coder/v2/cli/clitest" )
55
55
m .Import ("github.com/coder/coder/v2/enterprise/coderd/coderenttest" )
56
56
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
58
58
// client authenticated as the Owner user.
59
59
m .Match (`
60
60
$_ := coderdtest.CreateFirstUser($t, $client)
@@ -67,6 +67,16 @@ func testingWithOwnerUser(m dsl.Matcher) {
67
67
At (m ["SetupConfig" ]).
68
68
Report (`The CLI will be operating as the owner user, which has unrestricted permissions. Consider creating a different user.` )
69
69
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
+
70
80
// For the enterprise code, we check for any method called on the client.
71
81
// While we want to be a bit stricter here, some methods are known to require
72
82
// the owner user, so we exclude them.
@@ -78,7 +88,7 @@ func testingWithOwnerUser(m dsl.Matcher) {
78
88
m .File ().Name .Matches (`_test\.go$` ) &&
79
89
! m ["Method" ].Text .Matches (`^(UpdateAppearance|Licenses|AddLicense|InsertLicense|DeleteLicense|CreateWorkspaceProxy|Replicas|Regions)$` )).
80
90
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.` )
82
92
83
93
// Sadly, we need to match both one- and two-valued assignments separately.
84
94
m .Match (`
@@ -89,7 +99,7 @@ func testingWithOwnerUser(m dsl.Matcher) {
89
99
m .File ().Name .Matches (`_test\.go$` ) &&
90
100
! m ["Method" ].Text .Matches (`^(UpdateAppearance|Licenses|AddLicense|InsertLicense|DeleteLicense|CreateWorkspaceProxy|Replicas|Regions)$` )).
91
101
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.` )
93
103
}
94
104
95
105
// Use xerrors everywhere! It provides additional stacktrace info!
0 commit comments