diff --git a/db/migrate/20230801131609_change_event_logs_trailing_message_column.rb b/db/migrate/20230801131609_change_event_logs_trailing_message_column.rb new file mode 100644 index 000000000..f27b5a5e1 --- /dev/null +++ b/db/migrate/20230801131609_change_event_logs_trailing_message_column.rb @@ -0,0 +1,9 @@ +class ChangeEventLogsTrailingMessageColumn < ActiveRecord::Migration[7.0] + def up + change_column :event_logs, :trailing_message, :text + end + + def down + change_column :event_logs, :trailing_message, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 7526d22d9..fd8029a12 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -62,7 +62,7 @@ t.datetime "created_at", precision: nil, null: false t.integer "initiator_id" t.integer "application_id" - t.string "trailing_message" + t.text "trailing_message" t.integer "event_id" t.decimal "ip_address", precision: 38 t.integer "user_agent_id" diff --git a/test/services/user_update_test.rb b/test/services/user_update_test.rb index 624a054ee..d50143cbb 100644 --- a/test/services/user_update_test.rb +++ b/test/services/user_update_test.rb @@ -38,6 +38,23 @@ class UserUpdateTest < ActionView::TestCase assert_equal parsed_ip_address, add_event.ip_address_string end + should "log the addition of a large number of permissions" do + current_user = create(:superadmin_user) + ip_address = "1.2.3.4" + + affected_user = create(:user) + permissions = (0..100).map { |i| "permission-#{i}" } + app = create(:application, name: "App", with_supported_permissions: permissions) + + params = { supported_permission_ids: app.supported_permissions.map(&:id) } + UserUpdate.new(affected_user, params, current_user, ip_address).call + + add_event = EventLog.where(event_id: EventLog::PERMISSIONS_ADDED.id).last + logged_permissions = add_event.trailing_message.sub(/^\(/, "").sub(/\)$/, "").gsub(/ /, "").split(",") + + assert Set.new(permissions).subset?(Set.new(logged_permissions)) + end + should "record when 2SV exemption has been removed" do current_user = create(:superadmin_user) ip_address = "1.2.3.4"