Skip to content

Commit

Permalink
fix: all configs with password field should respond with REDACTED
Browse files Browse the repository at this point in the history
… value
  • Loading branch information
chasers committed Oct 29, 2024
1 parent 064837a commit 31cd82f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.9.1
1.9.2
2 changes: 1 addition & 1 deletion lib/logflare/backends/backend.ex
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ defmodule Logflare.Backends.Backend do
config when type == :datadog ->
Map.put(config, :api_key, "REDACTED")

%{password: pass} = config when pass != nil and type == :elastic ->
%{password: pass} = config when pass != nil ->
Map.put(config, :password, "REDACTED")

cfg ->
Expand Down
30 changes: 30 additions & 0 deletions test/logflare_web/controllers/api/backend_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,36 @@ defmodule LogflareWeb.Api.BackendControllerTest do
} = json_response(conn, 201)
end

test "creates a loki backend for an authenticated user", %{conn: conn, user: user} do
name = TestUtils.random_string()

conn =
conn
|> add_access_token(user, "private")
|> post("/api/backends", %{
name: name,
type: "loki",
config: %{url: "https://example.com", username: "someuser", password: "12345"},
metadata: %{
some: "data"
}
})

assert %{
"id" => _,
"token" => _,
"name" => ^name,
"config" => %{
"url" => "https://" <> _,
"password" => "REDACTED",
"username" => "someuser"
},
"metadata" => %{
"some" => "data"
}
} = json_response(conn, 201)
end

test "returns 422 on missing arguments", %{conn: conn, user: user} do
resp =
conn
Expand Down

0 comments on commit 31cd82f

Please sign in to comment.