@@ -64,7 +64,7 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
64
64
// reconnecting-pty proxy server we want to test is mounted.
65
65
client := appDetails .AppClient (t )
66
66
testReconnectingPTY (ctx , t , client , appDetails .Agent .ID , "" )
67
- assertWorkspaceLastUsedAtUpdated (t , client , appDetails )
67
+ assertWorkspaceLastUsedAtUpdated (t , appDetails )
68
68
})
69
69
70
70
t .Run ("SignedTokenQueryParameter" , func (t * testing.T ) {
@@ -93,7 +93,7 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
93
93
// Make an unauthenticated client.
94
94
unauthedAppClient := codersdk .New (appDetails .AppClient (t ).URL )
95
95
testReconnectingPTY (ctx , t , unauthedAppClient , appDetails .Agent .ID , issueRes .SignedToken )
96
- assertWorkspaceLastUsedAtUpdated (t , appDetails . AppClient ( t ), appDetails )
96
+ assertWorkspaceLastUsedAtUpdated (t , appDetails )
97
97
})
98
98
})
99
99
@@ -121,7 +121,7 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
121
121
require .Contains (t , string (body ), "Path-based applications are disabled" )
122
122
// Even though path-based apps are disabled, the request should indicate
123
123
// that the workspace was used.
124
- assertWorkspaceLastUsedAtNotUpdated (t , appDetails . AppClient ( t ), appDetails )
124
+ assertWorkspaceLastUsedAtNotUpdated (t , appDetails )
125
125
})
126
126
127
127
t .Run ("LoginWithoutAuthOnPrimary" , func (t * testing.T ) {
@@ -147,7 +147,7 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
147
147
require .NoError (t , err )
148
148
require .True (t , loc .Query ().Has ("message" ))
149
149
require .True (t , loc .Query ().Has ("redirect" ))
150
- assertWorkspaceLastUsedAtUpdated (t , appDetails . AppClient ( t ), appDetails )
150
+ assertWorkspaceLastUsedAtUpdated (t , appDetails )
151
151
})
152
152
153
153
t .Run ("LoginWithoutAuthOnProxy" , func (t * testing.T ) {
@@ -185,7 +185,7 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
185
185
// request is getting stripped.
186
186
require .Equal (t , u .Path , redirectURI .Path + "/" )
187
187
require .Equal (t , u .RawQuery , redirectURI .RawQuery )
188
- assertWorkspaceLastUsedAtUpdated (t , appDetails . AppClient ( t ), appDetails )
188
+ assertWorkspaceLastUsedAtUpdated (t , appDetails )
189
189
})
190
190
191
191
t .Run ("NoAccessShould404" , func (t * testing.T ) {
@@ -280,7 +280,7 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
280
280
require .NoError (t , err )
281
281
require .Equal (t , proxyTestAppBody , string (body ))
282
282
require .Equal (t , http .StatusOK , resp .StatusCode )
283
- assertWorkspaceLastUsedAtUpdated (t , appDetails . AppClient ( t ), appDetails )
283
+ assertWorkspaceLastUsedAtUpdated (t , appDetails )
284
284
})
285
285
286
286
t .Run ("ProxiesHTTPS" , func (t * testing.T ) {
@@ -326,7 +326,7 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
326
326
require .NoError (t , err )
327
327
require .Equal (t , proxyTestAppBody , string (body ))
328
328
require .Equal (t , http .StatusOK , resp .StatusCode )
329
- assertWorkspaceLastUsedAtUpdated (t , appDetails . AppClient ( t ), appDetails )
329
+ assertWorkspaceLastUsedAtUpdated (t , appDetails )
330
330
})
331
331
332
332
t .Run ("BlocksMe" , func (t * testing.T ) {
@@ -366,7 +366,7 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
366
366
require .Equal (t , proxyTestAppBody , string (body ))
367
367
require .Equal (t , http .StatusOK , resp .StatusCode )
368
368
require .Equal (t , "1.1.1.1,127.0.0.1" , resp .Header .Get ("X-Forwarded-For" ))
369
- assertWorkspaceLastUsedAtUpdated (t , appDetails . AppClient ( t ), appDetails )
369
+ assertWorkspaceLastUsedAtUpdated (t , appDetails )
370
370
})
371
371
372
372
t .Run ("ProxyError" , func (t * testing.T ) {
@@ -381,7 +381,7 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
381
381
require .Equal (t , http .StatusBadGateway , resp .StatusCode )
382
382
// An valid authenticated attempt to access a workspace app
383
383
// should count as usage regardless of success.
384
- assertWorkspaceLastUsedAtUpdated (t , appDetails . AppClient ( t ), appDetails )
384
+ assertWorkspaceLastUsedAtUpdated (t , appDetails )
385
385
})
386
386
387
387
t .Run ("NoProxyPort" , func (t * testing.T ) {
@@ -396,7 +396,7 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
396
396
// TODO(@deansheather): This should be 400. There's a todo in the
397
397
// resolve request code to fix this.
398
398
require .Equal (t , http .StatusInternalServerError , resp .StatusCode )
399
- assertWorkspaceLastUsedAtNotUpdated (t , appDetails . AppClient ( t ), appDetails )
399
+ assertWorkspaceLastUsedAtNotUpdated (t , appDetails )
400
400
})
401
401
})
402
402
@@ -1566,21 +1566,21 @@ func testReconnectingPTY(ctx context.Context, t *testing.T, client *codersdk.Cli
1566
1566
}
1567
1567
1568
1568
// Accessing an app should update the workspace's LastUsedAt.
1569
- func assertWorkspaceLastUsedAtUpdated (t testing.TB , client * codersdk. Client , details * Details ) {
1569
+ func assertWorkspaceLastUsedAtUpdated (t testing.TB , details * Details ) {
1570
1570
t .Helper ()
1571
1571
1572
1572
details .FlushStats ()
1573
- ws , err := client .Workspace (context .Background (), details .Workspace .ID )
1573
+ ws , err := details . SDKClient .Workspace (context .Background (), details .Workspace .ID )
1574
1574
require .NoError (t , err )
1575
1575
require .Greater (t , ws .LastUsedAt , details .Workspace .LastUsedAt , "workspace LastUsedAt not updated when it should have been" )
1576
1576
}
1577
1577
1578
1578
// Except when it sometimes shouldn't (e.g. no access)
1579
- func assertWorkspaceLastUsedAtNotUpdated (t testing.TB , client * codersdk. Client , details * Details ) {
1579
+ func assertWorkspaceLastUsedAtNotUpdated (t testing.TB , details * Details ) {
1580
1580
t .Helper ()
1581
1581
1582
1582
details .FlushStats ()
1583
- ws , err := client .Workspace (context .Background (), details .Workspace .ID )
1583
+ ws , err := details . SDKClient .Workspace (context .Background (), details .Workspace .ID )
1584
1584
require .NoError (t , err )
1585
1585
require .Equal (t , ws .LastUsedAt , details .Workspace .LastUsedAt , "workspace LastUsedAt updated when it should not have been" )
1586
1586
}
0 commit comments