Skip to content

Commit

Permalink
add attribute test
Browse files Browse the repository at this point in the history
  • Loading branch information
davidzhao committed Oct 29, 2024
1 parent 4080370 commit d6846e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
# LiveKit Server API for Ruby

<!--BEGIN_DESCRIPTION-->

Use this SDK to interact with <a href="https://livekit.io/">LiveKit</a> server APIs and create access tokens from your Ruby backend.

<!--END_DESCRIPTION-->

This library is designed to work with Ruby 2.6.0 and above.
Expand Down Expand Up @@ -46,8 +48,8 @@ require 'livekit'
token = LiveKit::AccessToken.new(api_key: 'yourkey', api_secret: 'yoursecret')
token.identity = 'participant-identity'
token.name = 'participant-name'
token.add_grant(roomJoin: true, room: 'room-name')

token.set_video_grant(LiveKit::VideoGrant.new(roomJoin: true, room: 'room-name'))
token.attributes = { "mykey" => "myvalue" }
puts token.to_jwt
```

Expand Down Expand Up @@ -136,7 +138,9 @@ You may store credentials in environment variables. If api-key or api-secret is
The gem is available as open source under the terms of Apache 2.0 License.

<!--BEGIN_REPO_NAV-->

<br/><table>

<thead><tr><th colspan="2">LiveKit Ecosystem</th></tr></thead>
<tbody>
<tr><td>Realtime SDKs</td><td><a href="https://github.com/livekit/components-js">React Components</a> · <a href="https://github.com/livekit/client-sdk-js">Browser</a> · <a href="https://github.com/livekit/components-swift">Swift Components</a> · <a href="https://github.com/livekit/client-sdk-swift">iOS/macOS/visionOS</a> · <a href="https://github.com/livekit/client-sdk-android">Android</a> · <a href="https://github.com/livekit/client-sdk-flutter">Flutter</a> · <a href="https://github.com/livekit/client-sdk-react-native">React Native</a> · <a href="https://github.com/livekit/rust-sdks">Rust</a> · <a href="https://github.com/livekit/node-sdks">Node.js</a> · <a href="https://github.com/livekit/python-sdks">Python</a> · <a href="https://github.com/livekit/client-sdk-unity-web">Unity (web)</a> · <a href="https://github.com/livekit/client-sdk-unity">Unity (beta)</a></td></tr><tr></tr>
Expand All @@ -147,4 +151,3 @@ The gem is available as open source under the terms of Apache 2.0 License.
</tbody>
</table>
<!--END_REPO_NAV-->

2 changes: 2 additions & 0 deletions spec/livekit/token_verifier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
identity: "user")
token.name = "name"
token.set_video_grant LiveKit::VideoGrant.new(roomJoin: true, room: "testroom")
token.attributes = { "mykey" => "myvalue" }
jwt = token.to_jwt
v = described_class.new(api_key: TEST_KEY, api_secret: TEST_SECRET)
grant = v.verify(jwt)
expect(grant.video.roomJoin).to eq(true)
expect(grant.video.room).to eq("testroom")
expect(grant.name).to eq("name")
expect(grant.identity).to eq("user")
expect(grant.attributes["mykey"]).to eq("myvalue")
end

it "fails on expired tokens" do
Expand Down

0 comments on commit d6846e2

Please sign in to comment.