URL encode remote emoji pack names (#362)
[akkoma] / test / pleroma / web / pleroma_api / controllers / emoji_pack_controller_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.PleromaAPI.EmojiPackControllerTest do
6 use Pleroma.Web.ConnCase, async: false
7
8 import Mock
9 import Tesla.Mock
10 import Pleroma.Factory
11
12 @emoji_path Path.join(
13 Pleroma.Config.get!([:instance, :static_dir]),
14 "emoji"
15 )
16
17 setup do: clear_config([:instance, :public], true)
18
19 setup do
20 admin = insert(:user, is_admin: true)
21 token = insert(:oauth_admin_token, user: admin)
22
23 admin_conn =
24 build_conn()
25 |> assign(:user, admin)
26 |> assign(:token, token)
27
28 Pleroma.Emoji.reload()
29 {:ok, %{admin_conn: admin_conn}}
30 end
31
32 test "GET /api/v1/pleroma/emoji/packs when :public: false", %{conn: conn} do
33 clear_config([:instance, :public], false)
34 conn |> get("/api/v1/pleroma/emoji/packs") |> json_response_and_validate_schema(200)
35 end
36
37 test "GET /api/v1/pleroma/emoji/packs", %{conn: conn} do
38 resp =
39 conn
40 |> get("/api/v1/pleroma/emoji/packs")
41 |> json_response_and_validate_schema(200)
42
43 assert resp["count"] == 5
44
45 assert resp["packs"]
46 |> Map.keys()
47 |> length() == 5
48
49 shared = resp["packs"]["test_pack"]
50 assert shared["files"] == %{"blank" => "blank.png", "blank2" => "blank2.png"}
51 assert Map.has_key?(shared["pack"], "download-sha256")
52 assert shared["pack"]["can-download"]
53 assert shared["pack"]["share-files"]
54
55 non_shared = resp["packs"]["test_pack_nonshared"]
56 assert non_shared["pack"]["share-files"] == false
57 assert non_shared["pack"]["can-download"] == false
58
59 resp =
60 conn
61 |> get("/api/v1/pleroma/emoji/packs?page_size=1")
62 |> json_response_and_validate_schema(200)
63
64 assert resp["count"] == 5
65
66 packs = Map.keys(resp["packs"])
67
68 assert length(packs) == 1
69
70 [pack1] = packs
71
72 resp =
73 conn
74 |> get("/api/v1/pleroma/emoji/packs?page_size=1&page=2")
75 |> json_response_and_validate_schema(200)
76
77 assert resp["count"] == 5
78 packs = Map.keys(resp["packs"])
79 assert length(packs) == 1
80 [pack2] = packs
81
82 resp =
83 conn
84 |> get("/api/v1/pleroma/emoji/packs?page_size=1&page=3")
85 |> json_response_and_validate_schema(200)
86
87 assert resp["count"] == 5
88 packs = Map.keys(resp["packs"])
89 assert length(packs) == 1
90 [pack3] = packs
91
92 resp =
93 conn
94 |> get("/api/v1/pleroma/emoji/packs?page_size=1&page=4")
95 |> json_response_and_validate_schema(200)
96
97 assert resp["count"] == 5
98 packs = Map.keys(resp["packs"])
99 assert length(packs) == 1
100 [pack4] = packs
101 assert [pack1, pack2, pack3, pack4] |> Enum.uniq() |> length() == 4
102 end
103
104 describe "GET /api/v1/pleroma/emoji/packs/remote" do
105 test "shareable instance", %{admin_conn: admin_conn, conn: conn} do
106 resp =
107 conn
108 |> get("/api/v1/pleroma/emoji/packs?page=2&page_size=1")
109 |> json_response_and_validate_schema(200)
110
111 mock(fn
112 %{method: :get, url: "https://example.com/.well-known/nodeinfo"} ->
113 json(%{links: [%{href: "https://example.com/nodeinfo/2.1.json"}]})
114
115 %{method: :get, url: "https://example.com/nodeinfo/2.1.json"} ->
116 json(%{metadata: %{features: ["shareable_emoji_packs"]}})
117
118 %{
119 method: :get,
120 url: "https://example.com/api/v1/pleroma/emoji/packs?page=2&page_size=1"
121 } ->
122 json(resp)
123 end)
124
125 assert admin_conn
126 |> get(
127 "/api/v1/pleroma/emoji/packs/remote?url=https://example.com&page=2&page_size=1"
128 )
129 |> json_response_and_validate_schema(200) == resp
130 end
131
132 test "non shareable instance", %{admin_conn: admin_conn} do
133 mock(fn
134 %{method: :get, url: "https://example.com/.well-known/nodeinfo"} ->
135 json(%{links: [%{href: "https://example.com/nodeinfo/2.1.json"}]})
136
137 %{method: :get, url: "https://example.com/nodeinfo/2.1.json"} ->
138 json(%{metadata: %{features: []}})
139 end)
140
141 assert admin_conn
142 |> get("/api/v1/pleroma/emoji/packs/remote?url=https://example.com")
143 |> json_response_and_validate_schema(500) == %{
144 "error" => "The requested instance does not support sharing emoji packs"
145 }
146 end
147 end
148
149 describe "GET /api/v1/pleroma/emoji/packs/archive?name=:name" do
150 test "download shared pack", %{conn: conn} do
151 resp =
152 conn
153 |> get("/api/v1/pleroma/emoji/packs/archive?name=test_pack")
154 |> response(200)
155
156 {:ok, arch} = :zip.unzip(resp, [:memory])
157
158 assert Enum.find(arch, fn {n, _} -> n == 'pack.json' end)
159 assert Enum.find(arch, fn {n, _} -> n == 'blank.png' end)
160 end
161
162 test "non existing pack", %{conn: conn} do
163 assert conn
164 |> get("/api/v1/pleroma/emoji/packs/archive?name=test_pack_for_import")
165 |> json_response_and_validate_schema(:not_found) == %{
166 "error" => "Pack test_pack_for_import does not exist"
167 }
168 end
169
170 test "non downloadable pack", %{conn: conn} do
171 assert conn
172 |> get("/api/v1/pleroma/emoji/packs/archive?name=test_pack_nonshared")
173 |> json_response_and_validate_schema(:forbidden) == %{
174 "error" =>
175 "Pack test_pack_nonshared cannot be downloaded from this instance, either pack sharing was disabled for this pack or some files are missing"
176 }
177 end
178 end
179
180 describe "POST /api/v1/pleroma/emoji/packs/download" do
181 test "shared pack from remote and non shared from fallback-src", %{
182 admin_conn: admin_conn,
183 conn: conn
184 } do
185 mock(fn
186 %{method: :get, url: "https://example.com/.well-known/nodeinfo"} ->
187 json(%{links: [%{href: "https://example.com/nodeinfo/2.1.json"}]})
188
189 %{method: :get, url: "https://example.com/nodeinfo/2.1.json"} ->
190 json(%{metadata: %{features: ["shareable_emoji_packs"]}})
191
192 %{
193 method: :get,
194 url: "https://example.com/api/v1/pleroma/emoji/pack?name=test_pack"
195 } ->
196 conn
197 |> get("/api/v1/pleroma/emoji/pack?name=test_pack")
198 |> json_response_and_validate_schema(200)
199 |> json()
200
201 %{
202 method: :get,
203 url: "https://example.com/api/v1/pleroma/emoji/packs/archive?name=test_pack"
204 } ->
205 conn
206 |> get("/api/v1/pleroma/emoji/packs/archive?name=test_pack")
207 |> response(200)
208 |> text()
209
210 %{
211 method: :get,
212 url: "https://example.com/api/v1/pleroma/emoji/pack?name=test_pack_nonshared"
213 } ->
214 conn
215 |> get("/api/v1/pleroma/emoji/pack?name=test_pack_nonshared")
216 |> json_response_and_validate_schema(200)
217 |> json()
218
219 %{
220 method: :get,
221 url: "https://nonshared-pack"
222 } ->
223 text(File.read!("#{@emoji_path}/test_pack_nonshared/nonshared.zip"))
224
225 %{
226 method: :get,
227 url: "https://example.com/api/v1/pleroma/emoji/pack?name=test%20with%20spaces"
228 } ->
229 conn
230 |> get("/api/v1/pleroma/emoji/pack?name=test%20with%20spaces")
231 |> json_response_and_validate_schema(200)
232 |> json()
233
234 %{
235 method: :get,
236 url: "https://example.com/api/v1/pleroma/emoji/packs/archive?name=test%20with%20spaces"
237 } ->
238 conn
239 |> get("/api/v1/pleroma/emoji/packs/archive?name=test%20with%20spaces")
240 |> response(200)
241 |> text()
242 end)
243
244 assert admin_conn
245 |> put_req_header("content-type", "multipart/form-data")
246 |> post("/api/v1/pleroma/emoji/packs/download", %{
247 url: "https://example.com",
248 name: "test_pack",
249 as: "test_pack2"
250 })
251 |> json_response_and_validate_schema(200) == "ok"
252
253 assert File.exists?("#{@emoji_path}/test_pack2/pack.json")
254 assert File.exists?("#{@emoji_path}/test_pack2/blank.png")
255
256 assert admin_conn
257 |> delete("/api/v1/pleroma/emoji/pack?name=test_pack2")
258 |> json_response_and_validate_schema(200) == "ok"
259
260 refute File.exists?("#{@emoji_path}/test_pack2")
261
262 assert admin_conn
263 |> put_req_header("content-type", "multipart/form-data")
264 |> post(
265 "/api/v1/pleroma/emoji/packs/download",
266 %{
267 url: "https://example.com",
268 name: "test_pack_nonshared",
269 as: "test_pack_nonshared2"
270 }
271 )
272 |> json_response_and_validate_schema(200) == "ok"
273
274 assert File.exists?("#{@emoji_path}/test_pack_nonshared2/pack.json")
275 assert File.exists?("#{@emoji_path}/test_pack_nonshared2/blank.png")
276
277 assert admin_conn
278 |> delete("/api/v1/pleroma/emoji/pack?name=test_pack_nonshared2")
279 |> json_response_and_validate_schema(200) == "ok"
280
281 refute File.exists?("#{@emoji_path}/test_pack_nonshared2")
282
283 assert admin_conn
284 |> put_req_header("content-type", "multipart/form-data")
285 |> post("/api/v1/pleroma/emoji/packs/download", %{
286 url: "https://example.com",
287 name: "test with spaces",
288 as: "test with spaces"
289 })
290 |> json_response_and_validate_schema(200) == "ok"
291
292 assert File.exists?("#{@emoji_path}/test with spaces/pack.json")
293 assert File.exists?("#{@emoji_path}/test with spaces/blank.png")
294 end
295
296 test "nonshareable instance", %{admin_conn: admin_conn} do
297 mock(fn
298 %{method: :get, url: "https://old-instance/.well-known/nodeinfo"} ->
299 json(%{links: [%{href: "https://old-instance/nodeinfo/2.1.json"}]})
300
301 %{method: :get, url: "https://old-instance/nodeinfo/2.1.json"} ->
302 json(%{metadata: %{features: []}})
303 end)
304
305 assert admin_conn
306 |> put_req_header("content-type", "multipart/form-data")
307 |> post(
308 "/api/v1/pleroma/emoji/packs/download",
309 %{
310 url: "https://old-instance",
311 name: "test_pack",
312 as: "test_pack2"
313 }
314 )
315 |> json_response_and_validate_schema(500) == %{
316 "error" => "The requested instance does not support sharing emoji packs"
317 }
318 end
319
320 test "checksum fail", %{admin_conn: admin_conn} do
321 mock(fn
322 %{method: :get, url: "https://example.com/.well-known/nodeinfo"} ->
323 json(%{links: [%{href: "https://example.com/nodeinfo/2.1.json"}]})
324
325 %{method: :get, url: "https://example.com/nodeinfo/2.1.json"} ->
326 json(%{metadata: %{features: ["shareable_emoji_packs"]}})
327
328 %{
329 method: :get,
330 url: "https://example.com/api/v1/pleroma/emoji/pack?name=pack_bad_sha"
331 } ->
332 {:ok, pack} = Pleroma.Emoji.Pack.load_pack("pack_bad_sha")
333 %Tesla.Env{status: 200, body: Jason.encode!(pack)}
334
335 %{
336 method: :get,
337 url: "https://example.com/api/v1/pleroma/emoji/packs/archive?name=pack_bad_sha"
338 } ->
339 %Tesla.Env{
340 status: 200,
341 body: File.read!("test/instance_static/emoji/pack_bad_sha/pack_bad_sha.zip")
342 }
343 end)
344
345 assert admin_conn
346 |> put_req_header("content-type", "multipart/form-data")
347 |> post("/api/v1/pleroma/emoji/packs/download", %{
348 url: "https://example.com",
349 name: "pack_bad_sha",
350 as: "pack_bad_sha2"
351 })
352 |> json_response_and_validate_schema(:internal_server_error) == %{
353 "error" => "SHA256 for the pack doesn't match the one sent by the server"
354 }
355 end
356
357 test "other error", %{admin_conn: admin_conn} do
358 mock(fn
359 %{method: :get, url: "https://example.com/.well-known/nodeinfo"} ->
360 json(%{links: [%{href: "https://example.com/nodeinfo/2.1.json"}]})
361
362 %{method: :get, url: "https://example.com/nodeinfo/2.1.json"} ->
363 json(%{metadata: %{features: ["shareable_emoji_packs"]}})
364
365 %{
366 method: :get,
367 url: "https://example.com/api/v1/pleroma/emoji/pack?name=test_pack"
368 } ->
369 {:ok, pack} = Pleroma.Emoji.Pack.load_pack("test_pack")
370 %Tesla.Env{status: 200, body: Jason.encode!(pack)}
371 end)
372
373 assert admin_conn
374 |> put_req_header("content-type", "multipart/form-data")
375 |> post("/api/v1/pleroma/emoji/packs/download", %{
376 url: "https://example.com",
377 name: "test_pack",
378 as: "test_pack2"
379 })
380 |> json_response_and_validate_schema(:internal_server_error) == %{
381 "error" =>
382 "The pack was not set as shared and there is no fallback src to download from"
383 }
384 end
385 end
386
387 describe "PATCH/update /api/v1/pleroma/emoji/pack?name=:name" do
388 setup do
389 pack_file = "#{@emoji_path}/test_pack/pack.json"
390 original_content = File.read!(pack_file)
391
392 on_exit(fn ->
393 File.write!(pack_file, original_content)
394 end)
395
396 {:ok,
397 pack_file: pack_file,
398 new_data: %{
399 "license" => "Test license changed",
400 "homepage" => "https://pleroma.social",
401 "description" => "Test description",
402 "share-files" => false
403 }}
404 end
405
406 test "returns error when file system not writable", %{admin_conn: conn} = ctx do
407 with_mocks([
408 {File, [:passthrough], [stat: fn _ -> {:error, :eacces} end]}
409 ]) do
410 assert conn
411 |> put_req_header("content-type", "multipart/form-data")
412 |> patch(
413 "/api/v1/pleroma/emoji/pack?name=test_pack",
414 %{"metadata" => ctx[:new_data]}
415 )
416 |> json_response_and_validate_schema(500)
417 end
418 end
419
420 test "for a pack without a fallback source", ctx do
421 assert ctx[:admin_conn]
422 |> put_req_header("content-type", "multipart/form-data")
423 |> patch("/api/v1/pleroma/emoji/pack?name=test_pack", %{
424 "metadata" => ctx[:new_data]
425 })
426 |> json_response_and_validate_schema(200) == ctx[:new_data]
427
428 assert Jason.decode!(File.read!(ctx[:pack_file]))["pack"] == ctx[:new_data]
429 end
430
431 test "for a pack with a fallback source", ctx do
432 mock(fn
433 %{
434 method: :get,
435 url: "https://nonshared-pack"
436 } ->
437 text(File.read!("#{@emoji_path}/test_pack_nonshared/nonshared.zip"))
438 end)
439
440 new_data = Map.put(ctx[:new_data], "fallback-src", "https://nonshared-pack")
441
442 new_data_with_sha =
443 Map.put(
444 new_data,
445 "fallback-src-sha256",
446 "1967BB4E42BCC34BCC12D57BE7811D3B7BE52F965BCE45C87BD377B9499CE11D"
447 )
448
449 assert ctx[:admin_conn]
450 |> put_req_header("content-type", "multipart/form-data")
451 |> patch("/api/v1/pleroma/emoji/pack?name=test_pack", %{metadata: new_data})
452 |> json_response_and_validate_schema(200) == new_data_with_sha
453
454 assert Jason.decode!(File.read!(ctx[:pack_file]))["pack"] == new_data_with_sha
455 end
456
457 test "when the fallback source doesn't have all the files", ctx do
458 mock(fn
459 %{
460 method: :get,
461 url: "https://nonshared-pack"
462 } ->
463 {:ok, {'empty.zip', empty_arch}} = :zip.zip('empty.zip', [], [:memory])
464 text(empty_arch)
465 end)
466
467 new_data = Map.put(ctx[:new_data], "fallback-src", "https://nonshared-pack")
468
469 assert ctx[:admin_conn]
470 |> put_req_header("content-type", "multipart/form-data")
471 |> patch("/api/v1/pleroma/emoji/pack?name=test_pack", %{metadata: new_data})
472 |> json_response_and_validate_schema(:bad_request) == %{
473 "error" => "The fallback archive does not have all files specified in pack.json"
474 }
475 end
476 end
477
478 describe "POST/DELETE /api/v1/pleroma/emoji/pack?name=:name" do
479 test "returns an error on creates pack when file system not writable", %{
480 admin_conn: admin_conn
481 } do
482 path_pack = Path.join(@emoji_path, "test_pack")
483
484 with_mocks([
485 {File, [:passthrough], [mkdir: fn ^path_pack -> {:error, :eacces} end]}
486 ]) do
487 assert admin_conn
488 |> post("/api/v1/pleroma/emoji/pack?name=test_pack")
489 |> json_response_and_validate_schema(500) == %{
490 "error" =>
491 "Unexpected error occurred while creating pack. (POSIX error: Permission denied)"
492 }
493 end
494 end
495
496 test "returns an error on deletes pack when the file system is not writable", %{
497 admin_conn: admin_conn
498 } do
499 path_pack = Path.join(@emoji_path, "test_emoji_pack")
500
501 try do
502 {:ok, _pack} = Pleroma.Emoji.Pack.create("test_emoji_pack")
503
504 with_mocks([
505 {File, [:passthrough], [rm_rf: fn ^path_pack -> {:error, :eacces, path_pack} end]}
506 ]) do
507 assert admin_conn
508 |> delete("/api/v1/pleroma/emoji/pack?name=test_emoji_pack")
509 |> json_response_and_validate_schema(500) == %{
510 "error" =>
511 "Couldn't delete the `test_emoji_pack` pack (POSIX error: Permission denied)"
512 }
513 end
514 after
515 File.rm_rf(path_pack)
516 end
517 end
518
519 test "creating and deleting a pack", %{admin_conn: admin_conn} do
520 assert admin_conn
521 |> post("/api/v1/pleroma/emoji/pack?name=test_created")
522 |> json_response_and_validate_schema(200) == "ok"
523
524 assert File.exists?("#{@emoji_path}/test_created/pack.json")
525
526 assert Jason.decode!(File.read!("#{@emoji_path}/test_created/pack.json")) == %{
527 "pack" => %{},
528 "files" => %{},
529 "files_count" => 0
530 }
531
532 assert admin_conn
533 |> delete("/api/v1/pleroma/emoji/pack?name=test_created")
534 |> json_response_and_validate_schema(200) == "ok"
535
536 refute File.exists?("#{@emoji_path}/test_created/pack.json")
537 end
538
539 test "if pack exists", %{admin_conn: admin_conn} do
540 path = Path.join(@emoji_path, "test_created")
541 File.mkdir(path)
542 pack_file = Jason.encode!(%{files: %{}, pack: %{}})
543 File.write!(Path.join(path, "pack.json"), pack_file)
544
545 assert admin_conn
546 |> post("/api/v1/pleroma/emoji/pack?name=test_created")
547 |> json_response_and_validate_schema(:conflict) == %{
548 "error" => "A pack named \"test_created\" already exists"
549 }
550
551 on_exit(fn -> File.rm_rf(path) end)
552 end
553
554 test "with empty name", %{admin_conn: admin_conn} do
555 assert admin_conn
556 |> post("/api/v1/pleroma/emoji/pack?name= ")
557 |> json_response_and_validate_schema(:bad_request) == %{
558 "error" => "pack name cannot be empty"
559 }
560 end
561 end
562
563 test "deleting nonexisting pack", %{admin_conn: admin_conn} do
564 assert admin_conn
565 |> delete("/api/v1/pleroma/emoji/pack?name=non_existing")
566 |> json_response_and_validate_schema(:not_found) == %{
567 "error" => "Pack non_existing does not exist"
568 }
569 end
570
571 test "deleting with empty name", %{admin_conn: admin_conn} do
572 assert admin_conn
573 |> delete("/api/v1/pleroma/emoji/pack?name= ")
574 |> json_response_and_validate_schema(:bad_request) == %{
575 "error" => "pack name cannot be empty"
576 }
577 end
578
579 test "filesystem import", %{admin_conn: admin_conn, conn: conn} do
580 on_exit(fn ->
581 File.rm!("#{@emoji_path}/test_pack_for_import/emoji.txt")
582 File.rm!("#{@emoji_path}/test_pack_for_import/pack.json")
583 end)
584
585 resp =
586 conn
587 |> get("/api/v1/pleroma/emoji/packs")
588 |> json_response_and_validate_schema(200)
589
590 refute Map.has_key?(resp["packs"], "test_pack_for_import")
591
592 assert admin_conn
593 |> get("/api/v1/pleroma/emoji/packs/import")
594 |> json_response_and_validate_schema(200) == ["test_pack_for_import"]
595
596 resp =
597 conn
598 |> get("/api/v1/pleroma/emoji/packs")
599 |> json_response_and_validate_schema(200)
600
601 assert resp["packs"]["test_pack_for_import"]["files"] == %{"blank" => "blank.png"}
602
603 File.rm!("#{@emoji_path}/test_pack_for_import/pack.json")
604 refute File.exists?("#{@emoji_path}/test_pack_for_import/pack.json")
605
606 emoji_txt_content = """
607 blank, blank.png, Fun
608 blank2, blank.png
609 foo, /emoji/test_pack_for_import/blank.png
610 bar
611 """
612
613 File.write!("#{@emoji_path}/test_pack_for_import/emoji.txt", emoji_txt_content)
614
615 assert admin_conn
616 |> get("/api/v1/pleroma/emoji/packs/import")
617 |> json_response_and_validate_schema(200) == ["test_pack_for_import"]
618
619 resp =
620 conn
621 |> get("/api/v1/pleroma/emoji/packs")
622 |> json_response_and_validate_schema(200)
623
624 assert resp["packs"]["test_pack_for_import"]["files"] == %{
625 "blank" => "blank.png",
626 "blank2" => "blank.png",
627 "foo" => "blank.png"
628 }
629 end
630
631 describe "GET /api/v1/pleroma/emoji/pack?name=:name" do
632 test "shows pack.json", %{conn: conn} do
633 assert %{
634 "files" => files,
635 "files_count" => 2,
636 "pack" => %{
637 "can-download" => true,
638 "description" => "Test description",
639 "download-sha256" => _,
640 "homepage" => "https://pleroma.social",
641 "license" => "Test license",
642 "share-files" => true
643 }
644 } =
645 conn
646 |> get("/api/v1/pleroma/emoji/pack?name=test_pack")
647 |> json_response_and_validate_schema(200)
648
649 assert files == %{"blank" => "blank.png", "blank2" => "blank2.png"}
650
651 assert %{
652 "files" => files,
653 "files_count" => 2
654 } =
655 conn
656 |> get("/api/v1/pleroma/emoji/pack?name=test_pack&page_size=1")
657 |> json_response_and_validate_schema(200)
658
659 assert files |> Map.keys() |> length() == 1
660
661 assert %{
662 "files" => files,
663 "files_count" => 2
664 } =
665 conn
666 |> get("/api/v1/pleroma/emoji/pack?name=test_pack&page_size=1&page=2")
667 |> json_response_and_validate_schema(200)
668
669 assert files |> Map.keys() |> length() == 1
670 end
671
672 test "for pack name with special chars", %{conn: conn} do
673 assert %{
674 "files" => _files,
675 "files_count" => 1,
676 "pack" => %{
677 "can-download" => true,
678 "description" => "Test description",
679 "download-sha256" => _,
680 "homepage" => "https://pleroma.social",
681 "license" => "Test license",
682 "share-files" => true
683 }
684 } =
685 conn
686 |> get("/api/v1/pleroma/emoji/pack?name=blobs.gg")
687 |> json_response_and_validate_schema(200)
688 end
689
690 test "non existing pack", %{conn: conn} do
691 assert conn
692 |> get("/api/v1/pleroma/emoji/pack?name=non_existing")
693 |> json_response_and_validate_schema(:not_found) == %{
694 "error" => "Pack non_existing does not exist"
695 }
696 end
697
698 test "error name", %{conn: conn} do
699 assert conn
700 |> get("/api/v1/pleroma/emoji/pack?name= ")
701 |> json_response_and_validate_schema(:bad_request) == %{
702 "error" => "pack name cannot be empty"
703 }
704 end
705 end
706 end