Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

fix: mask IBAN to last 4 characters in Lunch Flow account selection (#3574)

GFRca52d184b5f3
diff --git a/app/views/lunchflow_items/select_accounts.html.erb b/app/views/lunchflow_items/select_accounts.html.erb
index dc9f5aba5e..ab01c34434 100644
--- a/app/views/lunchflow_items/select_accounts.html.erb
+++ b/app/views/lunchflow_items/select_accounts.html.erb
@@ -28,7 +28,7 @@
</div>
<div class="text-xs text-secondary mt-1">
<% if account[:iban].present? %>
- <%= account[:iban] %> •
+ •<%= account[:iban].last(4) %> •
<% end %>
<%= account[:institution_name] %> • <%= account[:currency] %> • <%= account[:status] %>
</div>
diff --git a/app/views/lunchflow_items/select_existing_account.html.erb b/app/views/lunchflow_items/select_existing_account.html.erb
index 07f8227eb0..a9837844dd 100644
--- a/app/views/lunchflow_items/select_existing_account.html.erb
+++ b/app/views/lunchflow_items/select_existing_account.html.erb
@@ -28,7 +28,7 @@
</div>
<div class="text-xs text-secondary mt-1">
<% if account[:iban].present? %>
- <%= account[:iban] %> •
+ •<%= account[:iban].last(4) %> •
<% end %>
<%= account[:institution_name] %> • <%= account[:currency] %> • <%= account[:status] %>
</div>
diff --git a/test/controllers/lunchflow_items_controller_test.rb b/test/controllers/lunchflow_items_controller_test.rb
index e35ad45357..5432a893f5 100644
--- a/test/controllers/lunchflow_items_controller_test.rb
+++ b/test/controllers/lunchflow_items_controller_test.rb
@@ -121,6 +121,34 @@ class LunchflowItemsControllerTest < ActionDispatch::IntegrationTest
refute_includes response.body, "Ein unerwarteter Fehler ist aufgetreten. Versuch es später noch einmal."
end
+ test "select accounts masks the iban to the last 4 characters" do
+ provider = mock("lunchflow_provider")
+ provider.stubs(:get_accounts).returns(accounts: [
+ { id: "acc_1", name: "Checking", iban: "DE89370400440532013000", institution_name: "Test Bank", currency: "EUR", status: "active" } # pipelock:ignore IBAN
+ ])
+ Provider::LunchflowAdapter.stubs(:build_provider).returns(provider)
+
+ get select_accounts_lunchflow_items_url
+
+ assert_response :success
+ assert_includes response.body, "•3000"
+ refute_includes response.body, "DE89370400440532013000" # pipelock:ignore IBAN
+ end
+
+ test "select existing account masks the iban to the last 4 characters" do
+ provider = mock("lunchflow_provider")
+ provider.stubs(:get_accounts).returns(accounts: [
+ { id: "acc_1", name: "Checking", iban: "DE89370400440532013000", institution_name: "Test Bank", currency: "EUR", status: "active" } # pipelock:ignore IBAN
+ ])
+ Provider::LunchflowAdapter.stubs(:build_provider).returns(provider)
+
+ get select_existing_account_lunchflow_items_url(account_id: accounts(:depository).id)
+
+ assert_response :success
+ assert_includes response.body, "•3000"
+ refute_includes response.body, "DE89370400440532013000" # pipelock:ignore IBAN
+ end
+
test "invalid non-Turbo create redirects instead of rendering a missing template" do
assert_no_difference "LunchflowItem.count" do
post lunchflow_items_url, params: {