disclose attributes validator

This commit is contained in:
olegphenomenon 2022-11-28 11:26:43 +02:00
parent 1b92bf0d64
commit ea2fc01a60
3 changed files with 42 additions and 22 deletions

View file

@ -9,7 +9,6 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
@original_address_processing = Setting.address_processing
@original_fax_enabled_setting = ENV['fax_enabled']
@user = users(:registrant)
end
teardown do
@ -91,18 +90,18 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
@contact.address
end
# def test_update_address_when_enabled_without_address_params
# Setting.address_processing = false
def test_update_address_when_enabled_without_address_params
Setting.address_processing = false
# patch api_v1_registrant_contact_path(@contact.uuid), params: { address: { } },
# as: :json,
# headers: { 'HTTP_AUTHORIZATION' => auth_token }
patch api_v1_registrant_contact_path(@contact.uuid), params: { address: { } },
as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
# assert_response :bad_request
# @contact.reload
# assert_equal Contact::Address.new(nil, nil, nil, nil, nil),
# @contact.address
# end
assert_response :bad_request
@contact.reload
assert_equal Contact::Address.new(nil, nil, nil, nil, nil),
@contact.address
end
def test_address_is_optional_when_enabled
Setting.address_processing = true
@ -179,7 +178,7 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
# def test_legal_persons_disclosed_attributes_cannot_be_changed
# @contact = contacts(:acme_ltd)
# # contacts(:acme_ltd).ident
# contacts(:acme_ltd).ident
# assert_equal '1234567', @contact.ident
# assert_equal Contact::ORG, @contact.ident_type
@ -254,20 +253,20 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
symbolize_names: true)
end
# def test_org_disclosed_attributes
# patch api_v1_registrant_contact_path(@contact_org.uuid), params: { disclosed_attributes: ["some_attr"] },
# as: :json,
# headers: { 'HTTP_AUTHORIZATION' => auth_token }
def test_org_disclosed_attributes
patch api_v1_registrant_contact_path(@contact_org.uuid), params: { disclosed_attributes: ["some_attr"] },
as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
# assert_response :bad_request
assert_response :bad_request
# err_msg = "Legal person's data is visible by default and cannot be concealed. Please remove this parameter."
err_msg = "Request contains extra attributes: some_attr"
# response_json = JSON.parse(response.body, symbolize_names: true)
# response_msg = response_json[:errors][0][:disclosed_attributes][0]
response_json = JSON.parse(response.body, symbolize_names: true)
response_msg = response_json[:errors][0][:disclosed_attributes][0]
# assert_equal err_msg, response_msg
# end
assert_equal err_msg, response_msg
end
def test_unmanaged_contact_cannot_be_updated
assert_equal 'US-1234', @user.registrant_ident