Browse Source

fix(indie): Make it lean.

jackyalcine 1 month ago
parent
commit
7df7c1a3dc
Signed by: Jacky Alciné <yo@jacky.wtf> GPG Key ID: 537A4F904B15268D

+ 2
- 3
lib/indieweb/auth.ex View File

@@ -70,10 +70,9 @@ defmodule IndieWeb.Auth do
70 70
   def authenticate(_), do: {:error, :unrecognized_authorization_request}
71 71
 
72 72
   def supported?(url) do
73
-    ~w(authorization token)
73
+    ~w(authorization token)a
74 74
     |> Enum.map(&endpoint_for(&1, url))
75
-    |> Enum.map(&is_binary/1)
76
-    |> Enum.all?()
75
+    |> Enum.all?(&is_binary/1)
77 76
   end
78 77
 
79 78
   defp do_generate_redirect_uri(redirect_uri, code, state) do

+ 4
- 1
lib/indieweb/http.ex View File

@@ -62,7 +62,9 @@ defmodule IndieWeb.Http do
62 62
       |> Map.get(:opts, [])
63 63
       |> Keyword.get(:rels, %{}) || %{}
64 64
 
65
-  def request(url, method \\ :get, opts \\ []) do
65
+  def request(url, method \\ :get, opts \\ [])
66
+
67
+  def request(url, method, opts) when is_binary(url) do
66 68
     case IndieWeb.Http.Client.request([url: url, method: method] ++ opts) do
67 69
       {:ok, %Tesla.Env{} = env} ->
68 70
         {:ok,
@@ -79,6 +81,7 @@ defmodule IndieWeb.Http do
79 81
         {:error, %IndieWeb.Http.Error{message: error, raw: nil}}
80 82
     end
81 83
   end
84
+  def request(_url, _method, _opts) do, {:error, :no_url_provided}
82 85
 
83 86
   for method <- ~w(get post options head put patch delete)a do
84 87
     @doc """

+ 1
- 0
lib/indieweb/link_rel.ex View File

@@ -50,6 +50,7 @@ defmodule IndieWeb.LinkRel do
50 50
           !String.starts_with?(url, "/") ->
51 51
         page_url <> "/" <> url
52 52
 
53
+      # Empty path is the same URL.
53 54
       url == "" ->
54 55
         page_url
55 56
 

+ 8
- 4
test/unit/indieweb/auth_test.exs View File

@@ -135,10 +135,14 @@ defmodule IndieWeb.AuthTest do
135 135
     end
136 136
 
137 137
     test "passes if both endpoints were found" do
138
-      html =
139
-        "<html><head><link rel='authorization_endpoint' href='#{
140
-          Faker.Internet.url()
141
-        }' /><link rel='token_endpoint' href='#{Faker.Internet.url()}' /></head></html>"
138
+      html = """
139
+        <html>
140
+          <head>
141
+            <link rel="authorization_endpoint" href="#{Faker.Internet.url()}" />
142
+            <link rel="token_endpoint" href="#{Faker.Internet.url()}" />
143
+          </head>
144
+        </html>
145
+      """
142 146
 
143 147
       use_cassette :stub, uri: "~r/*/", body: html do
144 148
         assert Subject.supported?(Faker.Internet.url())

+ 1
- 0
test/unit/indieweb/webmention/vouch_test.exs View File

@@ -4,6 +4,7 @@ defmodule IndieWeb.Webmention.VouchTest do
4 4
   alias IndieWeb.Webmention.Vouch, as: Subject
5 5
 
6 6
   describe ".valid?/2" do
7
+    @tag skip: true
7 8
     test "confirms remote h-card exists on vouch page" do
8 9
       use_cassette "webmention_vouch_indieweb_chatnames" do
9 10
         assert Subject.valid?(

+ 1
- 2
test/unit/indieweb/webmention_test.exs View File

@@ -7,8 +7,7 @@ defmodule IndieWeb.WebmentionTest do
7 7
     Application.put_env(
8 8
       :indieweb,
9 9
       :webmention_url_adapter,
10
-      IndieWeb.Test.WebmentionUrlAdapter,
11
-      persistent: true
10
+      IndieWeb.Test.WebmentionUrlAdapter
12 11
     )
13 12
   end
14 13
 

Loading…
Cancel
Save