From 4eb36e6cdd5b7bf53d8d28146bdac1898869a448 Mon Sep 17 00:00:00 2001 From: Karol Konkol <56369082+Karolk99@users.noreply.github.com> Date: Wed, 3 Apr 2024 12:48:27 +0200 Subject: [PATCH] Fix recording component request (#172) --- .../api_spec/component/recording.ex | 2 +- openapi.yaml | 1 - .../component/recording_component_test.exs | 30 +++++++++++++++++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/lib/jellyfish_web/api_spec/component/recording.ex b/lib/jellyfish_web/api_spec/component/recording.ex index 2d38ea64..3f47234e 100644 --- a/lib/jellyfish_web/api_spec/component/recording.ex +++ b/lib/jellyfish_web/api_spec/component/recording.ex @@ -39,7 +39,7 @@ defmodule JellyfishWeb.ApiSpec.Component.Recording do pathPrefix: %Schema{ type: :string, description: "Path prefix under which all recording are stored", - default: "" + default: nil }, credentials: %Schema{ type: :object, diff --git a/openapi.yaml b/openapi.yaml index 4b0694f7..70170a0c 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -161,7 +161,6 @@ components: - $ref: '#/components/schemas/S3Credentials' type: object pathPrefix: - default: '' description: Path prefix under which all recording are stored type: string title: ComponentOptionsRecording diff --git a/test/jellyfish_web/controllers/component/recording_component_test.exs b/test/jellyfish_web/controllers/component/recording_component_test.exs index 822561e1..5910e981 100644 --- a/test/jellyfish_web/controllers/component/recording_component_test.exs +++ b/test/jellyfish_web/controllers/component/recording_component_test.exs @@ -47,7 +47,7 @@ defmodule JellyfishWeb.Component.RecordingComponentTest do setup :set_mox_from_context - test "renders component when credentials are in passed in config", %{ + test "renders component when credentials are passed in config", %{ conn: conn, room_id: room_id } do @@ -73,6 +73,32 @@ defmodule JellyfishWeb.Component.RecordingComponentTest do clean_s3_envs() end + test "renders component when path prefix is passed in config", %{ + conn: conn, + room_id: room_id + } do + mock_http_request() + put_s3_envs(path_prefix: @path_prefix, credentials: nil) + + conn = + post(conn, ~p"/room/#{room_id}/component", + type: "recording", + options: %{credentials: Enum.into(@s3_credentials, %{})} + ) + + assert %{ + "data" => %{ + "id" => id, + "type" => "recording", + "properties" => %{"pathPrefix" => @path_prefix} + } + } = model_response(conn, :created, "ComponentDetailsResponse") + + assert_component_created(conn, room_id, id, "recording") + + clean_s3_envs() + end + test "renders error when credentials are passed both in config and request", %{ conn: conn, room_id: room_id @@ -100,7 +126,7 @@ defmodule JellyfishWeb.Component.RecordingComponentTest do conn = post(conn, ~p"/room/#{room_id}/component", type: "recording", - options: %{path_prefix: @path_prefix} + options: %{pathPrefix: @path_prefix} ) assert model_response(conn, :bad_request, "Error")["errors"] ==