Skip to content

Commit

Permalink
Merge pull request #1454 from internetee/762-partially-allow-to-updat…
Browse files Browse the repository at this point in the history
…e-statuses-via-epp

Fix epp domains controller to apply add or rem changes to status
  • Loading branch information
vohmar authored Jan 3, 2020
2 parents a06baa2 + a863c3c commit 3e214ba
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/controllers/epp/domains_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,19 @@ def find_password

def status_editing_disabled
return true if Setting.client_status_editing_enabled
return true if check_client_hold
return true if params[:parsed_frame].css('status').empty?
epp_errors << {
code: '2306',
msg: "#{I18n.t(:client_side_status_editing_error)}: status [status]"
}
end

def check_client_hold
statuses = params[:parsed_frame].css('status').map { |element| element['s'] }
statuses == [::DomainStatus::CLIENT_HOLD]
end

def balance_ok?(operation, period = nil, unit = nil)
@domain_pricelist = @domain.pricelist(operation, period.try(:to_i), unit)
if @domain_pricelist.try(:price) # checking if price list is not found
Expand Down
50 changes: 50 additions & 0 deletions test/integration/epp/domain/update/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,56 @@ def test_deactivates_domain_when_all_name_servers_are_removed
assert @domain.inactive?
end

def test_update_domain_allows_add_of_client_hold
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>shop.test</domain:name>
<domain:add>
<domain:status s="clientHold" lang="en">Test</domain:status>
</domain:add>
</domain:update>
</update>
</command>
</epp>
XML

post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
@domain.reload
assert_epp_response :completed_successfully
assert_includes(@domain.statuses, DomainStatus::CLIENT_HOLD)
end

def test_update_domain_allows_remove_of_client_hold
@domain.update!(statuses: [DomainStatus::CLIENT_HOLD])

request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>shop.test</domain:name>
<domain:rem>
<domain:status s="clientHold" lang="en">Test</domain:status>
</domain:rem>
</domain:update>
</update>
</command>
</epp>
XML

post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
@domain.reload
assert_epp_response :completed_successfully
assert_not_includes(@domain.statuses, DomainStatus::CLIENT_HOLD)
end

private

def assert_verification_and_notification_emails
Expand Down

0 comments on commit 3e214ba

Please sign in to comment.