diff --git a/config/test.exs b/config/test.exs
index 802b32cd3..3f04c721b 100644
--- a/config/test.exs
+++ b/config/test.exs
@@ -75,7 +75,7 @@ config :cadet,
lambda_name: "dummy"
],
uploader: [
- assets_bucket: "source-academy-assets",
+ assets_bucket: "test-sa-assets",
sourcecasts_bucket: "test-cadet-sourcecasts"
],
remote_execution: [
diff --git a/lib/cadet/assets/assets.ex b/lib/cadet/assets/assets.ex
index 37fecb1c6..79cedb78c 100644
--- a/lib/cadet/assets/assets.ex
+++ b/lib/cadet/assets/assets.ex
@@ -9,18 +9,18 @@ defmodule Cadet.Assets.Assets do
if(Mix.env() == :test, do: ["testFolder"], else: [])
@accepted_file_types ~w(.jpg .jpeg .gif .png .wav .mp3 .txt)
- def upload_to_s3(upload_params, folder_name, file_name) do
+ def upload_to_s3(upload_params, course_id, folder_name, file_name) do
file_type = Path.extname(file_name)
with :ok <- validate_file_name(file_name),
:ok <- validate_folder_name(folder_name),
:ok <- validate_file_type(file_type) do
- if object_exists?(folder_name, file_name) do
+ if object_exists?(course_id, folder_name, file_name) do
{:error, {:bad_request, "File already exists"}}
else
file = upload_params.path
- s3_path = "#{folder_name}/#{file_name}"
+ s3_path = "#{course_id}/#{folder_name}/#{file_name}"
file
|> Upload.stream_file()
@@ -32,11 +32,11 @@ defmodule Cadet.Assets.Assets do
end
end
- def list_assets(folder_name) do
+ def list_assets(course_id, folder_name) do
case validate_folder_name(folder_name) do
:ok ->
bucket()
- |> S3.list_objects(prefix: folder_name <> "/")
+ |> S3.list_objects(prefix: "#{course_id}/" <> folder_name <> "/")
|> ExAws.stream!()
|> Enum.map(fn file -> file.key end)
@@ -45,12 +45,12 @@ defmodule Cadet.Assets.Assets do
end
end
- def delete_object(folder_name, file_name) do
+ def delete_object(course_id, folder_name, file_name) do
with :ok <- validate_file_name(file_name),
:ok <- validate_folder_name(folder_name) do
- if object_exists?(folder_name, file_name) do
+ if object_exists?(course_id, folder_name, file_name) do
bucket()
- |> S3.delete_object("#{folder_name}/#{file_name}")
+ |> S3.delete_object("#{course_id}/#{folder_name}/#{file_name}")
|> ExAws.request!()
:ok
@@ -60,9 +60,10 @@ defmodule Cadet.Assets.Assets do
end
end
- @spec object_exists?(binary, binary) :: boolean()
- def object_exists?(folder_name, file_name) do
- response = bucket() |> S3.head_object("#{folder_name}/#{file_name}") |> ExAws.request()
+ @spec object_exists?(integer(), binary, binary) :: boolean()
+ def object_exists?(course_id, folder_name, file_name) do
+ response =
+ bucket() |> S3.head_object("#{course_id}/#{folder_name}/#{file_name}") |> ExAws.request()
case response do
{:error, _error} -> false
diff --git a/lib/cadet_web/admin_controllers/admin_assets_controller.ex b/lib/cadet_web/admin_controllers/admin_assets_controller.ex
index 6d96d11cb..d2eec9ec5 100644
--- a/lib/cadet_web/admin_controllers/admin_assets_controller.ex
+++ b/lib/cadet_web/admin_controllers/admin_assets_controller.ex
@@ -5,7 +5,9 @@ defmodule CadetWeb.AdminAssetsController do
alias Cadet.Assets.Assets
def index(conn, _params = %{"foldername" => foldername}) do
- case Assets.list_assets(foldername) do
+ course_reg = conn.assigns.course_reg
+
+ case Assets.list_assets(course_reg.course_id, foldername) do
{:error, {status, message}} -> conn |> put_status(status) |> text(message)
assets -> render(conn, "index.json", assets: assets)
end
@@ -13,9 +15,10 @@ defmodule CadetWeb.AdminAssetsController do
@spec delete(Plug.Conn.t(), map) :: Plug.Conn.t()
def delete(conn, _params = %{"foldername" => foldername, "filename" => filename}) do
+ course_reg = conn.assigns.course_reg
filename = Enum.join(filename, "/")
- case Assets.delete_object(foldername, filename) do
+ case Assets.delete_object(course_reg.course_id, foldername, filename) do
{:error, {status, message}} -> conn |> put_status(status) |> text(message)
_ -> conn |> put_status(204) |> text('')
end
@@ -26,9 +29,10 @@ defmodule CadetWeb.AdminAssetsController do
"filename" => filename,
"foldername" => foldername
}) do
+ course_reg = conn.assigns.course_reg
filename = Enum.join(filename, "/")
- case Assets.upload_to_s3(upload_params, foldername, filename) do
+ case Assets.upload_to_s3(upload_params, course_reg.course_id, foldername, filename) do
{:error, {status, message}} -> conn |> put_status(status) |> text(message)
resp -> render(conn, "show.json", resp: resp)
end
diff --git a/test/cadet/assets/assets_test.exs b/test/cadet/assets/assets_test.exs
index fdb59a552..74311dee6 100644
--- a/test/cadet/assets/assets_test.exs
+++ b/test/cadet/assets/assets_test.exs
@@ -7,24 +7,30 @@ defmodule Cadet.Assets.AssetsTest do
describe "Manage assets" do
test "accessible folder" do
use_cassette "aws/model_list_assets#1" do
- assert Assets.list_assets("testFolder") === [
- "testFolder/",
- "testFolder/test.png",
- "testFolder/test2.png"
+ assert Assets.list_assets(1, "testFolder") === [
+ "1/testFolder/",
+ "1/testFolder/test.png",
+ "1/testFolder/test2.png"
]
end
end
+ test "access another course with 0 folder" do
+ use_cassette "aws/model_list_assets#2" do
+ assert Assets.list_assets(2, "testFolder") === []
+ end
+ end
+
test "delete nonexistent file" do
use_cassette "aws/model_delete_asset#1" do
- assert Assets.delete_object("testFolder", "test4.png") ===
+ assert Assets.delete_object(1, "testFolder", "test4.png") ===
{:error, {:not_found, "File not found"}}
end
end
test "delete ok file" do
use_cassette "aws/model_delete_asset#2" do
- assert Assets.delete_object("testFolder", "test.png") === :ok
+ assert Assets.delete_object(1, "testFolder", "test.png") === :ok
end
end
@@ -32,6 +38,7 @@ defmodule Cadet.Assets.AssetsTest do
use_cassette "aws/model_upload_asset#1" do
assert Assets.upload_to_s3(
build_upload("test/fixtures/upload.png"),
+ 1,
"testFolder",
"test2.png"
) ===
@@ -43,10 +50,11 @@ defmodule Cadet.Assets.AssetsTest do
use_cassette "aws/model_upload_asset#2" do
assert Assets.upload_to_s3(
build_upload("test/fixtures/upload.png"),
+ 1,
"testFolder",
"test1.png"
) ===
- "https://source-academy-assets.s3.amazonaws.com/testFolder/test1.png"
+ "https://#{bucket()}.s3.amazonaws.com/1/testFolder/test1.png"
end
end
end
@@ -54,4 +62,6 @@ defmodule Cadet.Assets.AssetsTest do
defp build_upload(path, content_type \\ "image\png") do
%Plug.Upload{path: path, filename: Path.basename(path), content_type: content_type}
end
+
+ defp bucket, do: :cadet |> Application.fetch_env!(:uploader) |> Keyword.get(:assets_bucket)
end
diff --git a/test/cadet_web/admin_controllers/admin_assets_controller_test.exs b/test/cadet_web/admin_controllers/admin_assets_controller_test.exs
index 7cddf0562..1dd88c894 100644
--- a/test/cadet_web/admin_controllers/admin_assets_controller_test.exs
+++ b/test/cadet_web/admin_controllers/admin_assets_controller_test.exs
@@ -94,7 +94,7 @@ defmodule CadetWeb.AdminAssetsControllerTest do
end
describe "ok request" do
- @tag authenticate: :staff
+ @tag authenticate: :staff, course_id: 117
test "index file", %{conn: conn} do
course_id = conn.assigns.course_id
@@ -106,7 +106,7 @@ defmodule CadetWeb.AdminAssetsControllerTest do
end
end
- @tag authenticate: :staff
+ @tag authenticate: :staff, course_id: 117
test "delete file", %{conn: conn} do
course_id = conn.assigns.course_id
@@ -117,7 +117,7 @@ defmodule CadetWeb.AdminAssetsControllerTest do
end
end
- @tag authenticate: :staff
+ @tag authenticate: :staff, course_id: 117
test "upload file", %{conn: conn} do
course_id = conn.assigns.course_id
@@ -128,7 +128,7 @@ defmodule CadetWeb.AdminAssetsControllerTest do
})
assert json_response(conn, 200) ===
- "https://source-academy-assets.s3.amazonaws.com/testFolder/test.png"
+ "https://#{bucket()}.s3.amazonaws.com/#{course_id}/testFolder/test.png"
end
end
end
@@ -169,7 +169,7 @@ defmodule CadetWeb.AdminAssetsControllerTest do
end
describe "nested filename request" do
- @tag authenticate: :staff
+ @tag authenticate: :staff, course_id: 117
test "delete file", %{conn: conn} do
course_id = conn.assigns.course_id
@@ -180,7 +180,7 @@ defmodule CadetWeb.AdminAssetsControllerTest do
end
end
- @tag authenticate: :staff
+ @tag authenticate: :staff, course_id: 117
test "upload file", %{conn: conn} do
course_id = conn.assigns.course_id
@@ -191,7 +191,7 @@ defmodule CadetWeb.AdminAssetsControllerTest do
})
assert json_response(conn, 200) ===
- "https://source-academy-assets.s3.amazonaws.com/testFolder/nestedFolder/test.png"
+ "https://#{bucket()}.s3.amazonaws.com/#{course_id}/testFolder/nestedFolder/test.png"
end
end
end
@@ -202,4 +202,6 @@ defmodule CadetWeb.AdminAssetsControllerTest do
defp build_upload(path, content_type \\ "image/png") do
%Plug.Upload{path: path, filename: Path.basename(path), content_type: content_type}
end
+
+ defp bucket, do: :cadet |> Application.fetch_env!(:uploader) |> Keyword.get(:assets_bucket)
end
diff --git a/test/fixtures/vcr_cassettes/aws/controller_delete_asset#1.json b/test/fixtures/vcr_cassettes/aws/controller_delete_asset#1.json
index 646aa75c1..fb60631a2 100644
--- a/test/fixtures/vcr_cassettes/aws/controller_delete_asset#1.json
+++ b/test/fixtures/vcr_cassettes/aws/controller_delete_asset#1.json
@@ -15,7 +15,7 @@
"recv_timeout": 660000
},
"request_body": "",
- "url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/testFolder/test2.png"
+ "url": "https://s3.ap-southeast-1.amazonaws.com/test-sa-assets/117/testFolder/test2.png"
},
"response": {
"binary": false,
@@ -49,7 +49,7 @@
"recv_timeout": 660000
},
"request_body": "",
- "url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/testFolder/test2.png"
+ "url": "https://s3.ap-southeast-1.amazonaws.com/test-sa-assets/117/testFolder/test2.png"
},
"response": {
"binary": false,
@@ -62,4 +62,4 @@
"type": "ok"
}
}
-]
\ No newline at end of file
+]
diff --git a/test/fixtures/vcr_cassettes/aws/controller_delete_asset#2.json b/test/fixtures/vcr_cassettes/aws/controller_delete_asset#2.json
index 0f059d8aa..bc8e6d3c2 100644
--- a/test/fixtures/vcr_cassettes/aws/controller_delete_asset#2.json
+++ b/test/fixtures/vcr_cassettes/aws/controller_delete_asset#2.json
@@ -5,7 +5,7 @@
"headers": {
"Authorization": "***",
"host": "s3.ap-southeast-1.amazonaws.com",
- "x-amz-date": "20200704T190420Z",
+ "x-amz-date": "20200704T190423Z",
"content-length": "0",
"x-amz-content-sha256": "***"
},
@@ -15,14 +15,14 @@
"recv_timeout": 660000
},
"request_body": "",
- "url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/testFolder/nestedFolder/test2.png"
+ "url": "https://s3.ap-southeast-1.amazonaws.com/test-sa-assets/117/testFolder/nestedFolder/test2.png"
},
"response": {
"binary": false,
"body": null,
"headers": {
- "Date": "Sat, 04 Jul 2020 19:04:21 GMT",
- "Last-Modified": "Sat, 04 Jul 2020 19:03:31 GMT",
+ "Date": "Sat, 04 Jul 2020 19:04:24 GMT",
+ "Last-Modified": "Sat, 04 Jul 2020 18:58:52 GMT",
"ETag": "\"3104001edec38fadeb925b9dbddab198\"",
"Accept-Ranges": "bytes",
"Content-Type": "image/png",
@@ -39,7 +39,7 @@
"headers": {
"Authorization": "***",
"host": "s3.ap-southeast-1.amazonaws.com",
- "x-amz-date": "20200704T190421Z",
+ "x-amz-date": "20200704T190423Z",
"content-length": "0",
"x-amz-content-sha256": "***"
},
@@ -49,17 +49,17 @@
"recv_timeout": 660000
},
"request_body": "",
- "url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/testFolder/nestedFolder/test2.png"
+ "url": "https://s3.ap-southeast-1.amazonaws.com/test-sa-assets/117/testFolder/nestedFolder/test2.png"
},
"response": {
"binary": false,
"body": "",
"headers": {
- "Date": "Sat, 04 Jul 2020 19:04:22 GMT",
+ "Date": "Sat, 04 Jul 2020 19:04:24 GMT",
"Server": "AmazonS3"
},
"status_code": 204,
"type": "ok"
}
}
-]
\ No newline at end of file
+]
diff --git a/test/fixtures/vcr_cassettes/aws/controller_list_assets#1.json b/test/fixtures/vcr_cassettes/aws/controller_list_assets#1.json
index c90025214..519462577 100644
--- a/test/fixtures/vcr_cassettes/aws/controller_list_assets#1.json
+++ b/test/fixtures/vcr_cassettes/aws/controller_list_assets#1.json
@@ -14,11 +14,11 @@
"recv_timeout": 660000
},
"request_body": "",
- "url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/"
+ "url": "https://s3.ap-southeast-1.amazonaws.com/test-sa-assets/"
},
"response": {
"binary": false,
- "body": "\nsource-academy-assetstestFolder/1000falsetestFolder/2020-07-04T18:53:11.000Z"d41d8cd98f00b204e9800998ecf8427e"098bd2bd2de0c976fb511f741fea454cb1026b9e1f9ac9160fd9f51d07e765f19unixsp+cs1101sSTANDARDtestFolder/test.png2020-07-04T19:04:50.000Z"3104001edec38fadeb925b9dbddab198"803598bd2bd2de0c976fb511f741fea454cb1026b9e1f9ac9160fd9f51d07e765f19unixsp+cs1101sSTANDARDtestFolder/test2.png2020-07-04T19:04:50.000Z"3104001edec38fadeb925b9dbddab198"803598bd2bd2de0c976fb511f741fea454cb1026b9e1f9ac9160fd9f51d07e765f19unixsp+cs1101sSTANDARD",
+ "body": "\ntest-sa-assets117/testFolder/1000falsetestFolder/2020-07-04T18:53:11.000Z"d41d8cd98f00b204e9800998ecf8427e"098bd2bd2de0c976fb511f741fea454cb1026b9e1f9ac9160fd9f51d07e765f19unixsp+cs1101sSTANDARDtestFolder/test.png2020-07-04T19:04:50.000Z"3104001edec38fadeb925b9dbddab198"803598bd2bd2de0c976fb511f741fea454cb1026b9e1f9ac9160fd9f51d07e765f19unixsp+cs1101sSTANDARDtestFolder/test2.png2020-07-04T19:04:50.000Z"3104001edec38fadeb925b9dbddab198"803598bd2bd2de0c976fb511f741fea454cb1026b9e1f9ac9160fd9f51d07e765f19unixsp+cs1101sSTANDARD",
"headers": {
"Date": "Sat, 04 Jul 2020 19:04:57 GMT",
"x-amz-bucket-region": "ap-southeast-1",
diff --git a/test/fixtures/vcr_cassettes/aws/controller_upload_asset#1.json b/test/fixtures/vcr_cassettes/aws/controller_upload_asset#1.json
index d2d368d70..0a9064703 100644
--- a/test/fixtures/vcr_cassettes/aws/controller_upload_asset#1.json
+++ b/test/fixtures/vcr_cassettes/aws/controller_upload_asset#1.json
@@ -5,7 +5,7 @@
"headers": {
"Authorization": "***",
"host": "s3.ap-southeast-1.amazonaws.com",
- "x-amz-date": "20200704T190421Z",
+ "x-amz-date": "20210802T110002Z",
"content-length": "0",
"x-amz-content-sha256": "***"
},
@@ -15,13 +15,13 @@
"recv_timeout": 660000
},
"request_body": "",
- "url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/testFolder/test.png"
+ "url": "https://s3.ap-southeast-1.amazonaws.com/test-sa-assets/117/testFolder/test.png"
},
"response": {
"binary": false,
- "body": "\nsource-academy-assetstestFolder/test.png.2EnEkVehEMM61hmagbmwhodenj6TCiSgnwzQfDVir9Bj4f9TsuVvQ1aXGwqBypLXqrWKtw7MjM8Q6klQ94F4utNPNKnEG7RV06bD1Uws343jIRCvomw6tFXcPSjqedREjKn2C.KxYF2BtIT1fpBNw--",
+ "body": "\ntest-sa-assets148689/testFolder/test.png4Yy8HgHzbtzXH3XoEvCgp2v2CBA6yiQ_97OiOuOM2UtcZBOfS9WJreKi3F9yVipygVd4LtNaHLXT2ZMJZsQaU1pWmrVqP8xQuK1VN2TaZdXKs8yiR7KUM8RqBsJ3QdWvnJJ8gQjTbBYdjqiFi2NcNA--",
"headers": {
- "Date": "Sat, 04 Jul 2020 19:04:22 GMT",
+ "Date": "Mon, 02 Aug 2021 11:00:01 GMT",
"Transfer-Encoding": "chunked",
"Server": "AmazonS3"
},
@@ -35,7 +35,7 @@
"headers": {
"Authorization": "***",
"host": "s3.ap-southeast-1.amazonaws.com",
- "x-amz-date": "20200704T190421Z",
+ "x-amz-date": "20210802T110002Z",
"content-length": "0",
"x-amz-content-sha256": "***"
},
@@ -45,15 +45,14 @@
"recv_timeout": 660000
},
"request_body": "",
- "url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/testFolder/test.png"
+ "url": "https://s3.ap-southeast-1.amazonaws.com/test-sa-assets/117/testFolder/test.png"
},
"response": {
"binary": false,
"body": null,
"headers": {
"Content-Type": "application/xml",
- "Transfer-Encoding": "chunked",
- "Date": "Sat, 04 Jul 2020 19:04:21 GMT",
+ "Date": "Mon, 02 Aug 2021 11:00:00 GMT",
"Server": "AmazonS3"
},
"status_code": 404,
@@ -66,7 +65,7 @@
"headers": {
"Authorization": "***",
"host": "s3.ap-southeast-1.amazonaws.com",
- "x-amz-date": "20200704T190421Z",
+ "x-amz-date": "20210802T110002Z",
"content-length": "95",
"x-amz-content-sha256": "***"
},
@@ -76,19 +75,19 @@
"recv_timeout": 660000
},
"request_body": "",
- "url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/testFolder/test.png"
+ "url": "https://s3.ap-southeast-1.amazonaws.com/test-sa-assets/117/testFolder/test.png"
},
"response": {
"binary": false,
"body": "",
"headers": {
- "Date": "Sat, 04 Jul 2020 19:04:22 GMT",
+ "Date": "Mon, 02 Aug 2021 11:00:01 GMT",
"ETag": "\"60cf42b4d05caf10cf8bb15c0817a7b4\"",
- "Content-Length": "0",
- "Server": "AmazonS3"
+ "Server": "AmazonS3",
+ "Content-Length": "0"
},
"status_code": 200,
"type": "ok"
}
}
-]
\ No newline at end of file
+]
diff --git a/test/fixtures/vcr_cassettes/aws/controller_upload_asset#2.json b/test/fixtures/vcr_cassettes/aws/controller_upload_asset#2.json
index 107455396..74c5b4137 100644
--- a/test/fixtures/vcr_cassettes/aws/controller_upload_asset#2.json
+++ b/test/fixtures/vcr_cassettes/aws/controller_upload_asset#2.json
@@ -5,7 +5,7 @@
"headers": {
"Authorization": "***",
"host": "s3.ap-southeast-1.amazonaws.com",
- "x-amz-date": "20200704T190422Z",
+ "x-amz-date": "20210802T110004Z",
"content-length": "0",
"x-amz-content-sha256": "***"
},
@@ -15,13 +15,13 @@
"recv_timeout": 660000
},
"request_body": "",
- "url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/testFolder/nestedFolder/test.png"
+ "url": "https://s3.ap-southeast-1.amazonaws.com/test-sa-assets/117/testFolder/nestedFolder/test.png"
},
"response": {
"binary": false,
- "body": "\nsource-academy-assetstestFolder/nestedFolder/test.pngWUrnAEbR2AGAiMw4looUmu5e9rlZRM1.LUz72T0Sm161JutNyiq1Lfakpi2Z_jtx9GRdYRTO7yNOHmFowKHQ118WxtqPgKJxUEJsabMnVSkltBXkfNX_VuIsHxZX4aRqXOBmrJOyq8j7fBVDYUvyTQ--",
+ "body": "\ntest-sa-assets148694/testFolder/nestedFolder/test.pngjQOloaBCXjlYK5iRAQKuUVpX4bDPKZ0RSW8T3ndp4N.ZnW_e3eoE.AermyCbfytWRJ.i.tQ4lKSvruRteBTviJ5.492AlTIm6D08VEaszDayFRN_gGrdPclOZgxcT1b.UZ9V.Nku10KjcT7fc3BWbQ--",
"headers": {
- "Date": "Sat, 04 Jul 2020 19:04:23 GMT",
+ "Date": "Mon, 02 Aug 2021 11:00:04 GMT",
"Transfer-Encoding": "chunked",
"Server": "AmazonS3"
},
@@ -35,7 +35,7 @@
"headers": {
"Authorization": "***",
"host": "s3.ap-southeast-1.amazonaws.com",
- "x-amz-date": "20200704T190422Z",
+ "x-amz-date": "20210802T110004Z",
"content-length": "0",
"x-amz-content-sha256": "***"
},
@@ -45,15 +45,14 @@
"recv_timeout": 660000
},
"request_body": "",
- "url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/testFolder/nestedFolder/test.png"
+ "url": "https://s3.ap-southeast-1.amazonaws.com/test-sa-assets/117/testFolder/nestedFolder/test.png"
},
"response": {
"binary": false,
"body": null,
"headers": {
"Content-Type": "application/xml",
- "Transfer-Encoding": "chunked",
- "Date": "Sat, 04 Jul 2020 19:04:21 GMT",
+ "Date": "Mon, 02 Aug 2021 11:00:02 GMT",
"Server": "AmazonS3"
},
"status_code": 404,
@@ -66,7 +65,7 @@
"headers": {
"Authorization": "***",
"host": "s3.ap-southeast-1.amazonaws.com",
- "x-amz-date": "20200704T190422Z",
+ "x-amz-date": "20210802T110004Z",
"content-length": "95",
"x-amz-content-sha256": "***"
},
@@ -76,19 +75,19 @@
"recv_timeout": 660000
},
"request_body": "",
- "url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/testFolder/nestedFolder/test.png"
+ "url": "https://s3.ap-southeast-1.amazonaws.com/test-sa-assets/117/testFolder/nestedFolder/test.png"
},
"response": {
"binary": false,
"body": "",
"headers": {
- "Date": "Sat, 04 Jul 2020 19:04:23 GMT",
+ "Date": "Mon, 02 Aug 2021 11:00:04 GMT",
"ETag": "\"60cf42b4d05caf10cf8bb15c0817a7b4\"",
- "Content-Length": "0",
- "Server": "AmazonS3"
+ "Server": "AmazonS3",
+ "Content-Length": "0"
},
"status_code": 200,
"type": "ok"
}
}
-]
\ No newline at end of file
+]
diff --git a/test/fixtures/vcr_cassettes/aws/model_delete_asset#1.json b/test/fixtures/vcr_cassettes/aws/model_delete_asset#1.json
index 0752add76..d2b2a118a 100644
--- a/test/fixtures/vcr_cassettes/aws/model_delete_asset#1.json
+++ b/test/fixtures/vcr_cassettes/aws/model_delete_asset#1.json
@@ -5,7 +5,7 @@
"headers": {
"Authorization": "***",
"host": "s3.ap-southeast-1.amazonaws.com",
- "x-amz-date": "20200704T185902Z",
+ "x-amz-date": "20210802T105948Z",
"content-length": "0",
"x-amz-content-sha256": "***"
},
@@ -15,19 +15,18 @@
"recv_timeout": 660000
},
"request_body": "",
- "url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/testFolder/test4.png"
+ "url": "https://s3.ap-southeast-1.amazonaws.com/test-sa-assets/1/testFolder/test4.png"
},
"response": {
"binary": false,
"body": null,
"headers": {
"Content-Type": "application/xml",
- "Transfer-Encoding": "chunked",
- "Date": "Sat, 04 Jul 2020 18:59:02 GMT",
+ "Date": "Mon, 02 Aug 2021 10:59:47 GMT",
"Server": "AmazonS3"
},
"status_code": 404,
"type": "ok"
}
}
-]
\ No newline at end of file
+]
diff --git a/test/fixtures/vcr_cassettes/aws/model_delete_asset#2.json b/test/fixtures/vcr_cassettes/aws/model_delete_asset#2.json
index e940f153b..04a06a652 100644
--- a/test/fixtures/vcr_cassettes/aws/model_delete_asset#2.json
+++ b/test/fixtures/vcr_cassettes/aws/model_delete_asset#2.json
@@ -5,7 +5,7 @@
"headers": {
"Authorization": "***",
"host": "s3.ap-southeast-1.amazonaws.com",
- "x-amz-date": "20200704T185901Z",
+ "x-amz-date": "20210802T105956Z",
"content-length": "0",
"x-amz-content-sha256": "***"
},
@@ -15,19 +15,19 @@
"recv_timeout": 660000
},
"request_body": "",
- "url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/testFolder/test.png"
+ "url": "https://s3.ap-southeast-1.amazonaws.com/test-sa-assets/1/testFolder/test.png"
},
"response": {
"binary": false,
"body": null,
"headers": {
- "Date": "Sat, 04 Jul 2020 18:59:02 GMT",
- "Last-Modified": "Sat, 04 Jul 2020 18:58:52 GMT",
- "ETag": "\"3104001edec38fadeb925b9dbddab198\"",
+ "Date": "Mon, 02 Aug 2021 10:59:55 GMT",
+ "Last-Modified": "Mon, 02 Aug 2021 10:56:36 GMT",
+ "ETag": "\"33c5d4f094a7727780a3c63babae1083\"",
"Accept-Ranges": "bytes",
"Content-Type": "image/png",
- "Content-Length": "8035",
- "Server": "AmazonS3"
+ "Server": "AmazonS3",
+ "Content-Length": "2568"
},
"status_code": 200,
"type": "ok"
@@ -39,7 +39,7 @@
"headers": {
"Authorization": "***",
"host": "s3.ap-southeast-1.amazonaws.com",
- "x-amz-date": "20200704T185901Z",
+ "x-amz-date": "20210802T105956Z",
"content-length": "0",
"x-amz-content-sha256": "***"
},
@@ -49,13 +49,13 @@
"recv_timeout": 660000
},
"request_body": "",
- "url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/testFolder/test.png"
+ "url": "https://s3.ap-southeast-1.amazonaws.com/test-sa-assets/1/testFolder/test.png"
},
"response": {
"binary": false,
"body": "",
"headers": {
- "Date": "Sat, 04 Jul 2020 18:59:02 GMT",
+ "Date": "Mon, 02 Aug 2021 10:59:56 GMT",
"Server": "AmazonS3"
},
"status_code": 204,
diff --git a/test/fixtures/vcr_cassettes/aws/model_list_assets#1.json b/test/fixtures/vcr_cassettes/aws/model_list_assets#1.json
index ab64e23cd..8c2532351 100644
--- a/test/fixtures/vcr_cassettes/aws/model_list_assets#1.json
+++ b/test/fixtures/vcr_cassettes/aws/model_list_assets#1.json
@@ -5,7 +5,7 @@
"headers": {
"Authorization": "***",
"host": "s3.ap-southeast-1.amazonaws.com",
- "x-amz-date": "20200704T190051Z",
+ "x-amz-date": "20210802T105951Z",
"x-amz-content-sha256": "***"
},
"method": "get",
@@ -14,13 +14,13 @@
"recv_timeout": 660000
},
"request_body": "",
- "url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/"
+ "url": "https://s3.ap-southeast-1.amazonaws.com/test-sa-assets/"
},
"response": {
"binary": false,
- "body": "\nsource-academy-assetstestFolder/1000falsetestFolder/2020-07-04T18:53:11.000Z"d41d8cd98f00b204e9800998ecf8427e"098bd2bd2de0c976fb511f741fea454cb1026b9e1f9ac9160fd9f51d07e765f19xxxSTANDARDtestFolder/test.png2020-07-04T19:00:44.000Z"3104001edec38fadeb925b9dbddab198"803598bd2bd2de0c976fb511f741fea454cb1026b9e1f9ac9160fd9f51d07e765f19xxxSTANDARDtestFolder/test2.png2020-07-04T18:58:52.000Z"3104001edec38fadeb925b9dbddab198"803598bd2bd2de0c976fb511f741fea454cb1026b9e1f9ac9160fd9f51d07e765f19xxxSTANDARD",
+ "body": "\ntest-sa-assets1/testFolder/1000false1/testFolder/2021-08-02T10:23:39.000Z"d41d8cd98f00b204e9800998ecf8427e"098bd2bd2de0c976fb511f741fea454cb1026b9e1f9ac9160fd9f51d07e765f19unixsp+cs1101sSTANDARD1/testFolder/test.png2021-08-02T10:56:36.000Z"33c5d4f094a7727780a3c63babae1083"256898bd2bd2de0c976fb511f741fea454cb1026b9e1f9ac9160fd9f51d07e765f19unixsp+cs1101sSTANDARD1/testFolder/test2.png2021-08-02T10:25:15.000Z"af2ab457d8b118efa176bc12cff4895f"299698bd2bd2de0c976fb511f741fea454cb1026b9e1f9ac9160fd9f51d07e765f19unixsp+cs1101sSTANDARD",
"headers": {
- "Date": "Sat, 04 Jul 2020 19:00:52 GMT",
+ "Date": "Mon, 02 Aug 2021 10:59:51 GMT",
"x-amz-bucket-region": "ap-southeast-1",
"Content-Type": "application/xml",
"Transfer-Encoding": "chunked",
@@ -30,4 +30,4 @@
"type": "ok"
}
}
-]
+]
\ No newline at end of file
diff --git a/test/fixtures/vcr_cassettes/aws/model_list_assets#2.json b/test/fixtures/vcr_cassettes/aws/model_list_assets#2.json
new file mode 100644
index 000000000..90e54e9ac
--- /dev/null
+++ b/test/fixtures/vcr_cassettes/aws/model_list_assets#2.json
@@ -0,0 +1,33 @@
+[
+ {
+ "request": {
+ "body": "",
+ "headers": {
+ "Authorization": "***",
+ "host": "s3.ap-southeast-1.amazonaws.com",
+ "x-amz-date": "20210802T105950Z",
+ "x-amz-content-sha256": "***"
+ },
+ "method": "get",
+ "options": {
+ "with_body": "true",
+ "recv_timeout": 660000
+ },
+ "request_body": "",
+ "url": "https://s3.ap-southeast-1.amazonaws.com/test-sa-assets/"
+ },
+ "response": {
+ "binary": false,
+ "body": "\ntest-sa-assets2/testFolder/1000false",
+ "headers": {
+ "Date": "Mon, 02 Aug 2021 10:59:49 GMT",
+ "x-amz-bucket-region": "ap-southeast-1",
+ "Content-Type": "application/xml",
+ "Transfer-Encoding": "chunked",
+ "Server": "AmazonS3"
+ },
+ "status_code": 200,
+ "type": "ok"
+ }
+ }
+]
\ No newline at end of file
diff --git a/test/fixtures/vcr_cassettes/aws/model_upload_asset#1.json b/test/fixtures/vcr_cassettes/aws/model_upload_asset#1.json
index e0c34f67d..05484f371 100644
--- a/test/fixtures/vcr_cassettes/aws/model_upload_asset#1.json
+++ b/test/fixtures/vcr_cassettes/aws/model_upload_asset#1.json
@@ -5,7 +5,7 @@
"headers": {
"Authorization": "***",
"host": "s3.ap-southeast-1.amazonaws.com",
- "x-amz-date": "20200704T185901Z",
+ "x-amz-date": "20210802T105952Z",
"content-length": "0",
"x-amz-content-sha256": "***"
},
@@ -15,19 +15,19 @@
"recv_timeout": 660000
},
"request_body": "",
- "url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/testFolder/test2.png"
+ "url": "https://s3.ap-southeast-1.amazonaws.com/test-sa-assets/1/testFolder/test2.png"
},
"response": {
"binary": false,
"body": null,
"headers": {
- "Date": "Sat, 04 Jul 2020 18:59:02 GMT",
- "Last-Modified": "Sat, 04 Jul 2020 18:58:52 GMT",
- "ETag": "\"3104001edec38fadeb925b9dbddab198\"",
+ "Date": "Mon, 02 Aug 2021 10:59:52 GMT",
+ "Last-Modified": "Mon, 02 Aug 2021 10:25:15 GMT",
+ "ETag": "\"af2ab457d8b118efa176bc12cff4895f\"",
"Accept-Ranges": "bytes",
"Content-Type": "image/png",
- "Content-Length": "8035",
- "Server": "AmazonS3"
+ "Server": "AmazonS3",
+ "Content-Length": "2996"
},
"status_code": 200,
"type": "ok"
diff --git a/test/fixtures/vcr_cassettes/aws/model_upload_asset#2.json b/test/fixtures/vcr_cassettes/aws/model_upload_asset#2.json
index 32ac35e52..4ab2c41ad 100644
--- a/test/fixtures/vcr_cassettes/aws/model_upload_asset#2.json
+++ b/test/fixtures/vcr_cassettes/aws/model_upload_asset#2.json
@@ -5,7 +5,7 @@
"headers": {
"Authorization": "***",
"host": "s3.ap-southeast-1.amazonaws.com",
- "x-amz-date": "20200704T185904Z",
+ "x-amz-date": "20210802T105953Z",
"content-length": "0",
"x-amz-content-sha256": "***"
},
@@ -15,13 +15,13 @@
"recv_timeout": 660000
},
"request_body": "",
- "url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/testFolder/test1.png"
+ "url": "https://s3.ap-southeast-1.amazonaws.com/test-sa-assets/1/testFolder/test1.png"
},
"response": {
"binary": false,
- "body": "\nsource-academy-assetstestFolder/test1.pngk8EvSsT6HeF7fdv2d6pqVl6lvkJ71x4A9uXwfzMe5GAvJOiXm5p0X26mo_1H5N9vhjTgLrsAJAE.ZcUz_vytv86yvm6AqbYNmokRv6QxLGPiJPAzE.7JhveH7r9mSVpmnpzWdshDvE.idoUKH1.2QA--",
+ "body": "\ntest-sa-assets1/testFolder/test1.pngJk9B8v0z6kdQbTsuU9S4Wu0r5oCPGDwid8meJ4h6sdUGwNyMKSetyBSCooSrl6zormlRXJDxmzcZMQJp9ylbq.aNQql.Vf048gE28hUz5_.bSzARS8fxYzPQFjgvxgkVLK4sCM.QSI3KtEc6JpYJHg--",
"headers": {
- "Date": "Sat, 04 Jul 2020 18:59:05 GMT",
+ "Date": "Mon, 02 Aug 2021 10:59:53 GMT",
"Transfer-Encoding": "chunked",
"Server": "AmazonS3"
},
@@ -35,7 +35,7 @@
"headers": {
"Authorization": "***",
"host": "s3.ap-southeast-1.amazonaws.com",
- "x-amz-date": "20200704T185904Z",
+ "x-amz-date": "20210802T105953Z",
"content-length": "0",
"x-amz-content-sha256": "***"
},
@@ -45,15 +45,14 @@
"recv_timeout": 660000
},
"request_body": "",
- "url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/testFolder/test1.png"
+ "url": "https://s3.ap-southeast-1.amazonaws.com/test-sa-assets/1/testFolder/test1.png"
},
"response": {
"binary": false,
"body": null,
"headers": {
"Content-Type": "application/xml",
- "Transfer-Encoding": "chunked",
- "Date": "Sat, 04 Jul 2020 18:59:03 GMT",
+ "Date": "Mon, 02 Aug 2021 10:59:52 GMT",
"Server": "AmazonS3"
},
"status_code": 404,
@@ -66,7 +65,7 @@
"headers": {
"Authorization": "***",
"host": "s3.ap-southeast-1.amazonaws.com",
- "x-amz-date": "20200704T185904Z",
+ "x-amz-date": "20210802T105953Z",
"content-length": "95",
"x-amz-content-sha256": "***"
},
@@ -76,16 +75,16 @@
"recv_timeout": 660000
},
"request_body": "",
- "url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/testFolder/test1.png"
+ "url": "https://s3.ap-southeast-1.amazonaws.com/test-sa-assets/1/testFolder/test1.png"
},
"response": {
"binary": false,
"body": "",
"headers": {
- "Date": "Sat, 04 Jul 2020 18:59:05 GMT",
+ "Date": "Mon, 02 Aug 2021 10:59:53 GMT",
"ETag": "\"60cf42b4d05caf10cf8bb15c0817a7b4\"",
- "Content-Length": "0",
- "Server": "AmazonS3"
+ "Server": "AmazonS3",
+ "Content-Length": "0"
},
"status_code": 200,
"type": "ok"
diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex
index ef8da28c5..352e15765 100644
--- a/test/support/conn_case.ex
+++ b/test/support/conn_case.ex
@@ -52,7 +52,7 @@ defmodule CadetWeb.ConnCase do
conn = Phoenix.ConnTest.build_conn()
if tags[:authenticate] do
- course = Factory.insert(:course)
+ course = Factory.insert(:course, id: tags[:course_id])
user = Factory.insert(:user, %{latest_viewed_course: course})
course_registration =