little fixes and typos fix
authorAlexander <alex.strizhakov@gmail.com>
Wed, 25 Dec 2019 12:31:51 +0000 (15:31 +0300)
committerAlexander Strizhakov <alex.strizhakov@gmail.com>
Fri, 10 Jan 2020 12:52:02 +0000 (15:52 +0300)
config/description.exs
lib/pleroma/web/admin_api/config.ex
test/docs/generator_test.exs
test/web/admin_api/admin_api_controller_test.exs
test/web/admin_api/config_test.exs

index 52f7d2017b5b85d786858f3143111c8959558d0e..a9b2efec544ed58e9df585b661b3a5bfe3a1f5ba 100644 (file)
@@ -101,8 +101,8 @@ config :pleroma, :config_description, [
                       %{
                         key: :versions,
                         type: {:list, :atom},
-                        descriptions: "List of TLS version to use",
-                        suggestions: [:tlsv1, :"tlsv1.1", :"tlsv1.2"]
+                        description: "List of TLS version to use",
+                        suggestions: [:tlsv1, ":tlsv1.1", ":tlsv1.2"]
                       }
                     ]
                   }
@@ -1509,8 +1509,8 @@ config :pleroma, :config_description, [
                       %{
                         key: :versions,
                         type: {:list, :atom},
-                        descriptions: "List of TLS version to use",
-                        suggestions: [:tlsv1, :"tlsv1.1", :"tlsv1.2"]
+                        description: "List of TLS version to use",
+                        suggestions: [:tlsv1, ":tlsv1.1", ":tlsv1.2"]
                       }
                     ]
                   }
@@ -2820,8 +2820,8 @@ config :pleroma, :config_description, [
               %{
                 key: :versions,
                 type: {:list, :atom},
-                descriptions: "List of TLS version to use",
-                suggestions: [:tlsv1, :"tlsv1.1", :"tlsv1.2"]
+                description: "List of TLS version to use",
+                suggestions: [:tlsv1, ":tlsv1.1", ":tlsv1.2"]
               }
             ]
           }
index ef658e0793b120503302fc04a9dfa92010ed2d57..b55851602a05609d946a6418b8db59e5532615e5 100644 (file)
@@ -183,6 +183,11 @@ defmodule Pleroma.Web.AdminAPI.Config do
   defp do_convert(entity) when is_boolean(entity) or is_number(entity) or is_nil(entity),
     do: entity
 
+  defp do_convert(entity)
+       when is_atom(entity) and entity in [:"tlsv1.1", :"tlsv1.2", :"tlsv1.3"] do
+    ":#{to_string(entity)}"
+  end
+
   defp do_convert(entity) when is_atom(entity), do: inspect(entity)
 
   defp do_convert(entity) when is_binary(entity), do: entity
index 0106809c2d9106c275401d35ce13bd4aba946288..9c9f4357b2836a116d84c0d05d528e4aee2484ab 100644 (file)
@@ -85,6 +85,12 @@ defmodule Pleroma.Docs.GeneratorTest do
           key: "application/xml",
           type: {:list, :string},
           suggestions: ["xml"]
+        },
+        %{
+          key: :versions,
+          type: {:list, :atom},
+          description: "List of TLS version to use",
+          suggestions: [:tlsv1, ":tlsv1.1", ":tlsv1.2"]
         }
       ]
     },
@@ -208,6 +214,12 @@ defmodule Pleroma.Docs.GeneratorTest do
       assert child[:key] == "application/xml"
     end
 
+    test "suggestion for tls versions" do
+      [%{children: children} | _] = Generator.convert_to_strings(@descriptions)
+      child = Enum.at(children, 8)
+      assert child[:suggestions] == [":tlsv1", ":tlsv1.1", ":tlsv1.2"]
+    end
+
     test "subgroup with module name" do
       [%{children: children} | _] = Generator.convert_to_strings(@descriptions)
 
index ea3c43158904a4a6d13f6de8f1754f583c4b73e5..d83a95aae8459c03210957e89403fc83dfc45d01 100644 (file)
@@ -2204,6 +2204,47 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
              }
     end
 
+    test "saving special atoms", %{conn: conn} do
+      conn =
+        post(conn, "/api/pleroma/admin/config", %{
+          "configs" => [
+            %{
+              "group" => ":pleroma",
+              "key" => ":key1",
+              "value" => [
+                %{
+                  "tuple" => [
+                    ":ssl_options",
+                    [%{"tuple" => [":versions", [":tlsv1", ":tlsv1.1", ":tlsv1.2"]]}]
+                  ]
+                }
+              ]
+            }
+          ]
+        })
+
+      assert json_response(conn, 200) == %{
+               "configs" => [
+                 %{
+                   "group" => ":pleroma",
+                   "key" => ":key1",
+                   "value" => [
+                     %{
+                       "tuple" => [
+                         ":ssl_options",
+                         [%{"tuple" => [":versions", [":tlsv1", ":tlsv1.1", ":tlsv1.2"]]}]
+                       ]
+                     }
+                   ]
+                 }
+               ]
+             }
+
+      assert Application.get_env(:pleroma, :key1) == [
+               ssl_options: [versions: [:tlsv1, :"tlsv1.1", :"tlsv1.2"]]
+             ]
+    end
+
     test "saving full setting if value is in full_key_update list", %{conn: conn} do
       backends = Application.get_env(:logger, :backends)
       on_exit(fn -> Application.put_env(:logger, :backends, backends) end)
index 4f96322af1834201c53efa65c2f929b08f6070be..cc4c903bf4311c8f297c5586280e97db8b5b23df 100644 (file)
@@ -151,6 +151,12 @@ defmodule Pleroma.Web.AdminAPI.ConfigTest do
       assert Config.from_binary(binary) == :atom
     end
 
+    test "ssl options" do
+      binary = Config.transform([":tlsv1", ":tlsv1.1", ":tlsv1.2"])
+      assert binary == :erlang.term_to_binary([:tlsv1, :"tlsv1.1", :"tlsv1.2"])
+      assert Config.from_binary(binary) == [:tlsv1, :"tlsv1.1", :"tlsv1.2"]
+    end
+
     test "pleroma module" do
       binary = Config.transform("Pleroma.Bookmark")
       assert binary == :erlang.term_to_binary(Pleroma.Bookmark)