Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
davidzhao committed Oct 20, 2024
1 parent edcceab commit 3b90574
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions auth/accesstoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions auth/accesstoken_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
Expand Down
8 changes: 4 additions & 4 deletions auth/grants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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 {
Expand All @@ -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
}
Expand Down

0 comments on commit 3b90574

Please sign in to comment.