diff --git a/apps/core/lib/core/clients/hydra.ex b/apps/core/lib/core/clients/hydra.ex index d696a723c..8a20144be 100644 --- a/apps/core/lib/core/clients/hydra.ex +++ b/apps/core/lib/core/clients/hydra.ex @@ -129,7 +129,7 @@ defmodule Core.Clients.Hydra do do: {:ok, Poison.decode!(body, as: type)} defp handle_response(error, _) do Logger.error "Failed to call hydra: #{inspect(error)}" - {:error, :unauthorized} + {:error, hydra_error(error)} end defp user_details(user) do @@ -156,5 +156,9 @@ defmodule Core.Clients.Hydra do defp conf(key), do: Application.get_env(:core, __MODULE__)[key] + defp hydra_error({:error, _}), do: "internal network error" + defp hydra_error({:ok, %HTTPoison.Response{status_code: code, body: body}}), + do: "hydra error: code=#{code}, body=#{body}" + defp headers(), do: [{"accept", "application/json"}, {"content-type", "application/json"}] end diff --git a/apps/core/test/services/cloud/workflow_test.exs b/apps/core/test/services/cloud/workflow_test.exs index 766108830..ee4c898fa 100644 --- a/apps/core/test/services/cloud/workflow_test.exs +++ b/apps/core/test/services/cloud/workflow_test.exs @@ -1,5 +1,5 @@ defmodule Core.Services.Cloud.WorkflowTest do - use Core.SchemaCase, async: true + use Core.SchemaCase, async: false use Mimic alias Core.Clients.Console alias Core.Services.{Cloud, Cloud.Workflow} @@ -28,6 +28,7 @@ defmodule Core.Services.Cloud.WorkflowTest do expect(Req, :post, fn _, [graphql: {_, %{clusterId: ^cluster_id}}] -> {:ok, %Req.Response{status: 200, body: %{"data" => %{"createServiceDeployment" => %{"id" => Ecto.UUID.generate()}}}}} end) + expect(DNS, :resolve, fn _ -> {:ok, ['some-ip']} end) {:ok, %{external_id: svc_id} = instance} = Workflow.provision(instance) diff --git a/apps/core/test/test_helper.exs b/apps/core/test/test_helper.exs index da5d8b514..02bd73c54 100644 --- a/apps/core/test/test_helper.exs +++ b/apps/core/test/test_helper.exs @@ -19,6 +19,7 @@ Mimic.copy(Core.Buffers.TokenAudit) Mimic.copy(Core.Clients.Hydra) Mimic.copy(Cloudflare.DnsRecord) Mimic.copy(Kazan) +Mimic.copy(DNS) Mimic.copy(Goth.Token) Mimic.copy(GoogleApi.CloudBilling.V1.Api.Projects) Mimic.copy(GoogleApi.CloudResourceManager.V3.Api.Projects)