Domain status value uniqueness fix, epp tests fixes

This commit is contained in:
Martin Lensment 2014-09-30 18:05:32 +03:00
parent bfba09f0a4
commit 0ab1e29a53
7 changed files with 9 additions and 16 deletions

View file

@ -48,7 +48,7 @@ class Domain < ActiveRecord::Base
validate :validate_nameservers_uniqueness, if: :new_record? validate :validate_nameservers_uniqueness, if: :new_record?
validate :validate_tech_contacts_uniqueness, if: :new_record? validate :validate_tech_contacts_uniqueness, if: :new_record?
validate :validate_admin_contacts_uniqueness, if: :new_record? validate :validate_admin_contacts_uniqueness, if: :new_record?
validate :validate_domain_statuses_uniqueness, if: :new_record? validate :validate_domain_statuses_uniqueness
attr_accessor :owner_contact_typeahead attr_accessor :owner_contact_typeahead

View file

@ -33,8 +33,6 @@ class DomainStatus < ActiveRecord::Base
CLIENT_STATUSES = [CLIENT_DELETE_PROHIBITED, CLIENT_HOLD, CLIENT_RENEW_PROHIBITED, CLIENT_TRANSFER_PROHIBITED, CLIENT_UPDATE_PROHIBITED] CLIENT_STATUSES = [CLIENT_DELETE_PROHIBITED, CLIENT_HOLD, CLIENT_RENEW_PROHIBITED, CLIENT_TRANSFER_PROHIBITED, CLIENT_UPDATE_PROHIBITED]
SERVER_STATUSES = [SERVER_DELETE_PROHIBITED, SERVER_HOLD, SERVER_RENEW_PROHIBITED, SERVER_TRANSFER_PROHIBITED, SERVER_UPDATE_PROHIBITED, SERVER_MANUAL_INZONE, SERVER_REGISTRANT_CHANGE_PROHIBITED, SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED] SERVER_STATUSES = [SERVER_DELETE_PROHIBITED, SERVER_HOLD, SERVER_RENEW_PROHIBITED, SERVER_TRANSFER_PROHIBITED, SERVER_UPDATE_PROHIBITED, SERVER_MANUAL_INZONE, SERVER_REGISTRANT_CHANGE_PROHIBITED, SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED]
validates :value, uniqueness: { scope: :domain_id }
def epp_code_map def epp_code_map
{ {
'2302' => [ # Object exists '2302' => [ # Object exists

View file

@ -1,7 +1,6 @@
require 'rails_helper' require 'rails_helper'
describe 'EPP Contact', epp: true do describe 'EPP Contact', epp: true do
let(:server_gitlab) { Epp::Server.new({ server: 'localhost', tag: 'gitlab', password: 'ghyt9e4fu', port: 701 }) }
let(:server_zone) { Epp::Server.new({ server: 'localhost', tag: 'zone', password: 'ghyt9e4fu', port: 701 }) } let(:server_zone) { Epp::Server.new({ server: 'localhost', tag: 'zone', password: 'ghyt9e4fu', port: 701 }) }
let(:server_elkdata) { Epp::Server.new({ server: 'localhost', tag: 'elkdata', password: 'ghyt9e4fu', port: 701 }) } let(:server_elkdata) { Epp::Server.new({ server: 'localhost', tag: 'elkdata', password: 'ghyt9e4fu', port: 701 }) }
let(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) } let(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) }
@ -9,7 +8,6 @@ describe 'EPP Contact', epp: true do
context 'with valid user' do context 'with valid user' do
before(:each) do before(:each) do
Fabricate(:epp_user)
Fabricate(:epp_user, username: 'zone', registrar: zone) Fabricate(:epp_user, username: 'zone', registrar: zone)
Fabricate(:epp_user, username: 'elkdata', registrar: elkdata) Fabricate(:epp_user, username: 'elkdata', registrar: elkdata)
Fabricate(:domain_validation_setting_group) Fabricate(:domain_validation_setting_group)
@ -175,7 +173,7 @@ describe 'EPP Contact', epp: true do
end end
it 'fails if contact has associated domain' do it 'fails if contact has associated domain' do
Fabricate(:domain, owner_contact: Fabricate(:contact, code: 'dwa1234', created_by_id: EppUser.first.id)) Fabricate(:domain, owner_contact: Fabricate(:contact, code: 'dwa1234', created_by_id: EppUser.first.id), registrar: zone)
expect(Domain.first.owner_contact.address.present?).to be true expect(Domain.first.owner_contact.address.present?).to be true
response = epp_request('contacts/delete.xml') response = epp_request('contacts/delete.xml')

View file

@ -1,7 +1,6 @@
require 'rails_helper' require 'rails_helper'
describe 'EPP Domain', epp: true do describe 'EPP Domain', epp: true do
let(:server_gitlab) { Epp::Server.new({ server: 'localhost', tag: 'gitlab', password: 'ghyt9e4fu', port: 701 }) }
let(:server_zone) { Epp::Server.new({ server: 'localhost', tag: 'zone', password: 'ghyt9e4fu', port: 701 }) } let(:server_zone) { Epp::Server.new({ server: 'localhost', tag: 'zone', password: 'ghyt9e4fu', port: 701 }) }
let(:server_elkdata) { Epp::Server.new({ server: 'localhost', tag: 'elkdata', password: 'ghyt9e4fu', port: 701 }) } let(:server_elkdata) { Epp::Server.new({ server: 'localhost', tag: 'elkdata', password: 'ghyt9e4fu', port: 701 }) }
let(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) } let(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) }
@ -9,7 +8,6 @@ describe 'EPP Domain', epp: true do
context 'with valid user' do context 'with valid user' do
before(:each) do before(:each) do
Fabricate(:epp_user)
Fabricate(:epp_user, username: 'zone', registrar: zone) Fabricate(:epp_user, username: 'zone', registrar: zone)
Fabricate(:epp_user, username: 'elkdata', registrar: elkdata) Fabricate(:epp_user, username: 'elkdata', registrar: elkdata)
@ -171,9 +169,8 @@ describe 'EPP Domain', epp: true do
it 'creates new pw after successful transfer' do it 'creates new pw after successful transfer' do
pw = domain.auth_info pw = domain.auth_info
xml = domain_transfer_xml(pw: pw) xml = domain_transfer_xml(pw: pw)
epp_request(xml, :xml) # transfer domain response = epp_request(xml, :xml, :elkdata) # transfer domain
response = epp_request(xml, :xml) # attempt second transfer response = epp_request(xml, :xml, :elkdata) # attempt second transfer
expect(response[:result_code]).to eq('2200') expect(response[:result_code]).to eq('2200')
expect(response[:msg]).to eq('Authentication error') expect(response[:msg]).to eq('Authentication error')
end end
@ -609,7 +606,7 @@ describe 'EPP Domain', epp: true do
expect(domain.text).to eq('example.ee') expect(domain.text).to eq('example.ee')
expect(domain[:avail]).to eq('1') expect(domain[:avail]).to eq('1')
Fabricate(:domain, name: 'example.ee') Fabricate(:domain, name: 'example.ee', registrar: zone)
response = epp_request(domain_check_xml, :xml) response = epp_request(domain_check_xml, :xml)
domain = response[:parsed].css('resData chkData cd').first domain = response[:parsed].css('resData chkData cd').first

View file

@ -1,4 +1,4 @@
Fabricator(:country) do Fabricator(:country) do
iso Faker::Address.state_abbr iso 'EE'
name Faker::Address.country name 'Estonia'
end end

View file

@ -2,4 +2,5 @@ Fabricator(:registrar) do
name 'Zone Media OÜ' name 'Zone Media OÜ'
reg_no '10577829' reg_no '10577829'
address 'Lõõtsa 2, Tallinna linn, Harju maakond, 11415' address 'Lõõtsa 2, Tallinna linn, Harju maakond, 11415'
country
end end

View file

@ -5,9 +5,8 @@ module Epp
# handles connection and login automatically # handles connection and login automatically
def epp_request(data, *args) def epp_request(data, *args)
server = server_gitlab server = server_zone
server = server_elkdata if args.include?(:elkdata) server = server_elkdata if args.include?(:elkdata)
server = server_zone if args.include?(:zone)
return parse_response(server.request(data)) if args.include?(:xml) return parse_response(server.request(data)) if args.include?(:xml)
return parse_response(server.request(read_body(data))) return parse_response(server.request(read_body(data)))