Cookie auth (#116)
* Added new extras directory * Automatically create cookie file on boot * Added cookie file option to DL option builder * Put cookie auth in correct spot * Updated Docs * Removed useless setter for config path
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
defmodule Pinchflat.Downloading.DownloadOptionBuilderTest do
|
||||
use Pinchflat.DataCase
|
||||
import Pinchflat.MediaFixtures
|
||||
import Pinchflat.ProfilesFixtures
|
||||
import Pinchflat.SourcesFixtures
|
||||
import Pinchflat.ProfilesFixtures
|
||||
|
||||
alias Pinchflat.Profiles
|
||||
alias Pinchflat.Downloading.DownloadOptionBuilder
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
defmodule Pinchflat.YtDlp.CommandRunnerTest do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
alias Pinchflat.Filesystem.FilesystemHelpers
|
||||
|
||||
alias Pinchflat.YtDlp.CommandRunner, as: Runner
|
||||
|
||||
@original_executable Application.compile_env(:pinchflat, :yt_dlp_executable)
|
||||
@@ -65,6 +67,41 @@ defmodule Pinchflat.YtDlp.CommandRunnerTest do
|
||||
end
|
||||
end
|
||||
|
||||
describe "run/4 when testing cookie options" do
|
||||
setup do
|
||||
base_dir = Application.get_env(:pinchflat, :extras_directory)
|
||||
cookie_file = Path.join(base_dir, "cookies.txt")
|
||||
|
||||
{:ok, cookie_file: cookie_file}
|
||||
end
|
||||
|
||||
test "includes cookie options when cookies.txt exists", %{cookie_file: cookie_file} do
|
||||
FilesystemHelpers.write_p!(cookie_file, "cookie data")
|
||||
|
||||
assert {:ok, output} = Runner.run(@media_url, [], "")
|
||||
|
||||
assert String.contains?(output, "--cookies #{cookie_file}")
|
||||
end
|
||||
|
||||
test "doesn't include cookie options when cookies.txt blank", %{cookie_file: cookie_file} do
|
||||
FilesystemHelpers.write_p!(cookie_file, " \n \n ")
|
||||
|
||||
assert {:ok, output} = Runner.run(@media_url, [], "")
|
||||
|
||||
refute String.contains?(output, "--cookies")
|
||||
refute String.contains?(output, cookie_file)
|
||||
end
|
||||
|
||||
test "doesn't include cookie options when cookies.txt doesn't exist", %{cookie_file: cookie_file} do
|
||||
File.rm(cookie_file)
|
||||
|
||||
assert {:ok, output} = Runner.run(@media_url, [], "")
|
||||
|
||||
refute String.contains?(output, "--cookies")
|
||||
refute String.contains?(output, cookie_file)
|
||||
end
|
||||
end
|
||||
|
||||
defp wrap_executable(new_executable, fun) do
|
||||
Application.put_env(:pinchflat, :yt_dlp_executable, new_executable)
|
||||
fun.()
|
||||
|
||||
@@ -11,9 +11,11 @@ Faker.start()
|
||||
ExUnit.after_suite(fn _ ->
|
||||
File.rm_rf!(Application.get_env(:pinchflat, :media_directory))
|
||||
File.rm_rf!(Application.get_env(:pinchflat, :metadata_directory))
|
||||
File.rm_rf!(Application.get_env(:pinchflat, :extras_directory))
|
||||
File.rm_rf!(Application.get_env(:pinchflat, :tmpfile_directory))
|
||||
|
||||
File.mkdir_p!(Application.get_env(:pinchflat, :media_directory))
|
||||
File.mkdir_p!(Application.get_env(:pinchflat, :metadata_directory))
|
||||
File.mkdir_p!(Application.get_env(:pinchflat, :extras_directory))
|
||||
File.mkdir_p!(Application.get_env(:pinchflat, :tmpfile_directory))
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user