@@ -170,7 +170,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
170
170
require .Equal (t , http .StatusSeeOther , resp .StatusCode )
171
171
loc , err := resp .Location ()
172
172
require .NoError (t , err )
173
- require .Equal (t , appDetails .APIClient .URL .Host , loc .Host )
173
+ require .Equal (t , appDetails .SDKClient .URL .Host , loc .Host )
174
174
require .Equal (t , "/api/v2/applications/auth-redirect" , loc .Path )
175
175
176
176
redirectURIStr := loc .Query ().Get ("redirect_uri" )
@@ -189,7 +189,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
189
189
t .Run ("NoAccessShould404" , func (t * testing.T ) {
190
190
t .Parallel ()
191
191
192
- userClient , _ := coderdtest .CreateAnotherUser (t , appDetails .APIClient , appDetails .FirstUser .OrganizationID , rbac .RoleMember ())
192
+ userClient , _ := coderdtest .CreateAnotherUser (t , appDetails .SDKClient , appDetails .FirstUser .OrganizationID , rbac .RoleMember ())
193
193
userAppClient := appDetails .AppClient (t )
194
194
userAppClient .SetSessionToken (userClient .SessionToken ())
195
195
@@ -393,9 +393,9 @@ func Run(t *testing.T, factory DeploymentFactory) {
393
393
defer cancel ()
394
394
395
395
// Get the current user and API key.
396
- user , err := appDetails .APIClient .User (ctx , codersdk .Me )
396
+ user , err := appDetails .SDKClient .User (ctx , codersdk .Me )
397
397
require .NoError (t , err )
398
- currentAPIKey , err := appDetails .APIClient .APIKeyByID (ctx , appDetails .FirstUser .UserID .String (), strings .Split (appDetails .APIClient .SessionToken (), "-" )[0 ])
398
+ currentAPIKey , err := appDetails .SDKClient .APIKeyByID (ctx , appDetails .FirstUser .UserID .String (), strings .Split (appDetails .SDKClient .SessionToken (), "-" )[0 ])
399
399
require .NoError (t , err )
400
400
401
401
appClient := appDetails .AppClient (t )
@@ -422,12 +422,12 @@ func Run(t *testing.T, factory DeploymentFactory) {
422
422
gotLocation , err := resp .Location ()
423
423
require .NoError (t , err )
424
424
// This should always redirect to the primary access URL.
425
- require .Equal (t , appDetails .APIClient .URL .Host , gotLocation .Host )
425
+ require .Equal (t , appDetails .SDKClient .URL .Host , gotLocation .Host )
426
426
require .Equal (t , "/api/v2/applications/auth-redirect" , gotLocation .Path )
427
427
require .Equal (t , u .String (), gotLocation .Query ().Get ("redirect_uri" ))
428
428
429
429
// Load the application auth-redirect endpoint.
430
- resp , err = requestWithRetries (ctx , t , appDetails .APIClient , http .MethodGet , "/api/v2/applications/auth-redirect" , nil , codersdk .WithQueryParam (
430
+ resp , err = requestWithRetries (ctx , t , appDetails .SDKClient , http .MethodGet , "/api/v2/applications/auth-redirect" , nil , codersdk .WithQueryParam (
431
431
"redirect_uri" , u .String (),
432
432
))
433
433
require .NoError (t , err )
@@ -467,18 +467,18 @@ func Run(t *testing.T, factory DeploymentFactory) {
467
467
apiKey := cookie .Value
468
468
469
469
// Fetch the API key from the API.
470
- apiKeyInfo , err := appDetails .APIClient .APIKeyByID (ctx , appDetails .FirstUser .UserID .String (), strings .Split (apiKey , "-" )[0 ])
470
+ apiKeyInfo , err := appDetails .SDKClient .APIKeyByID (ctx , appDetails .FirstUser .UserID .String (), strings .Split (apiKey , "-" )[0 ])
471
471
require .NoError (t , err )
472
472
require .Equal (t , user .ID , apiKeyInfo .UserID )
473
473
require .Equal (t , codersdk .LoginTypePassword , apiKeyInfo .LoginType )
474
474
require .WithinDuration (t , currentAPIKey .ExpiresAt , apiKeyInfo .ExpiresAt , 5 * time .Second )
475
475
require .EqualValues (t , currentAPIKey .LifetimeSeconds , apiKeyInfo .LifetimeSeconds )
476
476
477
477
// Verify the API key permissions
478
- appTokenAPIClient := codersdk .New (appDetails .APIClient .URL )
478
+ appTokenAPIClient := codersdk .New (appDetails .SDKClient .URL )
479
479
appTokenAPIClient .SetSessionToken (apiKey )
480
- appTokenAPIClient .HTTPClient .CheckRedirect = appDetails .APIClient .HTTPClient .CheckRedirect
481
- appTokenAPIClient .HTTPClient .Transport = appDetails .APIClient .HTTPClient .Transport
480
+ appTokenAPIClient .HTTPClient .CheckRedirect = appDetails .SDKClient .HTTPClient .CheckRedirect
481
+ appTokenAPIClient .HTTPClient .Transport = appDetails .SDKClient .HTTPClient .Transport
482
482
483
483
var (
484
484
canCreateApplicationConnect = "can-create-application_connect"
@@ -543,7 +543,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
543
543
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
544
544
defer cancel ()
545
545
546
- u := * appDetails .APIClient .URL
546
+ u := * appDetails .SDKClient .URL
547
547
u .Host = "app--agent--workspace--username.test.coder.com"
548
548
u .Path = "/api/v2/users/me"
549
549
resp , err := requestWithRetries (ctx , t , appDetails .AppClient (t ), http .MethodGet , u .String (), nil )
@@ -597,7 +597,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
597
597
t .Run ("NoAccessShould401" , func (t * testing.T ) {
598
598
t .Parallel ()
599
599
600
- userClient , _ := coderdtest .CreateAnotherUser (t , appDetails .APIClient , appDetails .FirstUser .OrganizationID , rbac .RoleMember ())
600
+ userClient , _ := coderdtest .CreateAnotherUser (t , appDetails .SDKClient , appDetails .FirstUser .OrganizationID , rbac .RoleMember ())
601
601
userAppClient := appDetails .AppClient (t )
602
602
userAppClient .SetSessionToken (userClient .SessionToken ())
603
603
@@ -827,7 +827,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
827
827
828
828
// Create a template-admin user in the same org. We don't use an owner
829
829
// since they have access to everything.
830
- ownerClient = appDetails .APIClient
830
+ ownerClient = appDetails .SDKClient
831
831
user , err := ownerClient .CreateUser (ctx , codersdk.CreateUserRequest {
832
832
Email : "user@coder.com" ,
833
833
Username : "user" ,
@@ -1170,7 +1170,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
1170
1170
// server.
1171
1171
secWebSocketKey := "test-dean-was-here"
1172
1172
req .Header ["Sec-WebSocket-Key" ] = []string {secWebSocketKey }
1173
- req .Header .Set (codersdk .SessionTokenHeader , appDetails .APIClient .SessionToken ())
1173
+ req .Header .Set (codersdk .SessionTokenHeader , appDetails .SDKClient .SessionToken ())
1174
1174
1175
1175
resp , err := doWithRetries (t , appDetails .AppClient (t ), req )
1176
1176
require .NoError (t , err )
0 commit comments