amazon-chime-sdk-rails 2.0.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +7 -0
  3. data/.github/workflows/build.yml +14 -8
  4. data/CHANGELOG.md +28 -0
  5. data/Dockerfile +1 -1
  6. data/Gemfile +3 -7
  7. data/README.md +12 -8
  8. data/amazon-chime-sdk-rails.gemspec +7 -7
  9. data/docs/Develop_Rails_API_Application.md +9 -2
  10. data/docs/Develop_Rails_View_Application.md +9 -14
  11. data/gemfiles/Gemfile.rails-7.0 +2 -5
  12. data/gemfiles/Gemfile.rails-7.1 +1 -4
  13. data/gemfiles/Gemfile.rails-7.2 +1 -4
  14. data/gemfiles/Gemfile.rails-8.0 +1 -6
  15. data/gemfiles/Gemfile.rails-8.1 +21 -0
  16. data/lib/chime_sdk/config.rb +10 -0
  17. data/lib/chime_sdk/controller/attendees.rb +17 -3
  18. data/lib/chime_sdk/controller/common.rb +47 -1
  19. data/lib/chime_sdk/controller/meetings.rb +7 -5
  20. data/lib/chime_sdk/version.rb +1 -1
  21. data/lib/generators/chime_sdk/js_generator.rb +6 -1
  22. data/lib/generators/templates/chime_sdk.rb +5 -0
  23. data/lib/generators/templates/controllers/meeting_attendees_controller.rb +13 -1
  24. data/lib/generators/templates/controllers/meetings_controller.rb +2 -1
  25. data/lib/generators/templates/views/meetings/show.html.erb +21 -11
  26. data/spec/generators/controllers_generator_spec.rb +2 -0
  27. data/spec/rails_app/app/assets/javascripts/application.js +1 -3
  28. data/spec/rails_app/app/controllers/api/public/meeting_attendees_controller.rb +6 -0
  29. data/spec/rails_app/app/controllers/api/public/meetings_controller.rb +6 -0
  30. data/spec/rails_app/app/controllers/meeting_attendees_controller.rb +10 -0
  31. data/spec/rails_app/app/views/layouts/application.html.erb +2 -2
  32. data/spec/rails_app/app/views/meetings/show.html.erb +21 -11
  33. data/spec/rails_app/app/views/rooms/show.html.erb +1 -5
  34. data/spec/rails_app/config/environments/test.rb +8 -1
  35. data/spec/requests/atendees_spec.rb +56 -0
  36. data/spec/requests/meetings_spec.rb +105 -8
  37. metadata +18 -19
@@ -22,4 +22,9 @@ ChimeSdk.configure do |config|
22
22
 
23
23
  # Configure whether the application creates meeting in meetings#index action by HTTP GET request.
24
24
  config.create_meeting_by_get_request = false
25
+
26
+ # Configure whether the controllers verify that requested meetings were created with config.prefix + meeting_request_id.
27
+ # When enabled, meetings and attendees controllers respond with 404 for meetings of other resources, such as other private rooms.
28
+ # Default value is true. Disabling it allows any meeting in your AWS account to be accessed by its meeting id.
29
+ config.verify_meeting_request_id = true
25
30
  end
@@ -23,14 +23,26 @@ class <%= @namespace %><%= @class_name_prefix %>MeetingAttendeesController < App
23
23
  # params[:id]
24
24
  # end
25
25
 
26
+ # Unique meeting request id to identify meeting by Amazon Chime.
27
+ # Configure it depending on your application resources to identify meeting.
28
+ # For example, set "PrivateRoom-#{@room.id}" by Room model.
29
+ # Use the same value as your meetings controller since requested meetings are verified with this id.
30
+ # @api protected
31
+ # @return [String] Unique meeting request id to identify meeting by Amazon Chime
32
+ def meeting_request_id
33
+ # "PrivateRoom-#{@room.id}"
34
+ "<%= @default_meeting_request_id %>"
35
+ end
36
+
26
37
  # Unique attendee request id to identify attendee by Amazon Chime.
27
38
  # Configure it depending on your application resources to identify attendee.
28
39
  # For example, set "User-#{current_user.id}" by User model.
