@@ -60,6 +60,13 @@ func TestGetManifest(t *testing.T) {
60
60
Directory : "/cool/dir" ,
61
61
MOTDFile : "/cool/motd" ,
62
62
}
63
+ childAgent = database.WorkspaceAgent {
64
+ ID : uuid .New (),
65
+ Name : "cool-child-agent" ,
66
+ ParentID : uuid.NullUUID {Valid : true , UUID : agent .ID },
67
+ Directory : "/workspace/dir" ,
68
+ MOTDFile : "/workspace/motd" ,
69
+ }
63
70
apps = []database.WorkspaceApp {
64
71
{
65
72
ID : uuid .New (),
@@ -337,6 +344,7 @@ func TestGetManifest(t *testing.T) {
337
344
expected := & agentproto.Manifest {
338
345
AgentId : agent .ID [:],
339
346
AgentName : agent .Name ,
347
+ ParentId : nil ,
340
348
OwnerUsername : owner .Username ,
341
349
WorkspaceId : workspace .ID [:],
342
350
WorkspaceName : workspace .Name ,
@@ -364,6 +372,70 @@ func TestGetManifest(t *testing.T) {
364
372
require .Equal (t , expected , got )
365
373
})
366
374
375
+ t .Run ("OK/Child" , func (t * testing.T ) {
376
+ t .Parallel ()
377
+
378
+ mDB := dbmock .NewMockStore (gomock .NewController (t ))
379
+
380
+ api := & agentapi.ManifestAPI {
381
+ AccessURL : & url.URL {Scheme : "https" , Host : "example.com" },
382
+ AppHostname : "*--apps.example.com" ,
383
+ ExternalAuthConfigs : []* externalauth.Config {
384
+ {Type : string (codersdk .EnhancedExternalAuthProviderGitHub )},
385
+ {Type : "some-provider" },
386
+ {Type : string (codersdk .EnhancedExternalAuthProviderGitLab )},
387
+ },
388
+ DisableDirectConnections : true ,
389
+ DerpForceWebSockets : true ,
390
+
391
+ AgentFn : func (ctx context.Context ) (database.WorkspaceAgent , error ) {
392
+ return childAgent , nil
393
+ },
394
+ WorkspaceID : workspace .ID ,
395
+ Database : mDB ,
396
+ DerpMapFn : derpMapFn ,
397
+ }
398
+
399
+ mDB .EXPECT ().GetWorkspaceAppsByAgentID (gomock .Any (), childAgent .ID ).Return ([]database.WorkspaceApp {}, nil )
400
+ mDB .EXPECT ().GetWorkspaceAgentScriptsByAgentIDs (gomock .Any (), []uuid.UUID {childAgent .ID }).Return ([]database.WorkspaceAgentScript {}, nil )
401
+ mDB .EXPECT ().GetWorkspaceAgentMetadata (gomock .Any (), database.GetWorkspaceAgentMetadataParams {
402
+ WorkspaceAgentID : childAgent .ID ,
403
+ Keys : nil , // all
404
+ }).Return ([]database.WorkspaceAgentMetadatum {}, nil )
405
+ mDB .EXPECT ().GetWorkspaceAgentDevcontainersByAgentID (gomock .Any (), childAgent .ID ).Return ([]database.WorkspaceAgentDevcontainer {}, nil )
406
+ mDB .EXPECT ().GetWorkspaceByID (gomock .Any (), workspace .ID ).Return (workspace , nil )
407
+ mDB .EXPECT ().GetUserByID (gomock .Any (), workspace .OwnerID ).Return (owner , nil )
408
+
409
+ got , err := api .GetManifest (context .Background (), & agentproto.GetManifestRequest {})
410
+ require .NoError (t , err )
411
+
412
+ expected := & agentproto.Manifest {
413
+ AgentId : childAgent .ID [:],
414
+ AgentName : childAgent .Name ,
415
+ ParentId : agent .ID [:],
416
+ OwnerUsername : owner .Username ,
417
+ WorkspaceId : workspace .ID [:],
418
+ WorkspaceName : workspace .Name ,
419
+ GitAuthConfigs : 2 , // two "enhanced" external auth configs
420
+ EnvironmentVariables : nil ,
421
+ Directory : childAgent .Directory ,
422
+ VsCodePortProxyUri : fmt .Sprintf ("https://{{port}}--%s--%s--%s--apps.example.com" , childAgent .Name , workspace .Name , owner .Username ),
423
+ MotdPath : childAgent .MOTDFile ,
424
+ DisableDirectConnections : true ,
425
+ DerpForceWebsockets : true ,
426
+ // tailnet.DERPMapToProto() is extensively tested elsewhere, so it's
427
+ // not necessary to manually recreate a big DERP map here like we
428
+ // did for apps and metadata.
429
+ DerpMap : tailnet .DERPMapToProto (derpMapFn ()),
430
+ Scripts : []* agentproto.WorkspaceAgentScript {},
431
+ Apps : []* agentproto.WorkspaceApp {},
432
+ Metadata : []* agentproto.WorkspaceAgentMetadata_Description {},
433
+ Devcontainers : []* agentproto.WorkspaceAgentDevcontainer {},
434
+ }
435
+
436
+ require .Equal (t , expected , got )
437
+ })
438
+
367
439
t .Run ("NoAppHostname" , func (t * testing.T ) {
368
440
t .Parallel ()
369
441
0 commit comments