Skip to content

Commit

Permalink
chore: redact auth token and response value changes (momentohq#39)
Browse files Browse the repository at this point in the history
Redact the auth token in the inspect methods for scs_data_client and
scs_control_client.

Change the get-scores hit response containing the values from 'values'
to 'value'.
  • Loading branch information
nand4011 authored Jun 21, 2023
1 parent c2624f2 commit a652f2d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/integration-test/momento/cache_client_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1008,15 +1008,15 @@ defmodule CacheClientTest do
"key99"
])

assert [{"key1", 1.0}, {"key99", nil}] = response.values
assert [{"key1", 1.0}, {"key99", nil}] = response.value

{:ok, response} =
CacheClient.sorted_set_get_scores(cache_client, cache_name, sorted_set_name, [
"key98",
"key99"
])

assert [{"key98", nil}, {"key99", nil}] = response.values
assert [{"key98", nil}, {"key99", nil}] = response.value
end

test "should fail if the cache name is invalid", %{
Expand Down
6 changes: 6 additions & 0 deletions src/lib/momento/internal/scs_control_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ defmodule Momento.Internal.ScsControlClient do
channel: GRPC.Channel.t()
}

defimpl Inspect, for: Momento.Internal.ScsControlClient do
def inspect(%Momento.Internal.ScsControlClient{} = control_client, _opts) do
"#Momento.Internal.ScsControlClient<auth_token: [hidden], channel: #{inspect(control_client.channel)}>"
end
end

@spec create!(CredentialProvider.t()) :: t()
def create!(credential_provider) do
control_endpoint = CredentialProvider.control_endpoint(credential_provider)
Expand Down
10 changes: 8 additions & 2 deletions src/lib/momento/internal/scs_data_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ defmodule Momento.Internal.ScsDataClient do
channel: GRPC.Channel.t()
}

defimpl Inspect, for: Momento.Internal.ScsDataClient do
def inspect(%Momento.Internal.ScsDataClient{} = data_client, _opts) do
"#Momento.Internal.ScsDataClient<auth_token: [hidden], channel: #{inspect(data_client.channel)}>"
end
end

@spec create!(CredentialProvider.t()) :: t()
def create!(credential_provider) do
cache_endpoint = CredentialProvider.cache_endpoint(credential_provider)
Expand Down Expand Up @@ -588,7 +594,7 @@ defmodule Momento.Internal.ScsDataClient do
sorted_set_name,
[value]
) do
{:ok, %Momento.Responses.SortedSet.GetScores.Hit{values: values}} ->
{:ok, %Momento.Responses.SortedSet.GetScores.Hit{value: values}} ->
case values do
[] ->
:miss
Expand Down Expand Up @@ -662,7 +668,7 @@ defmodule Momento.Internal.ScsDataClient do
end
end)

{:ok, %Momento.Responses.SortedSet.GetScores.Hit{values: values_to_scores}}
{:ok, %Momento.Responses.SortedSet.GetScores.Hit{value: values_to_scores}}

%Momento.Protos.CacheClient.SortedSetGetScoreResponse{
sorted_set:
Expand Down
6 changes: 3 additions & 3 deletions src/lib/momento/responses/sorted_set/get_scores.ex
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
defmodule Momento.Responses.SortedSet.GetScores do
defmodule Hit do
@enforce_keys [:values]
defstruct [:values]
@type t() :: %__MODULE__{values: [{binary(), float() | nil}]}
@enforce_keys [:value]
defstruct [:value]
@type t() :: %__MODULE__{value: [{binary(), float() | nil}]}
end

@type t() ::
Expand Down

0 comments on commit a652f2d

Please sign in to comment.