Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions dashboard/test/controllers/activities_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -835,30 +835,6 @@ def build_try_again_response(options = {})
assert_equal_expected_keys expected_response, JSON.parse(@response.body)
end

test 'sharing program with street address returns error' do
Geocoder.stubs(:find_potential_street_address).returns('1600 Pennsylvania Ave NW Washington DC')

assert_does_not_create(LevelSource) do
post :milestone,
params: @milestone_params.merge(
script_level_id: @playlab_script_level.id,
course_id: @playlab_script.original_unit_group_id,
program: studio_program_with_text('1600 Pennsylvania Ave NW Washington DC')
)
end
assert_response :success

expected_response = {
'level_source' => nil,
'share_failure' => {
'message' => "It looks like there is an address in it. Try changing the text.",
'contents' => '1600 Pennsylvania Ave NW Washington DC',
'type' => 'address'
}
}
assert_equal_expected_keys expected_response, JSON.parse(@response.body)
end

test 'sharing when gatekeeper has disabled sharing does not work' do
Gatekeeper.set('shareEnabled', where: {script_name: @playlab_script.name}, value: false)

Expand Down
17 changes: 2 additions & 15 deletions lib/cdo/share_filtering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,8 @@ def self.find_share_failure(program, locale, project_type, exceptions: false)
failure = find_email_or_phone_failure(program_text, exceptions: exceptions)
return failure if failure

# Address: check each text block independently to prevent cross-block bleeding.
candidate = nil
texts.each do |text|
candidate = Geocoder.extract_address_candidate(text)
break if candidate
end
if candidate
address = Geocoder.find_potential_street_address(candidate)
if address
failure = ShareFailure.new(FailureType::ADDRESS, address)
raise PIIFilterException.new("Address PII Filter Violation", failure) if exceptions
return failure
end
end

# Temporarily disable address filtering to prevent false positives.
# TODO: re-enable this when we improve the user experience of the address filter.
find_profanity_failure(program_text, locale, {}, exceptions: exceptions)
end

Expand Down
21 changes: 3 additions & 18 deletions lib/test/cdo/test_share_filtering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_extract_address_candidate
assert_equal Geocoder::MAX_ADDRESS_WORDS, candidate.split.length
end

def test_find_share_failure_with_street_address
def test_find_share_failure_temporarily_ignores_street_address
Geocoder.
stubs(:find_potential_street_address).
returns('1600 Pennsylvania Ave NW, Washington, DC 20500')
Expand All @@ -112,23 +112,8 @@ def test_find_share_failure_with_street_address
'My Street Address',
'1600 Pennsylvania Ave NW, Washington, DC 20500'
)
assert_equal(
ShareFailure.new(
ShareFiltering::FailureType::ADDRESS,
'1600 Pennsylvania Ave NW, Washington, DC 20500'
),
ShareFiltering.find_share_failure(program, 'en', 'playlab')
)

assert_equal(
ShareFailure.new(
ShareFiltering::FailureType::ADDRESS,
'1600 Pennsylvania Ave NW, Washington, DC 20500'
),
assert_raises(PIIFilterException) do
ShareFiltering.find_share_failure(program, 'en', 'playlab', exceptions: true)
end.share_failure
)
assert_nil ShareFiltering.find_share_failure(program, 'en', 'playlab')
assert_nil ShareFiltering.find_share_failure(program, 'en', 'playlab', exceptions: true)
end

def test_find_share_failure_with_phone_number
Expand Down
Loading