Enable Room.List to filter by specific names (#290)

This commit is contained in:
David Zhao
2021-12-27 23:32:29 -08:00
committed by GitHub
parent 472f51cdba
commit 15cd98be22
13 changed files with 133 additions and 36 deletions
+13 -3
View File
@@ -58,7 +58,7 @@ func setupSingleNodeTest(name string, roomName string) (*service.LivekitServer,
waitForServerToStart(s)
// create test room
_, err := roomClient.CreateRoom(contextWithCreateRoomToken(), &livekit.CreateRoomRequest{Name: roomName})
_, err := roomClient.CreateRoom(contextWithToken(createRoomToken()), &livekit.CreateRoomRequest{Name: roomName})
if err != nil {
panic(err)
}
@@ -86,9 +86,9 @@ func setupMultiNodeTest(name string) (*service.LivekitServer, *service.LivekitSe
}
}
func contextWithCreateRoomToken() context.Context {
func contextWithToken(token string) context.Context {
header := make(http.Header)
testclient.SetAuthorizationToken(header, createRoomToken())
testclient.SetAuthorizationToken(header, token)
tctx, err := twirp.WithHTTPRequestHeaders(context.Background(), header)
if err != nil {
panic(err)
@@ -258,6 +258,16 @@ func createRoomToken() string {
return t
}
func listRoomToken() string {
at := auth.NewAccessToken(testApiKey, testApiSecret).
AddGrant(&auth.VideoGrant{RoomList: true})
t, err := at.ToJWT()
if err != nil {
panic(err)
}
return t
}
func stopWriters(writers ...*testclient.TrackWriter) {
for _, w := range writers {
w.Stop()