|
50 | 50 | expect(expiring_token).to carry_valid_token_signature api_secret
|
51 | 51 | end
|
52 | 52 |
|
53 |
| - it "generates tokens with a role" do |
| 53 | + it "generates tokens with a publisher role" do |
| 54 | + role = :publisher |
| 55 | + role_token = opentok.generate_token session_id, :role => role |
| 56 | + expect(role_token).to be_an_instance_of String |
| 57 | + expect(role_token).to carry_token_data :session_id => session_id |
| 58 | + expect(role_token).to carry_token_data :api_key => api_key |
| 59 | + expect(role_token).to carry_token_data :role => role |
| 60 | + expect(role_token).to carry_token_data [:nonce, :create_time] |
| 61 | + expect(role_token).to carry_valid_token_signature api_secret |
| 62 | + end |
| 63 | + |
| 64 | + it "generates tokens with a subscriber role" do |
| 65 | + role = :subscriber |
| 66 | + role_token = opentok.generate_token session_id, :role => role |
| 67 | + expect(role_token).to be_an_instance_of String |
| 68 | + expect(role_token).to carry_token_data :session_id => session_id |
| 69 | + expect(role_token).to carry_token_data :api_key => api_key |
| 70 | + expect(role_token).to carry_token_data :role => role |
| 71 | + expect(role_token).to carry_token_data [:nonce, :create_time] |
| 72 | + expect(role_token).to carry_valid_token_signature api_secret |
| 73 | + end |
| 74 | + |
| 75 | + it "generates tokens with a moderator role" do |
54 | 76 | role = :moderator
|
55 | 77 | role_token = opentok.generate_token session_id, :role => role
|
56 | 78 | expect(role_token).to be_an_instance_of String
|
|
61 | 83 | expect(role_token).to carry_valid_token_signature api_secret
|
62 | 84 | end
|
63 | 85 |
|
| 86 | + it "generates tokens with a publisheronly role" do |
| 87 | + role = :publisheronly |
| 88 | + role_token = opentok.generate_token session_id, :role => role |
| 89 | + expect(role_token).to be_an_instance_of String |
| 90 | + expect(role_token).to carry_token_data :session_id => session_id |
| 91 | + expect(role_token).to carry_token_data :api_key => api_key |
| 92 | + expect(role_token).to carry_token_data :role => role |
| 93 | + expect(role_token).to carry_token_data [:nonce, :create_time] |
| 94 | + expect(role_token).to carry_valid_token_signature api_secret |
| 95 | + end |
| 96 | + |
64 | 97 | it "generates tokens with data" do
|
65 | 98 | data = "name=Johnny"
|
66 | 99 | data_bearing_token = opentok.generate_token session_id, :data => data
|
|
97 | 130 | expect(layout_class_bearing_token).to carry_valid_token_signature api_secret
|
98 | 131 | end
|
99 | 132 |
|
| 133 | + context "when the role is invalid" do |
| 134 | + it "raises an error" do |
| 135 | + expect { opentok.generate_token session_id, :role => :invalid_role }.to raise_error |
| 136 | + end |
| 137 | + end |
100 | 138 |
|
101 | 139 | # TODO a context about using a bad session_id
|
102 | 140 | end
|
|
0 commit comments