40
+ # Each user must have a different value, since users with the same value join meetings as the same attendee.
29
41
  # @api protected
30
42
  # @return [String] Unique attendee request id to identify attendee by Amazon Chime
31
43
  def attendee_request_id
32
44
  # "User-#{current_user.id}"
33
- "default"
45
+ raise NotImplementedError, "Define attendee_request_id in #{self.class.name} to identify each attendee, e.g. \"User-\#{current_user.id}\""
34
46
  end
35
47
 
36
48
  # Path for meetings#index action such as meetings_path.
@@ -28,11 +28,12 @@ class <%= @namespace %><%= @class_name_prefix %>MeetingsController < Application
28
28
  # Unique attendee request id to identify attendee by Amazon Chime.
29
29
  # Configure it depending on your application resources to identify attendee.
30
30
  # For example, set "User-#{current_user.id}" by User model.
31
+ # Each user must have a different value, since users with the same value join meetings as the same attendee.
31
32
  # @api protected
32
33
  # @return [String] Unique attendee request id to identify attendee by Amazon Chime
33
34
  def attendee_request_id
34
35
  # "User-#{current_user.id}"
35
- "default"
36
+ raise NotImplementedError, "Define attendee_request_id in #{self.class.name} to identify each attendee, e.g. \"User-\#{current_user.id}\""
36
37
  end
37
38
 
38
39
  # Path for meetings#index action such as meetings_path.
@@ -38,7 +38,6 @@
38
38
  <% end %>
39
39
 
40
40
  <%= javascript_include_tag "amazon-chime-sdk.min.js" %>
41
- <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
42
41
 
43
42
  <script defer>
44
43
  // This is a very simple script as a template view using Amazon Chime SDK.
@@ -63,9 +62,16 @@
63
62
  const configuration = new ChimeSDK.MeetingSessionConfiguration(meeting, attendee);
64
63
  const meetingSession = new ChimeSDK.DefaultMeetingSession(configuration, logger, deviceController);
65
64
 
66
- const attendeeApi = axios.create({
67
- baseURL: `${attendeeResourcesPath}/`
68
- });
65
+ async function getAttendee(attendeeId) {
66
+ const response = await fetch(`${attendeeResourcesPath}/${encodeURIComponent(attendeeId)}`, {
67
+ headers: { 'Accept': 'application/json' },
68
+ credentials: 'same-origin'
69
+ });
70
+ if (!response.ok) {
71
+ throw new Error(`Failed to get attendee: ${response.status}`);
72
+ }
73
+ return response.json();
74
+ }
69
75
 
