Merge branch 'develop' into fix/signup-without-email
[akkoma] / test / config / config_db_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.ConfigDBTest do
6 use Pleroma.DataCase, async: true
7 import Pleroma.Factory
8 alias Pleroma.ConfigDB
9
10 test "get_by_key/1" do
11 config = insert(:config)
12 insert(:config)
13
14 assert config == ConfigDB.get_by_params(%{group: config.group, key: config.key})
15 end
16
17 test "create/1" do
18 {:ok, config} = ConfigDB.create(%{group: ":pleroma", key: ":some_key", value: "some_value"})
19 assert config == ConfigDB.get_by_params(%{group: ":pleroma", key: ":some_key"})
20 end
21
22 test "update/1" do
23 config = insert(:config)
24 {:ok, updated} = ConfigDB.update(config, %{value: "some_value"})
25 loaded = ConfigDB.get_by_params(%{group: config.group, key: config.key})
26 assert loaded == updated
27 end
28
29 test "get_all_as_keyword/0" do
30 saved = insert(:config)
31 insert(:config, group: ":quack", key: ":level", value: ConfigDB.to_binary(:info))
32 insert(:config, group: ":quack", key: ":meta", value: ConfigDB.to_binary([:none]))
33
34 insert(:config,
35 group: ":quack",
36 key: ":webhook_url",
37 value: ConfigDB.to_binary("https://hooks.slack.com/services/KEY/some_val")
38 )
39
40 config = ConfigDB.get_all_as_keyword()
41
42 assert config[:pleroma] == [
43 {ConfigDB.from_string(saved.key), ConfigDB.from_binary(saved.value)}
44 ]
45
46 assert config[:quack] == [
47 level: :info,
48 meta: [:none],
49 webhook_url: "https://hooks.slack.com/services/KEY/some_val"
50 ]
51 end
52
53 describe "update_or_create/1" do
54 test "common" do
55 config = insert(:config)
56 key2 = "another_key"
57
58 params = [
59 %{group: "pleroma", key: key2, value: "another_value"},
60 %{group: config.group, key: config.key, value: "new_value"}
61 ]
62
63 assert Repo.all(ConfigDB) |> length() == 1
64
65 Enum.each(params, &ConfigDB.update_or_create(&1))
66
67 assert Repo.all(ConfigDB) |> length() == 2
68
69 config1 = ConfigDB.get_by_params(%{group: config.group, key: config.key})
70 config2 = ConfigDB.get_by_params(%{group: "pleroma", key: key2})
71
72 assert config1.value == ConfigDB.transform("new_value")
73 assert config2.value == ConfigDB.transform("another_value")
74 end
75
76 test "partial update" do
77 config = insert(:config, value: ConfigDB.to_binary(key1: "val1", key2: :val2))
78
79 {:ok, _config} =
80 ConfigDB.update_or_create(%{
81 group: config.group,
82 key: config.key,
83 value: [key1: :val1, key3: :val3]
84 })
85
86 updated = ConfigDB.get_by_params(%{group: config.group, key: config.key})
87
88 value = ConfigDB.from_binary(updated.value)
89 assert length(value) == 3
90 assert value[:key1] == :val1
91 assert value[:key2] == :val2
92 assert value[:key3] == :val3
93 end
94
95 test "deep merge" do
96 config = insert(:config, value: ConfigDB.to_binary(key1: "val1", key2: [k1: :v1, k2: "v2"]))
97
98 {:ok, config} =
99 ConfigDB.update_or_create(%{
100 group: config.group,
101 key: config.key,
102 value: [key1: :val1, key2: [k2: :v2, k3: :v3], key3: :val3]
103 })
104
105 updated = ConfigDB.get_by_params(%{group: config.group, key: config.key})
106
107 assert config.value == updated.value
108
109 value = ConfigDB.from_binary(updated.value)
110 assert value[:key1] == :val1
111 assert value[:key2] == [k1: :v1, k2: :v2, k3: :v3]
112 assert value[:key3] == :val3
113 end
114
115 test "only full update for some keys" do
116 config1 = insert(:config, key: ":ecto_repos", value: ConfigDB.to_binary(repo: Pleroma.Repo))
117
118 config2 =
119 insert(:config, group: ":cors_plug", key: ":max_age", value: ConfigDB.to_binary(18))
120
121 {:ok, _config} =
122 ConfigDB.update_or_create(%{
123 group: config1.group,
124 key: config1.key,
125 value: [another_repo: [Pleroma.Repo]]
126 })
127
128 {:ok, _config} =
129 ConfigDB.update_or_create(%{
130 group: config2.group,
131 key: config2.key,
132 value: 777
133 })
134
135 updated1 = ConfigDB.get_by_params(%{group: config1.group, key: config1.key})
136 updated2 = ConfigDB.get_by_params(%{group: config2.group, key: config2.key})
137
138 assert ConfigDB.from_binary(updated1.value) == [another_repo: [Pleroma.Repo]]
139 assert ConfigDB.from_binary(updated2.value) == 777
140 end
141
142 test "full update if value is not keyword" do
143 config =
144 insert(:config,
145 group: ":tesla",
146 key: ":adapter",
147 value: ConfigDB.to_binary(Tesla.Adapter.Hackney)
148 )
149
150 {:ok, _config} =
151 ConfigDB.update_or_create(%{
152 group: config.group,
153 key: config.key,
154 value: Tesla.Adapter.Httpc
155 })
156
157 updated = ConfigDB.get_by_params(%{group: config.group, key: config.key})
158
159 assert ConfigDB.from_binary(updated.value) == Tesla.Adapter.Httpc
160 end
161
162 test "only full update for some subkeys" do
163 config1 =
164 insert(:config,
165 key: ":emoji",
166 value: ConfigDB.to_binary(groups: [a: 1, b: 2], key: [a: 1])
167 )
168
169 config2 =
170 insert(:config,
171 key: ":assets",
172 value: ConfigDB.to_binary(mascots: [a: 1, b: 2], key: [a: 1])
173 )
174
175 {:ok, _config} =
176 ConfigDB.update_or_create(%{
177 group: config1.group,
178 key: config1.key,
179 value: [groups: [c: 3, d: 4], key: [b: 2]]
180 })
181
182 {:ok, _config} =
183 ConfigDB.update_or_create(%{
184 group: config2.group,
185 key: config2.key,
186 value: [mascots: [c: 3, d: 4], key: [b: 2]]
187 })
188
189 updated1 = ConfigDB.get_by_params(%{group: config1.group, key: config1.key})
190 updated2 = ConfigDB.get_by_params(%{group: config2.group, key: config2.key})
191
192 assert ConfigDB.from_binary(updated1.value) == [groups: [c: 3, d: 4], key: [a: 1, b: 2]]
193 assert ConfigDB.from_binary(updated2.value) == [mascots: [c: 3, d: 4], key: [a: 1, b: 2]]
194 end
195 end
196
197 describe "delete/1" do
198 test "error on deleting non existing setting" do
199 {:error, error} = ConfigDB.delete(%{group: ":pleroma", key: ":key"})
200 assert error =~ "Config with params %{group: \":pleroma\", key: \":key\"} not found"
201 end
202
203 test "full delete" do
204 config = insert(:config)
205 {:ok, deleted} = ConfigDB.delete(%{group: config.group, key: config.key})
206 assert Ecto.get_meta(deleted, :state) == :deleted
207 refute ConfigDB.get_by_params(%{group: config.group, key: config.key})
208 end
209
210 test "partial subkeys delete" do
211 config = insert(:config, value: ConfigDB.to_binary(groups: [a: 1, b: 2], key: [a: 1]))
212
213 {:ok, deleted} =
214 ConfigDB.delete(%{group: config.group, key: config.key, subkeys: [":groups"]})
215
216 assert Ecto.get_meta(deleted, :state) == :loaded
217
218 assert deleted.value == ConfigDB.to_binary(key: [a: 1])
219
220 updated = ConfigDB.get_by_params(%{group: config.group, key: config.key})
221
222 assert updated.value == deleted.value
223 end
224
225 test "full delete if remaining value after subkeys deletion is empty list" do
226 config = insert(:config, value: ConfigDB.to_binary(groups: [a: 1, b: 2]))
227
228 {:ok, deleted} =
229 ConfigDB.delete(%{group: config.group, key: config.key, subkeys: [":groups"]})
230
231 assert Ecto.get_meta(deleted, :state) == :deleted
232
233 refute ConfigDB.get_by_params(%{group: config.group, key: config.key})
234 end
235 end
236
237 describe "transform/1" do
238 test "string" do
239 binary = ConfigDB.transform("value as string")
240 assert binary == :erlang.term_to_binary("value as string")
241 assert ConfigDB.from_binary(binary) == "value as string"
242 end
243
244 test "boolean" do
245 binary = ConfigDB.transform(false)
246 assert binary == :erlang.term_to_binary(false)
247 assert ConfigDB.from_binary(binary) == false
248 end
249
250 test "nil" do
251 binary = ConfigDB.transform(nil)
252 assert binary == :erlang.term_to_binary(nil)
253 assert ConfigDB.from_binary(binary) == nil
254 end
255
256 test "integer" do
257 binary = ConfigDB.transform(150)
258 assert binary == :erlang.term_to_binary(150)
259 assert ConfigDB.from_binary(binary) == 150
260 end
261
262 test "atom" do
263 binary = ConfigDB.transform(":atom")
264 assert binary == :erlang.term_to_binary(:atom)
265 assert ConfigDB.from_binary(binary) == :atom
266 end
267
268 test "ssl options" do
269 binary = ConfigDB.transform([":tlsv1", ":tlsv1.1", ":tlsv1.2"])
270 assert binary == :erlang.term_to_binary([:tlsv1, :"tlsv1.1", :"tlsv1.2"])
271 assert ConfigDB.from_binary(binary) == [:tlsv1, :"tlsv1.1", :"tlsv1.2"]
272 end
273
274 test "pleroma module" do
275 binary = ConfigDB.transform("Pleroma.Bookmark")
276 assert binary == :erlang.term_to_binary(Pleroma.Bookmark)
277 assert ConfigDB.from_binary(binary) == Pleroma.Bookmark
278 end
279
280 test "pleroma string" do
281 binary = ConfigDB.transform("Pleroma")
282 assert binary == :erlang.term_to_binary("Pleroma")
283 assert ConfigDB.from_binary(binary) == "Pleroma"
284 end
285
286 test "phoenix module" do
287 binary = ConfigDB.transform("Phoenix.Socket.V1.JSONSerializer")
288 assert binary == :erlang.term_to_binary(Phoenix.Socket.V1.JSONSerializer)
289 assert ConfigDB.from_binary(binary) == Phoenix.Socket.V1.JSONSerializer
290 end
291
292 test "tesla module" do
293 binary = ConfigDB.transform("Tesla.Adapter.Hackney")
294 assert binary == :erlang.term_to_binary(Tesla.Adapter.Hackney)
295 assert ConfigDB.from_binary(binary) == Tesla.Adapter.Hackney
296 end
297
298 test "ExSyslogger module" do
299 binary = ConfigDB.transform("ExSyslogger")
300 assert binary == :erlang.term_to_binary(ExSyslogger)
301 assert ConfigDB.from_binary(binary) == ExSyslogger
302 end
303
304 test "Quack.Logger module" do
305 binary = ConfigDB.transform("Quack.Logger")
306 assert binary == :erlang.term_to_binary(Quack.Logger)
307 assert ConfigDB.from_binary(binary) == Quack.Logger
308 end
309
310 test "Swoosh.Adapters modules" do
311 binary = ConfigDB.transform("Swoosh.Adapters.SMTP")
312 assert binary == :erlang.term_to_binary(Swoosh.Adapters.SMTP)
313 assert ConfigDB.from_binary(binary) == Swoosh.Adapters.SMTP
314 binary = ConfigDB.transform("Swoosh.Adapters.AmazonSES")
315 assert binary == :erlang.term_to_binary(Swoosh.Adapters.AmazonSES)
316 assert ConfigDB.from_binary(binary) == Swoosh.Adapters.AmazonSES
317 end
318
319 test "sigil" do
320 binary = ConfigDB.transform("~r[comp[lL][aA][iI][nN]er]")
321 assert binary == :erlang.term_to_binary(~r/comp[lL][aA][iI][nN]er/)
322 assert ConfigDB.from_binary(binary) == ~r/comp[lL][aA][iI][nN]er/
323 end
324
325 test "link sigil" do
326 binary = ConfigDB.transform("~r/https:\/\/example.com/")
327 assert binary == :erlang.term_to_binary(~r/https:\/\/example.com/)
328 assert ConfigDB.from_binary(binary) == ~r/https:\/\/example.com/
329 end
330
331 test "link sigil with um modifiers" do
332 binary = ConfigDB.transform("~r/https:\/\/example.com/um")
333 assert binary == :erlang.term_to_binary(~r/https:\/\/example.com/um)
334 assert ConfigDB.from_binary(binary) == ~r/https:\/\/example.com/um
335 end
336
337 test "link sigil with i modifier" do
338 binary = ConfigDB.transform("~r/https:\/\/example.com/i")
339 assert binary == :erlang.term_to_binary(~r/https:\/\/example.com/i)
340 assert ConfigDB.from_binary(binary) == ~r/https:\/\/example.com/i
341 end
342
343 test "link sigil with s modifier" do
344 binary = ConfigDB.transform("~r/https:\/\/example.com/s")
345 assert binary == :erlang.term_to_binary(~r/https:\/\/example.com/s)
346 assert ConfigDB.from_binary(binary) == ~r/https:\/\/example.com/s
347 end
348
349 test "raise if valid delimiter not found" do
350 assert_raise ArgumentError, "valid delimiter for Regex expression not found", fn ->
351 ConfigDB.transform("~r/https://[]{}<>\"'()|example.com/s")
352 end
353 end
354
355 test "2 child tuple" do
356 binary = ConfigDB.transform(%{"tuple" => ["v1", ":v2"]})
357 assert binary == :erlang.term_to_binary({"v1", :v2})
358 assert ConfigDB.from_binary(binary) == {"v1", :v2}
359 end
360
361 test "proxy tuple with localhost" do
362 binary =
363 ConfigDB.transform(%{
364 "tuple" => [":proxy_url", %{"tuple" => [":socks5", "localhost", 1234]}]
365 })
366
367 assert binary == :erlang.term_to_binary({:proxy_url, {:socks5, :localhost, 1234}})
368 assert ConfigDB.from_binary(binary) == {:proxy_url, {:socks5, :localhost, 1234}}
369 end
370
371 test "proxy tuple with domain" do
372 binary =
373 ConfigDB.transform(%{
374 "tuple" => [":proxy_url", %{"tuple" => [":socks5", "domain.com", 1234]}]
375 })
376
377 assert binary == :erlang.term_to_binary({:proxy_url, {:socks5, 'domain.com', 1234}})
378 assert ConfigDB.from_binary(binary) == {:proxy_url, {:socks5, 'domain.com', 1234}}
379 end
380
381 test "proxy tuple with ip" do
382 binary =
383 ConfigDB.transform(%{
384 "tuple" => [":proxy_url", %{"tuple" => [":socks5", "127.0.0.1", 1234]}]
385 })
386
387 assert binary == :erlang.term_to_binary({:proxy_url, {:socks5, {127, 0, 0, 1}, 1234}})
388 assert ConfigDB.from_binary(binary) == {:proxy_url, {:socks5, {127, 0, 0, 1}, 1234}}
389 end
390
391 test "tuple with n childs" do
392 binary =
393 ConfigDB.transform(%{
394 "tuple" => [
395 "v1",
396 ":v2",
397 "Pleroma.Bookmark",
398 150,
399 false,
400 "Phoenix.Socket.V1.JSONSerializer"
401 ]
402 })
403
404 assert binary ==
405 :erlang.term_to_binary(
406 {"v1", :v2, Pleroma.Bookmark, 150, false, Phoenix.Socket.V1.JSONSerializer}
407 )
408
409 assert ConfigDB.from_binary(binary) ==
410 {"v1", :v2, Pleroma.Bookmark, 150, false, Phoenix.Socket.V1.JSONSerializer}
411 end
412
413 test "map with string key" do
414 binary = ConfigDB.transform(%{"key" => "value"})
415 assert binary == :erlang.term_to_binary(%{"key" => "value"})
416 assert ConfigDB.from_binary(binary) == %{"key" => "value"}
417 end
418
419 test "map with atom key" do
420 binary = ConfigDB.transform(%{":key" => "value"})
421 assert binary == :erlang.term_to_binary(%{key: "value"})
422 assert ConfigDB.from_binary(binary) == %{key: "value"}
423 end
424
425 test "list of strings" do
426 binary = ConfigDB.transform(["v1", "v2", "v3"])
427 assert binary == :erlang.term_to_binary(["v1", "v2", "v3"])
428 assert ConfigDB.from_binary(binary) == ["v1", "v2", "v3"]
429 end
430
431 test "list of modules" do
432 binary = ConfigDB.transform(["Pleroma.Repo", "Pleroma.Activity"])
433 assert binary == :erlang.term_to_binary([Pleroma.Repo, Pleroma.Activity])
434 assert ConfigDB.from_binary(binary) == [Pleroma.Repo, Pleroma.Activity]
435 end
436
437 test "list of atoms" do
438 binary = ConfigDB.transform([":v1", ":v2", ":v3"])
439 assert binary == :erlang.term_to_binary([:v1, :v2, :v3])
440 assert ConfigDB.from_binary(binary) == [:v1, :v2, :v3]
441 end
442
443 test "list of mixed values" do
444 binary =
445 ConfigDB.transform([
446 "v1",
447 ":v2",
448 "Pleroma.Repo",
449 "Phoenix.Socket.V1.JSONSerializer",
450 15,
451 false
452 ])
453
454 assert binary ==
455 :erlang.term_to_binary([
456 "v1",
457 :v2,
458 Pleroma.Repo,
459 Phoenix.Socket.V1.JSONSerializer,
460 15,
461 false
462 ])
463
464 assert ConfigDB.from_binary(binary) == [
465 "v1",
466 :v2,
467 Pleroma.Repo,
468 Phoenix.Socket.V1.JSONSerializer,
469 15,
470 false
471 ]
472 end
473
474 test "simple keyword" do
475 binary = ConfigDB.transform([%{"tuple" => [":key", "value"]}])
476 assert binary == :erlang.term_to_binary([{:key, "value"}])
477 assert ConfigDB.from_binary(binary) == [{:key, "value"}]
478 assert ConfigDB.from_binary(binary) == [key: "value"]
479 end
480
481 test "keyword with partial_chain key" do
482 binary =
483 ConfigDB.transform([%{"tuple" => [":partial_chain", "&:hackney_connect.partial_chain/1"]}])
484
485 assert binary == :erlang.term_to_binary(partial_chain: &:hackney_connect.partial_chain/1)
486 assert ConfigDB.from_binary(binary) == [partial_chain: &:hackney_connect.partial_chain/1]
487 end
488
489 test "keyword" do
490 binary =
491 ConfigDB.transform([
492 %{"tuple" => [":types", "Pleroma.PostgresTypes"]},
493 %{"tuple" => [":telemetry_event", ["Pleroma.Repo.Instrumenter"]]},
494 %{"tuple" => [":migration_lock", nil]},
495 %{"tuple" => [":key1", 150]},
496 %{"tuple" => [":key2", "string"]}
497 ])
498
499 assert binary ==
500 :erlang.term_to_binary(
501 types: Pleroma.PostgresTypes,
502 telemetry_event: [Pleroma.Repo.Instrumenter],
503 migration_lock: nil,
504 key1: 150,
505 key2: "string"
506 )
507
508 assert ConfigDB.from_binary(binary) == [
509 types: Pleroma.PostgresTypes,
510 telemetry_event: [Pleroma.Repo.Instrumenter],
511 migration_lock: nil,
512 key1: 150,
513 key2: "string"
514 ]
515 end
516
517 test "complex keyword with nested mixed childs" do
518 binary =
519 ConfigDB.transform([
520 %{"tuple" => [":uploader", "Pleroma.Uploaders.Local"]},
521 %{"tuple" => [":filters", ["Pleroma.Upload.Filter.Dedupe"]]},
522 %{"tuple" => [":link_name", true]},
523 %{"tuple" => [":proxy_remote", false]},
524 %{"tuple" => [":common_map", %{":key" => "value"}]},
525 %{
526 "tuple" => [
527 ":proxy_opts",
528 [
529 %{"tuple" => [":redirect_on_failure", false]},
530 %{"tuple" => [":max_body_length", 1_048_576]},
531 %{
532 "tuple" => [
533 ":http",
534 [%{"tuple" => [":follow_redirect", true]}, %{"tuple" => [":pool", ":upload"]}]
535 ]
536 }
537 ]
538 ]
539 }
540 ])
541
542 assert binary ==
543 :erlang.term_to_binary(
544 uploader: Pleroma.Uploaders.Local,
545 filters: [Pleroma.Upload.Filter.Dedupe],
546 link_name: true,
547 proxy_remote: false,
548 common_map: %{key: "value"},
549 proxy_opts: [
550 redirect_on_failure: false,
551 max_body_length: 1_048_576,
552 http: [
553 follow_redirect: true,
554 pool: :upload
555 ]
556 ]
557 )
558
559 assert ConfigDB.from_binary(binary) ==
560 [
561 uploader: Pleroma.Uploaders.Local,
562 filters: [Pleroma.Upload.Filter.Dedupe],
563 link_name: true,
564 proxy_remote: false,
565 common_map: %{key: "value"},
566 proxy_opts: [
567 redirect_on_failure: false,
568 max_body_length: 1_048_576,
569 http: [
570 follow_redirect: true,
571 pool: :upload
572 ]
573 ]
574 ]
575 end
576
577 test "common keyword" do
578 binary =
579 ConfigDB.transform([
580 %{"tuple" => [":level", ":warn"]},
581 %{"tuple" => [":meta", [":all"]]},
582 %{"tuple" => [":path", ""]},
583 %{"tuple" => [":val", nil]},
584 %{"tuple" => [":webhook_url", "https://hooks.slack.com/services/YOUR-KEY-HERE"]}
585 ])
586
587 assert binary ==
588 :erlang.term_to_binary(
589 level: :warn,
590 meta: [:all],
591 path: "",
592 val: nil,
593 webhook_url: "https://hooks.slack.com/services/YOUR-KEY-HERE"
594 )
595
596 assert ConfigDB.from_binary(binary) == [
597 level: :warn,
598 meta: [:all],
599 path: "",
600 val: nil,
601 webhook_url: "https://hooks.slack.com/services/YOUR-KEY-HERE"
602 ]
603 end
604
605 test "complex keyword with sigil" do
606 binary =
607 ConfigDB.transform([
608 %{"tuple" => [":federated_timeline_removal", []]},
609 %{"tuple" => [":reject", ["~r/comp[lL][aA][iI][nN]er/"]]},
610 %{"tuple" => [":replace", []]}
611 ])
612
613 assert binary ==
614 :erlang.term_to_binary(
615 federated_timeline_removal: [],
616 reject: [~r/comp[lL][aA][iI][nN]er/],
617 replace: []
618 )
619
620 assert ConfigDB.from_binary(binary) ==
621 [federated_timeline_removal: [], reject: [~r/comp[lL][aA][iI][nN]er/], replace: []]
622 end
623
624 test "complex keyword with tuples with more than 2 values" do
625 binary =
626 ConfigDB.transform([
627 %{
628 "tuple" => [
629 ":http",
630 [
631 %{
632 "tuple" => [
633 ":key1",
634 [
635 %{
636 "tuple" => [
637 ":_",
638 [
639 %{
640 "tuple" => [
641 "/api/v1/streaming",
642 "Pleroma.Web.MastodonAPI.WebsocketHandler",
643 []
644 ]
645 },
646 %{
647 "tuple" => [
648 "/websocket",
649 "Phoenix.Endpoint.CowboyWebSocket",
650 %{
651 "tuple" => [
652 "Phoenix.Transports.WebSocket",
653 %{
654 "tuple" => [
655 "Pleroma.Web.Endpoint",
656 "Pleroma.Web.UserSocket",
657 []
658 ]
659 }
660 ]
661 }
662 ]
663 },
664 %{
665 "tuple" => [
666 ":_",
667 "Phoenix.Endpoint.Cowboy2Handler",
668 %{"tuple" => ["Pleroma.Web.Endpoint", []]}
669 ]
670 }
671 ]
672 ]
673 }
674 ]
675 ]
676 }
677 ]
678 ]
679 }
680 ])
681
682 assert binary ==
683 :erlang.term_to_binary(
684 http: [
685 key1: [
686 _: [
687 {"/api/v1/streaming", Pleroma.Web.MastodonAPI.WebsocketHandler, []},
688 {"/websocket", Phoenix.Endpoint.CowboyWebSocket,
689 {Phoenix.Transports.WebSocket,
690 {Pleroma.Web.Endpoint, Pleroma.Web.UserSocket, []}}},
691 {:_, Phoenix.Endpoint.Cowboy2Handler, {Pleroma.Web.Endpoint, []}}
692 ]
693 ]
694 ]
695 )
696
697 assert ConfigDB.from_binary(binary) == [
698 http: [
699 key1: [
700 {:_,
701 [
702 {"/api/v1/streaming", Pleroma.Web.MastodonAPI.WebsocketHandler, []},
703 {"/websocket", Phoenix.Endpoint.CowboyWebSocket,
704 {Phoenix.Transports.WebSocket,
705 {Pleroma.Web.Endpoint, Pleroma.Web.UserSocket, []}}},
706 {:_, Phoenix.Endpoint.Cowboy2Handler, {Pleroma.Web.Endpoint, []}}
707 ]}
708 ]
709 ]
710 ]
711 end
712 end
713 end