From 3b905745c3fba7c36ff026a57ebfe2f0a96ecec1 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Sun, 20 Oct 2024 00:32:55 -0700 Subject: [PATCH] fix test --- auth/accesstoken.go | 10 +++++----- auth/accesstoken_test.go | 4 ++-- auth/grants.go | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/auth/accesstoken.go b/auth/accesstoken.go index 66be9daf..b5b5a6f9 100644 --- a/auth/accesstoken.go +++ b/auth/accesstoken.go @@ -112,19 +112,19 @@ func (t *AccessToken) SetRoomPreset(preset string) *AccessToken { func (t *AccessToken) SetRoomConfig(config *livekit.RoomConfiguration) *AccessToken { if config == nil { - t.grant.Room = nil + t.grant.RoomConfig = nil } else { - t.grant.Room = (*RoomConfiguration)(config) + t.grant.RoomConfig = (*RoomConfiguration)(config) } return t } // SetAgents is a shortcut for setting agents in room configuration func (t *AccessToken) SetAgents(agents []*livekit.RoomAgentDispatch) *AccessToken { - if t.grant.Room == nil { - t.grant.Room = &RoomConfiguration{} + if t.grant.RoomConfig == nil { + t.grant.RoomConfig = &RoomConfiguration{} } - t.grant.Room.Agents = agents + t.grant.RoomConfig.Agents = agents return t } diff --git a/auth/accesstoken_test.go b/auth/accesstoken_test.go index 8eea1afd..e97cc577 100644 --- a/auth/accesstoken_test.go +++ b/auth/accesstoken_test.go @@ -137,7 +137,7 @@ func TestAccessToken(t *testing.T) { require.NoError(t, err) // Check if the room configuration was correctly serialized and deserialized - roomDecoded := (*livekit.RoomConfiguration)(decodedGrant.Room) + roomDecoded := (*livekit.RoomConfiguration)(decodedGrant.RoomConfig) require.NotNil(t, roomDecoded) agents := roomDecoded.Agents require.NotNil(t, agents) @@ -160,7 +160,7 @@ func TestAccessToken(t *testing.T) { require.NoError(t, err) // Navigate to the agents array - room, ok := jsonPayload["room"].(map[string]interface{}) + room, ok := jsonPayload["roomConfig"].(map[string]interface{}) require.True(t, ok, "room should be a map") agentsJSON, ok := room["agents"].([]interface{}) require.True(t, ok, "agents should be an array") diff --git a/auth/grants.go b/auth/grants.go index 58fb03f5..765b692c 100644 --- a/auth/grants.go +++ b/auth/grants.go @@ -53,7 +53,7 @@ type ClaimGrants struct { Video *VideoGrant `json:"video,omitempty"` SIP *SIPGrant `json:"sip,omitempty"` // Room configuration to use if this participant initiates the room - Room *RoomConfiguration `json:"roomConfig,omitempty"` + RoomConfig *RoomConfiguration `json:"roomConfig,omitempty"` // Cloud-only, config preset to use // when both room and roomPreset are set, parameters in room overrides the preset RoomPreset string `json:"roomPreset,omitempty"` @@ -73,10 +73,10 @@ func (c *ClaimGrants) GetParticipantKind() livekit.ParticipantInfo_Kind { } func (c *ClaimGrants) GetRoomConfiguration() *livekit.RoomConfiguration { - if c.Room == nil { + if c.RoomConfig == nil { return nil } - return (*livekit.RoomConfiguration)(c.Room) + return (*livekit.RoomConfiguration)(c.RoomConfig) } func (c *ClaimGrants) Clone() *ClaimGrants { @@ -88,7 +88,7 @@ func (c *ClaimGrants) Clone() *ClaimGrants { clone.Video = c.Video.Clone() clone.SIP = c.SIP.Clone() clone.Attributes = maps.Clone(c.Attributes) - clone.Room = c.Room.Clone() + clone.RoomConfig = c.RoomConfig.Clone() return &clone }