70
76
  async function join() {
71
77
  try {
@@ -109,9 +115,9 @@
109
115
  const presentAttendeeMap = {};
110
116
  const callback = (presentAttendeeId, present) => {
111
117
  if (present) {
112
- attendeeApi.get(presentAttendeeId)
113
- .then(response => {
114
- presentAttendeeMap[presentAttendeeId] = response.data;
118
+ getAttendee(presentAttendeeId)
119
+ .then(attendee => {
120
+ presentAttendeeMap[presentAttendeeId] = attendee;
115
121
  updateAttendeeStatus(presentAttendeeMap);
116
122
  })
117
123
  .catch(error => {
@@ -126,11 +132,15 @@
126
132
  }
127
133
 
128
134
  function updateAttendeeStatus(presentAttendeeMap) {
129
- presentAttendees = "<strong>Present Attendees</strong><ul>";
135
+ // Use textContent since attendee names are user-provided values
136
+ const title = document.createElement('strong');
137
+ title.textContent = 'Present Attendees';
138
+ const list = document.createElement('ul');
130
139
  Object.values(presentAttendeeMap).forEach(attendee => {
131
- presentAttendees = presentAttendees + `<li>${showApplicationUserName(attendee)}</li>`
140
+ const item = document.createElement('li');
141
+ item.textContent = showApplicationUserName(attendee);
142
+ list.appendChild(item);
132
143
  });
133
- presentAttendees = presentAttendees + '</ul>'
134
- document.getElementById("attendee-status").innerHTML = presentAttendees;
144
+ document.getElementById("attendee-status").replaceChildren(title, list);
135
145
  }
136
146
  </script>
@@ -29,6 +29,8 @@ describe ChimeSdk::Generators::ControllersGenerator, type: :generator do
29
29
  it { is_expected.to exist }
30
30
  it { is_expected.to contain(/class MeetingAttendeesController < ApplicationController/) }
31
31
  it { is_expected.to contain(" meetings_path(params)\n") }
32
+ it { is_expected.to contain(" def meeting_request_id\n # \"PrivateRoom-\#{@room.id}\"\n \"default\"\n") }
33
+ it { is_expected.to contain(" def attendee_request_id\n # \"User-\#{current_user.id}\"\n raise NotImplementedError") }
32
34
  end
33
35
  end
34
36
 
@@ -1,3 +1 @@
1
- //= require rails-ujs
2
- //= require turbolinks
3
- //= require_tree .
1
+ //= require_tree .
@@ -8,4 +8,10 @@ class Api::Public::MeetingAttendeesController < ApplicationController
8
8
  "User": User.find_by_id(user_id)
9
9
  }
10
10
  end
11
+
12
+ # This public API for the React Meeting Demo accepts any meeting in the AWS account by its meeting id.
13
+ # Do not disable this verification in your applications unless you authorize access to meetings by yourself.
14
+ def verify_meeting_request_id?
15
+ false
16
+ end
11
17
  end
@@ -12,4 +12,10 @@ class Api::Public::MeetingsController < ApplicationController
12
12
  "PrivateRoom": Room.find_by_id(room_id)
13
13
  }
14
14
  end
15
+
16
+ # This public API for the React Meeting Demo accepts any meeting in the AWS account by its meeting id.
17
+ # Do not disable this verification in your applications unless you authorize access to meetings by yourself.
18
+ def verify_meeting_request_id?
19
+ false
20
+ end
15
21
  end
@@ -39,6 +39,16 @@ class MeetingAttendeesController < ApplicationController
39
39
  # params[:id]
40
40
  # end
41
41
 
42
+ # Unique meeting request id to identify meeting by Amazon Chime.
43
+ # Configure it depending on your application resources to identify meeting.
44
+ # For example, set "PrivateRoom-#{@room.id}" by Room model.
45
+ # Use the same value as your meetings controller since requested meetings are verified with this id.
46
+ # @api protected
47
+ # @return [String] Unique meeting request id to identify meeting by Amazon Chime
48
+ def meeting_request_id
49
+ "PrivateRoom-#{@room.id}"
50
+ end
51
+
42
52
  # Unique attendee request id to identify attendee by Amazon Chime.
43
53
  # Configure it depending on your application resources to identify attendee.
44
54
  # For example, set "User-#{current_user.id}" by User model.
@@ -4,8 +4,8 @@
4
4
  <title>Rails Application for Amazon Chime SDK Meeting</title>
5
5
  <%= csrf_meta_tags %>
6
6
 
7
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
8
- <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
7
+ <%= stylesheet_link_tag 'application', media: 'all' %>
8
+ <%= javascript_include_tag 'application' %>
9
9
  </head>
10
10
 
11
11
  <body>
@@ -43,7 +43,6 @@
43
43
  <% end %>
44
44
 
45
45
  <%= javascript_include_tag "amazon-chime-sdk.min.js" %>
46
- <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
47
46
 
48
47
  <script defer>
49
48
  // This is a very simple script as a template view using Amazon Chime SDK.
@@ -75,9 +74,16 @@
75
74
  const configuration = new ChimeSDK.MeetingSessionConfiguration(meeting, attendee);
76
75
  const meetingSession = new ChimeSDK.DefaultMeetingSession(configuration, logger, deviceController);
77
76
 
78
- const attendeeApi = axios.create({
79
- baseURL: `${attendeeResourcesPath}/`
80
- });
77
+ async function getAttendee(attendeeId) {
78
+ const response = await fetch(`${attendeeResourcesPath}/${encodeURIComponent(attendeeId)}`, {
79
+ headers: { 'Accept': 'application/json' },
80
+ credentials: 'same-origin'
81
+ });
82
+ if (!response.ok) {
83
+ throw new Error(`Failed to get attendee: ${response.status}`);
84
+ }
85
+ return response.json();
86
+ }
81
87
 
82
88
  async function join() {
83
89
  try {
@@ -121,9 +127,9 @@
121
127
  const presentAttendeeMap = {};
122
128
  const callback = (presentAttendeeId, present) => {
123
129
  if (present) {
124
- attendeeApi.get(presentAttendeeId)
125
- .then(response => {
126
- presentAttendeeMap[presentAttendeeId] = response.data;
130
+ getAttendee(presentAttendeeId)
131
+ .then(attendee => {
132
+ presentAttendeeMap[presentAttendeeId] = attendee;
127
133
  updateAttendeeStatus(presentAttendeeMap);
128
134
  })
129
135
  .catch(error => {
@@ -138,11 +144,15 @@
138
144
  }
139
145
 
140
146
  function updateAttendeeStatus(presentAttendeeMap) {
141
- presentAttendees = "<strong>Present Attendees</strong><ul>";
147
+ // Use textContent since attendee names are user-provided values
148
+ const title = document.createElement('strong');
149
+ title.textContent = 'Present Attendees';
150
+ const list = document.createElement('ul');
142
151
  Object.values(presentAttendeeMap).forEach(attendee => {
143
- presentAttendees = presentAttendees + `<li>${showApplicationUserName(attendee)}</li>`
152
+ const item = document.createElement('li');
153
+ item.textContent = showApplicationUserName(attendee);
154
+ list.appendChild(item);
144
155
  });
145
- presentAttendees = presentAttendees + '</ul>'
146
- document.getElementById("attendee-status").innerHTML = presentAttendees;
156
+ document.getElementById("attendee-status").replaceChildren(title, list);
147
157
  }
148
158
  </script>
@@ -8,11 +8,7 @@
8
8
  <p>
9
9
  <strong>Private Meeting:</strong>
10
10
  <p><%= link_to 'Show Meetings Index', room_meetings_path(@room) %></p>
11
- <p>
12
- Create Meeting
13
- <%= link_to 'GET', room_meetings_path(@room, create_meeting: true) %>
14
- <%= link_to 'POST', room_meetings_path(@room), method: :post %>
15
- </p>
11
+ <p><%= link_to 'Create Meeting', room_meetings_path(@room), method: :post %></p>
16
12
  </p>
17
13
 
18
14
  <p>
@@ -26,7 +26,11 @@ Rails.application.configure do
26
26
  config.cache_store = :null_store
27
27
 
28
28
  # Raise exceptions instead of rendering exception templates.
29
- config.action_dispatch.show_exceptions = false
29
+ if Rails::VERSION::MAJOR >= 8 || (Rails::VERSION::MAJOR == 7 && Rails::VERSION::MINOR >= 1)
30
+ config.action_dispatch.show_exceptions = :rescuable
31
+ else
32
+ config.action_dispatch.show_exceptions = false
33
+ end
30
34
 
31
35
  # Disable request forgery protection in test environment.
32
36
  config.action_controller.allow_forgery_protection = false
@@ -44,6 +48,9 @@ Rails.application.configure do
44
48
  # Print deprecation notices to the stderr.
45
49
  config.active_support.deprecation = :stderr
46
50
 
51
+ # Do not check if assets exist before linking to them.
52
+ config.assets.check_precompiled_asset = false if config.respond_to?(:assets) && config.assets.respond_to?(:check_precompiled_asset=)
53
+
47
54
  # Raises error for missing translations.
48
55
  # config.action_view.raise_on_missing_translations = true
49
56
  end
@@ -4,8 +4,10 @@ describe ChimeSdk::Controller::Attendees, type: :request do
4
4
  @attendee_id = "76543210-ba98-fedc-jihg-vutsrqponmlk"
5
5
  @dummy_meeting_id = "91234567-89ab-cdef-ghij-klmnopqrstuv"
6
6
  @dummy_attendee_id = "96543210-ba98-fedc-jihg-vutsrqponmlk"
7
+ @other_meeting_id = "81234567-89ab-cdef-ghij-klmnopqrstuv"
7
8
 
8
9
  @room = create(:room)
10
+ @other_room = create(:room)
9
11
  @attendee_user = create(:user)
10
12
  @room.add_member(@attendee_user)
11
13
  test_attendee = {
@@ -29,8 +31,24 @@ describe ChimeSdk::Controller::Attendees, type: :request do
29
31
  }
30
32
  }
31
33
 
34
+ meeting_of = -> (meeting_id, room) {
35
+ {
36
+ meeting_id: meeting_id,
37
+ external_meeting_id: "ChimeSdkRailsApp-test-PrivateRoom-#{room.id}",
38
+ media_region: "us-east-1",
39
+ media_placement: { audio_host_url: "dummy" }
40
+ }
41
+ }
42
+
32
43
  # Use stubs for the AWS SDK for Ruby
33
44
  client = Aws::ChimeSDKMeetings::Client.new(stub_responses: true)
45
+ client.stub_responses(:get_meeting, -> (context) {
46
+ case context.params[:meeting_id]
47
+ when @meeting_id then { meeting: meeting_of.(@meeting_id, @room) }
48
+ when @other_meeting_id then { meeting: meeting_of.(@other_meeting_id, @other_room) }
49
+ else 'ForbiddenException'
50
+ end
51
+ })
34
52
  client.stub_responses(:list_attendees, {
35
53
  attendees: [ test_attendee, dummy_attendee ]
36
54
  })
@@ -109,6 +127,12 @@ describe ChimeSdk::Controller::Attendees, type: :request do
109
127
  it "returns valid attendee in the list" do
110
128
  expect(JSON.parse(response.body)["attendees"][0]["Attendee"]["AttendeeId"]).to eq(@attendee_id)
111
129
  end
130
+
131
+ it "does not return join tokens of attendees in the list" do
132
+ JSON.parse(response.body)["attendees"].each do |attendee|
133
+ expect(attendee["Attendee"]).not_to have_key("JoinToken")
134
+ end
135
+ end
112
136
  end
113
137
 
114
138
  describe "GET /meetings/:meeting_id/attendees/:attendee_id" do
@@ -125,6 +149,10 @@ describe ChimeSdk::Controller::Attendees, type: :request do
125
149
  expect(JSON.parse(response.body)["Attendee"]["AttendeeId"]).to eq(@attendee_id)
126
150
  end
127
151
 
152
+ it "does not return join token of the attendee" do
153
+ expect(JSON.parse(response.body)["Attendee"]).not_to have_key("JoinToken")
154
+ end
155
+
128
156
  it "returns application metadata in the attendee" do
129
157
  expect(JSON.parse(response.body)["Attendee"]["ApplicationMetadata"]["User"]["id"]).to eq(@attendee_user.id)
130
158
  end
@@ -165,6 +193,34 @@ describe ChimeSdk::Controller::Attendees, type: :request do
165
193
  end
166
194
  end
167
195
 
196
+ context "when the meeting belongs to another private room" do
197
+ let(:other_meeting_path) { "#{api_path}/meetings/#{@other_meeting_id}" }
198
+
199
+ it "returns response with 404 status to GET /meetings/:meeting_id/attendees" do
200
+ expect(ChimeSdk::MeetingCoordinator).not_to receive(:list_attendees)
201
+ get "#{other_meeting_path}/attendees", headers: @auth_headers
202
+ expect(response).to have_http_status(404)
203
+ end
204
+
205
+ it "returns response with 404 status to GET /meetings/:meeting_id/attendees/:attendee_id" do
206
+ expect(ChimeSdk::MeetingCoordinator).not_to receive(:get_attendee)
207
+ get "#{other_meeting_path}/attendees/#{@attendee_id}", headers: @auth_headers
208
+ expect(response).to have_http_status(404)
209
+ end
210
+
211
+ it "returns response with 404 status to POST /meetings/:meeting_id/attendees" do
212
+ expect(ChimeSdk::MeetingCoordinator).not_to receive(:create_attendee)
213
+ post "#{other_meeting_path}/attendees", headers: @auth_headers
214
+ expect(response).to have_http_status(404)
215
+ end
216
+
217
+ it "returns response with 404 status to DELETE /meetings/:meeting_id/attendees/:attendee_id" do
218
+ expect(ChimeSdk::MeetingCoordinator).not_to receive(:delete_attendee)
219
+ delete "#{other_meeting_path}/attendees/#{@attendee_id}", headers: @auth_headers
220
+ expect(response).to have_http_status(404)
221
+ end
222
+ end
223
+
168
224
  describe "DELETE /meetings/:meeting_id/attendees/:attendee_id" do
169
225
  context "when the attendee is found" do
170
226
  before do
@@ -3,8 +3,10 @@ describe ChimeSdk::Controller::Meetings, type: :request do
3
3
  @meeting_id = "01234567-89ab-cdef-ghij-klmnopqrstuv"
4
4
  @attendee_id = "76543210-ba98-fedc-jihg-vutsrqponmlk"
5
5
  @dummy_meeting_id = "91234567-89ab-cdef-ghij-klmnopqrstuv"
6
+ @other_meeting_id = "81234567-89ab-cdef-ghij-klmnopqrstuv"
6
7
 
7
8
  @room = create(:room)
9
+ @other_room = create(:room)
8
10
  dummy_media_placement = {
9
11
  audio_host_url: "dummy",
10
12
  audio_fallback_url: "dummy",
@@ -51,10 +53,19 @@ describe ChimeSdk::Controller::Meetings, type: :request do
51
53
  meeting_arn: "arn:aws:chime:us-east-1:000000000000:meeting/#{@meeting_id}"
52
54
  }
53
55
 
56
+ other_room_meeting = test_meeting.merge(
57
+ meeting_id: @other_meeting_id,
58
+ external_meeting_id: "ChimeSdkRailsApp-test-PrivateRoom-#{@other_room.id}"
59
+ )
60
+
54
61
  # Use stubs for the AWS SDK for Ruby
55
62
  client = Aws::ChimeSDKMeetings::Client.new(stub_responses: true)
56
63
  client.stub_responses(:get_meeting, -> (context) {
57
- context.params[:meeting_id] == @meeting_id ? { meeting: test_meeting } : 'NotFoundException'
64
+ case context.params[:meeting_id]
65
+ when @meeting_id then { meeting: test_meeting }
66
+ when @other_meeting_id then { meeting: other_room_meeting }
67
+ else 'NotFoundException'
68
+ end
58
69
  })
59
70
  client.stub_responses(:create_meeting, {
60
71
  meeting: test_meeting
@@ -131,18 +142,37 @@ describe ChimeSdk::Controller::Meetings, type: :request do
131
142
  end
132
143
  end
133
144
 
134
- context "with true as create_meeting parameter" do
145
+ context "with true as create_meeting parameter and ChimeSdk.config.create_meeting_by_get_request is disabled" do
135
146
  before do
136
147
  get "#{api_path}/meetings", headers: @auth_headers, params: { create_meeting: true }
137
148
  end
138
149
 
139
- it "returns response with 201 status" do
140
- expect(response).to have_http_status(201)
150
+ it "does not create meeting" do
151
+ expect(response).to have_http_status(200)
152
+ expect(JSON.parse(response.body)["Meeting"]).to be_nil
141
153
  end
154
+ end
142
155
 
143
- it "returns created meeting" do
156
+ context "when ChimeSdk.config.create_meeting_by_get_request is enabled" do
157
+ before do
158
+ ChimeSdk.config.create_meeting_by_get_request = true
159
+ end
160
+
161
+ after do
162
+ ChimeSdk.config.create_meeting_by_get_request = false
163
+ end
164
+
165
+ it "returns created meeting with 201 status" do
166
+ get "#{api_path}/meetings", headers: @auth_headers
167
+ expect(response).to have_http_status(201)
144
168
  expect(JSON.parse(response.body)["Meeting"]["MeetingId"]).to eq(@meeting_id)
145
169
  end
170
+
171
+ it "does not create meeting with false as create_meeting parameter" do
172
+ get "#{api_path}/meetings", headers: @auth_headers, params: { create_meeting: false }
173
+ expect(response).to have_http_status(200)
174
+ expect(JSON.parse(response.body)["Meeting"]).to be_nil
175
+ end
146
176
  end
147
177
  end
148
178
 
@@ -178,6 +208,52 @@ describe ChimeSdk::Controller::Meetings, type: :request do
178
208
  expect(response).to have_http_status(404)
179
209
  end
180
210
  end
211
+
212
+ context "with true as create_attendee_from_meeting parameter and ChimeSdk.config.create_attendee_from_meeting is disabled" do
213
+ before do
214
+ ChimeSdk.config.create_attendee_from_meeting = false
215
+ get "#{api_path}/meetings/#{@meeting_id}", params: { create_attendee_from_meeting: true }, headers: @auth_headers
216
+ end
217
+
218
+ after do
219
+ ChimeSdk.config.create_attendee_from_meeting = true
220
+ end
221
+
222
+ it "does not create attendee" do
223
+ expect(response).to have_http_status(200)
224
+ expect(JSON.parse(response.body)["Attendee"]).to be_nil
225
+ end
226
+ end
227
+
228
+ context "when the meeting belongs to another private room" do
229
+ before do
230
+ get "#{api_path}/meetings/#{@other_meeting_id}", headers: @auth_headers
231
+ end
232
+
233
+ it "returns response with 404 status" do
234
+ expect(response).to have_http_status(404)
235
+ end
236
+
237
+ it "does not return the meeting" do
238
+ expect(JSON.parse(response.body)["Meeting"]).to be_nil
239
+ end
240
+ end
241
+
242
+ context "when the meeting belongs to another private room and ChimeSdk.config.verify_meeting_request_id is disabled" do
243
+ before do
244
+ ChimeSdk.config.verify_meeting_request_id = false
245
+ get "#{api_path}/meetings/#{@other_meeting_id}", params: { create_attendee_from_meeting: false }, headers: @auth_headers
246
+ end
247
+
248
+ after do
249
+ ChimeSdk.config.verify_meeting_request_id = true
250
+ end
251
+
252
+ it "returns the meeting" do
253
+ expect(response).to have_http_status(200)
254
+ expect(JSON.parse(response.body)["Meeting"]["MeetingId"]).to eq(@other_meeting_id)
255
+ end
256
+ end
181
257
  end
182
258
 
183
259
  describe "POST /meetings" do
@@ -243,6 +319,14 @@ describe ChimeSdk::Controller::Meetings, type: :request do
243
319
  expect(response).to have_http_status(404)
244
320
  end
245
321
  end
322
+
323
+ context "when the meeting belongs to another private room" do
324
+ it "returns response with 404 status without deleting the meeting" do
325
+ expect(ChimeSdk::MeetingCoordinator).not_to receive(:delete_meeting)
326
+ delete "#{api_path}/meetings/#{@other_meeting_id}", headers: @auth_headers
327
+ expect(response).to have_http_status(404)
328
+ end
329
+ end
246
330
  end
247
331
  end
248
332
  end
@@ -310,16 +394,29 @@ describe ChimeSdk::Controller::Meetings, type: :request do
310
394
  end
311
395
  end
312
396
 
313
- context "with true as create_meeting parameter" do
397
+ context "with true as create_meeting parameter and ChimeSdk.config.create_meeting_by_get_request is disabled" do
314
398
  before do
315
399
  get "#{api_path}/meetings", params: { create_meeting: true }
316
400
  end
317
401
 
318
- it "returns response with 302 status" do
319
- expect(response).to have_http_status(302)
402
+ it "does not create meeting" do
403
+ expect(response).to have_http_status(200)
404
+ expect(response.body).to include("Meetings by Amazon Chime SDK")
405
+ end
406
+ end
407
+
408
+ context "when ChimeSdk.config.create_meeting_by_get_request is enabled" do
409
+ before do
410
+ ChimeSdk.config.create_meeting_by_get_request = true
411
+ get "#{api_path}/meetings"
412
+ end
413
+
414
+ after do
415
+ ChimeSdk.config.create_meeting_by_get_request = false
320
416
  end
321
417
 
322
418
  it "redirects to created meeting path" do
419
+ expect(response).to have_http_status(302)
323
420
  expect(response.body).to redirect_to("#{api_path}/meetings/#{@meeting_id}")
324
421
  end
325
422
  end