From b227cfa8e652132fccce8251b6294084812c1b2e Mon Sep 17 00:00:00 2001 From: Szymon Jednac Date: Thu, 14 Sep 2023 08:11:06 +0200 Subject: [PATCH 1/2] Create the temporary directory before writing the cert file Other tests create expected directory structure in advance (e.g. `File.mkdir_p!("tmp/test_app")`). To prevent execution order issues, create the `tmp` directory here as well. --- test/assent/http_adapter/httpc_test.exs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/assent/http_adapter/httpc_test.exs b/test/assent/http_adapter/httpc_test.exs index c0bd711..56a3203 100644 --- a/test/assent/http_adapter/httpc_test.exs +++ b/test/assent/http_adapter/httpc_test.exs @@ -11,6 +11,7 @@ defmodule Assent.HTTPAdapter.HttpcTest do assert {:ok, %HTTPResponse{status: 200, body: "HTTP/1.1"}} = Httpc.request(:get, TestServer.url(), nil, [], ssl: [cacerts: TestServer.x509_suite().cacerts]) + File.mkdir_p!("tmp") File.write!("tmp/cacerts.pem", :public_key.pem_encode(Enum.map(TestServer.x509_suite().cacerts, &{:Certificate, &1, :not_encrypted}))) TestServer.add("/", via: :get) From 8cc3872049ef6be8c6fb94853c549d8802687b44 Mon Sep 17 00:00:00 2001 From: Dan Schultzer <1254724+danschultzer@users.noreply.github.com> Date: Thu, 14 Sep 2023 06:28:34 -0700 Subject: [PATCH 2/2] Make sure that directory exists or can be created --- test/assent/strategies/oauth2_test.exs | 2 +- test/assent/strategies/oauth_test.exs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/assent/strategies/oauth2_test.exs b/test/assent/strategies/oauth2_test.exs index ccc18ad..0ad5d6b 100644 --- a/test/assent/strategies/oauth2_test.exs +++ b/test/assent/strategies/oauth2_test.exs @@ -308,7 +308,7 @@ defmodule Assent.Strategy.OAuth2Test do end test "with `:private_key_jwt` auth method with private key as file", %{config: config, callback_params: params} do - File.mkdir("tmp/") + File.mkdir_p!("tmp/") File.write!("tmp/private-key.pem", @private_key) config = diff --git a/test/assent/strategies/oauth_test.exs b/test/assent/strategies/oauth_test.exs index e8386a9..85cfc71 100644 --- a/test/assent/strategies/oauth_test.exs +++ b/test/assent/strategies/oauth_test.exs @@ -231,7 +231,7 @@ defmodule Assent.Strategy.OAuthTest do end test "with `:private_key_path` config", %{config: config} do - File.mkdir("tmp/") + File.mkdir_p!("tmp/") File.write!("tmp/private-key.pem", @private_key) config =