MCPcopy Index your code
hub / github.com/coder/coder / TestClientUserCoordinateeAuth

Function TestClientUserCoordinateeAuth

tailnet/service_test.go:229–267  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

227}
228
229func TestClientUserCoordinateeAuth(t *testing.T) {
230 t.Parallel()
231
232 ctx := testutil.Context(t, testutil.WaitShort)
233
234 agentID := uuid.UUID{0x01}
235 agentID2 := uuid.UUID{0x02}
236 clientID := uuid.UUID{0x03}
237
238 ctrl := gomock.NewController(t)
239 updatesProvider := tailnettest.NewMockWorkspaceUpdatesProvider(ctrl)
240
241 fCoord, client := createUpdateService(t, ctx, clientID, updatesProvider)
242
243 // Coordinate
244 stream, err := client.Coordinate(ctx)
245 require.NoError(t, err)
246 defer stream.Close()
247
248 err = stream.Send(&proto.CoordinateRequest{
249 UpdateSelf: &proto.CoordinateRequest_UpdateSelf{Node: &proto.Node{PreferredDerp: 11}},
250 })
251 require.NoError(t, err)
252
253 call := testutil.TryReceive(ctx, t, fCoord.CoordinateCalls)
254 require.NotNil(t, call)
255 require.Equal(t, call.ID, clientID)
256 require.Equal(t, call.Name, "client")
257 req := testutil.TryReceive(ctx, t, call.Reqs)
258 require.Equal(t, int32(11), req.GetUpdateSelf().GetNode().GetPreferredDerp())
259
260 // Authorize uses `ClientUserCoordinateeAuth`
261 require.NoError(t, call.Auth.Authorize(ctx, &proto.CoordinateRequest{
262 AddTunnel: &proto.CoordinateRequest_Tunnel{Id: tailnet.UUIDToByteSlice(agentID)},
263 }))
264 require.Error(t, call.Auth.Authorize(ctx, &proto.CoordinateRequest{
265 AddTunnel: &proto.CoordinateRequest_Tunnel{Id: tailnet.UUIDToByteSlice(agentID2)},
266 }))
267}
268
269func TestWorkspaceUpdates(t *testing.T) {
270 t.Parallel()

Callers

nothing calls this directly

Calls 14

ContextFunction · 0.92
TryReceiveFunction · 0.92
UUIDToByteSliceFunction · 0.92
createUpdateServiceFunction · 0.85
GetUpdateSelfMethod · 0.80
CoordinateMethod · 0.65
CloseMethod · 0.65
SendMethod · 0.65
AuthorizeMethod · 0.65
EqualMethod · 0.45
GetPreferredDerpMethod · 0.45

Tested by

no test coverage detected