Merge branch 'master' of github.com:internetee/registry

This commit is contained in:
Andres Keskküla 2014-11-07 15:11:18 +02:00
commit a0c9c303db
25 changed files with 440 additions and 174 deletions

View file

@ -27,7 +27,7 @@ describe 'EPP Domain', epp: true do
it 'returns error if contact does not exists' do
Fabricate(:contact, code: 'jd1234')
response = epp_request(EppXml::Domain.create, :xml)
response = epp_request(domain_create_xml, :xml)
expect(response[:results][0][:result_code]).to eq('2303')
expect(response[:results][0][:msg]).to eq('Contact was not found')
@ -48,14 +48,14 @@ describe 'EPP Domain', epp: true do
end
it 'can not see other registrar domains' do
response = epp_request(EppXml::Domain.info, :xml, :elkdata)
response = epp_request(domain_info_xml, :xml, :elkdata)
expect(response[:result_code]).to eq('2302')
expect(response[:msg]).to eq('Domain exists but belongs to other registrar')
end
it 'transfers a domain' do
pw = domain.auth_info
xml = domain_transfer_xml(pw: pw)
xml = domain_transfer_xml({ authInfo: { pw: { value: pw } } })
response = epp_request(xml, :xml, :elkdata)
domain.reload
@ -76,7 +76,7 @@ describe 'EPP Domain', epp: true do
domain.reload
pw = domain.auth_info
xml = domain_transfer_xml(pw: pw) # request with new password
xml = domain_transfer_xml({ authInfo: { pw: { value: pw } } }) # request with new password
response = epp_request(xml, :xml, :zone)
trn_data = response[:parsed].css('trnData')
@ -110,6 +110,26 @@ describe 'EPP Domain', epp: true do
expect(trn_data.css('exDate').text).to eq(domain.valid_to.to_time.utc.to_s)
expect(domain.registrar).to eq(elkdata)
# should show up in other registrar's poll
response = epp_request(EppXml::Session.poll, :xml, :zone)
expect(response[:msg]).to eq('Command completed successfully; ack to dequeue')
msg_q = response[:parsed].css('msgQ')
expect(msg_q.css('qDate').text).to_not be_blank
expect(msg_q.css('msg').text).to eq('Transfer requested.')
expect(msg_q.first['id']).to_not be_blank
expect(msg_q.first['count']).to eq('1')
xml = EppXml::Session.poll(poll: {
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
})
response = epp_request(xml, :xml, :zone)
expect(response[:msg]).to eq('Command completed successfully')
msg_q = response[:parsed].css('msgQ')
expect(msg_q.first['id']).to_not be_blank
expect(msg_q.first['count']).to eq('0')
end
it 'prohibits wrong registrar from approving transfer' do
@ -120,7 +140,7 @@ describe 'EPP Domain', epp: true do
transfer_from: zone
})
xml = domain_transfer_xml(pw: domain.auth_info, op: 'approve')
xml = domain_transfer_xml({ authInfo: { pw: { value: domain.auth_info } } }, 'approve')
response = epp_request(xml, :xml, :elkdata)
expect(response[:result_code]).to eq('2304')
expect(response[:msg]).to eq('Transfer can be approved only by current domain registrar')
@ -134,7 +154,7 @@ describe 'EPP Domain', epp: true do
transfer_from: zone
})
xml = domain_transfer_xml(pw: domain.auth_info, op: 'approve')
xml = domain_transfer_xml({ authInfo: { pw: { value: domain.auth_info } } }, 'approve')
response = epp_request(xml, :xml, :zone)
domain.reload
dtl = domain.domain_transfers.last
@ -150,14 +170,15 @@ describe 'EPP Domain', epp: true do
end
it 'does not transfer with invalid pw' do
response = epp_request(domain_transfer_xml(pw: 'test'), :xml)
xml = domain_transfer_xml({ authInfo: { pw: { value: 'test' } } })
response = epp_request(xml, :xml)
expect(response[:result_code]).to eq('2201')
expect(response[:msg]).to eq('Authorization error')
end
it 'ignores transfer when owner registrar requests transfer' do
pw = domain.auth_info
xml = domain_transfer_xml(pw: pw)
xml = domain_transfer_xml({ authInfo: { pw: { value: pw } } })
response = epp_request(xml, :xml, :zone)
expect(response[:result_code]).to eq('2002')
@ -165,7 +186,7 @@ describe 'EPP Domain', epp: true do
end
it 'returns an error for incorrect op attribute' do
response = epp_request(domain_transfer_xml(op: 'bla'), :xml, :zone)
response = epp_request(domain_transfer_xml({}, 'bla'), :xml, :zone)
expect(response[:result_code]).to eq('2306')
expect(response[:msg]).to eq('Attribute op is invalid')
end
@ -188,7 +209,7 @@ describe 'EPP Domain', epp: true do
end
it 'creates a domain' do
response = epp_request(EppXml::Domain.create, :xml)
response = epp_request(domain_create_xml, :xml)
d = Domain.first
expect(response[:result_code]).to eq('1000')
@ -224,7 +245,7 @@ describe 'EPP Domain', epp: true do
end
it 'creates ria.ee with valid ds record' do
xml = EppXml::Domain.create({
xml = domain_create_xml({
name: { value: 'ria.ee' }
}, {
_anonymus: [
@ -250,7 +271,7 @@ describe 'EPP Domain', epp: true do
end
it 'validates nameserver ipv4 when in same zone as domain' do
xml = EppXml::Domain.create({
xml = domain_create_xml({
ns: [
{ hostObj: { value: 'ns1.example.ee' } },
{ hostObj: { value: 'ns2.example.ee' } }
@ -263,8 +284,8 @@ describe 'EPP Domain', epp: true do
end
it 'does not create duplicate domain' do
epp_request(EppXml::Domain.create, :xml)
response = epp_request(EppXml::Domain.create, :xml)
epp_request(domain_create_xml, :xml)
response = epp_request(domain_create_xml, :xml)
expect(response[:result_code]).to eq('2302')
expect(response[:msg]).to eq('Domain name already exists')
expect(response[:clTRID]).to eq('ABC-12345')
@ -273,7 +294,7 @@ describe 'EPP Domain', epp: true do
it 'does not create reserved domain' do
Fabricate(:reserved_domain)
xml = EppXml::Domain.create(name: { value: '1162.ee' })
xml = domain_create_xml(name: { value: '1162.ee' })
response = epp_request(xml, :xml)
expect(response[:result_code]).to eq('2302')
@ -282,7 +303,7 @@ describe 'EPP Domain', epp: true do
end
it 'does not create domain without contacts and registrant' do
xml = EppXml::Domain.create(contacts: [], registrant: false)
xml = domain_create_xml(contacts: [], registrant: false)
response = epp_request(xml, :xml)
expect(response[:results][0][:result_code]).to eq('2003')
@ -290,7 +311,7 @@ describe 'EPP Domain', epp: true do
end
it 'does not create domain without nameservers' do
xml = EppXml::Domain.create(ns: [])
xml = domain_create_xml(ns: [])
response = epp_request(xml, :xml)
expect(response[:result_code]).to eq('2003')
expect(response[:msg]).to eq('Required parameter missing: ns')
@ -299,7 +320,7 @@ describe 'EPP Domain', epp: true do
it 'does not create domain with too many nameservers' do
nameservers = []
14.times { |i| nameservers << { hostObj: { value: "ns#{i}.example.net" } } }
xml = EppXml::Domain.create(ns: nameservers)
xml = domain_create_xml(ns: nameservers)
response = epp_request(xml, :xml)
expect(response[:result_code]).to eq('2004')
@ -307,7 +328,7 @@ describe 'EPP Domain', epp: true do
end
it 'returns error when invalid nameservers are present' do
xml = EppXml::Domain.create({
xml = domain_create_xml({
ns: [
{ hostObj: { value: 'invalid1-' } },
{ hostObj: { value: '-invalid2' } }
@ -341,7 +362,7 @@ describe 'EPP Domain', epp: true do
end
it 'creates a domain with period in days' do
xml = EppXml::Domain.create(period_value: 365, period_unit: 'd')
xml = domain_create_xml(period_value: 365, period_unit: 'd')
response = epp_request(xml, :xml)
expect(response[:result_code]).to eq('1000')
@ -350,7 +371,7 @@ describe 'EPP Domain', epp: true do
end
it 'does not create a domain with invalid period' do
xml = EppXml::Domain.create({
xml = domain_create_xml({
period: { value: '367', attrs: { unit: 'd' } }
})
@ -361,7 +382,7 @@ describe 'EPP Domain', epp: true do
end
it 'creates a domain with multiple dnskeys' do
xml = EppXml::Domain.create({}, {
xml = domain_create_xml({}, {
_anonymus: [
{ keyData: {
flags: { value: '257' },
@ -411,7 +432,7 @@ describe 'EPP Domain', epp: true do
it 'does not create a domain when dnskeys are invalid' do
xml = EppXml::Domain.create({}, {
xml = domain_create_xml({}, {
_anonymus: [
{ keyData: {
flags: { value: '250' },
@ -463,7 +484,7 @@ describe 'EPP Domain', epp: true do
end
it 'does not create a domain with two identical dnskeys' do
xml = EppXml::Domain.create({}, {
xml = domain_create_xml({}, {
_anonymus: [
{ keyData: {
flags: { value: '257' },
@ -492,7 +513,7 @@ describe 'EPP Domain', epp: true do
it 'validated dnskeys count' do
Setting.dnskeys_max_count = 1
xml = EppXml::Domain.create({}, {
xml = domain_create_xml({}, {
_anonymus: [
{ keyData: {
flags: { value: '257' },
@ -518,7 +539,7 @@ describe 'EPP Domain', epp: true do
end
it 'creates domain with ds data' do
xml = EppXml::Domain.create({}, {
xml = domain_create_xml({}, {
_anonymus: [
{ dsData: {
keyTag: { value: '12345' },
@ -544,7 +565,7 @@ describe 'EPP Domain', epp: true do
end
it 'creates domain with ds data with key' do
xml = EppXml::Domain.create({}, {
xml = domain_create_xml({}, {
_anonymus: [
{ dsData: {
keyTag: { value: '12345' },
@ -578,7 +599,7 @@ describe 'EPP Domain', epp: true do
it 'prohibits dsData with key' do
Setting.ds_data_with_key_allowed = false
xml = EppXml::Domain.create({}, {
xml = domain_create_xml({}, {
_anonymus: [
{ dsData: {
keyTag: { value: '12345' },
@ -603,7 +624,7 @@ describe 'EPP Domain', epp: true do
it 'prohibits dsData' do
Setting.ds_data_allowed = false
xml = EppXml::Domain.create({}, {
xml = domain_create_xml({}, {
_anonymus: [
{ dsData: {
keyTag: { value: '12345' },
@ -628,7 +649,7 @@ describe 'EPP Domain', epp: true do
it 'prohibits keyData' do
Setting.key_data_allowed = false
xml = EppXml::Domain.create({}, {
xml = domain_create_xml({}, {
_anonymus: [
keyData: {
flags: { value: '0' },
@ -652,7 +673,7 @@ describe 'EPP Domain', epp: true do
end
it 'creates a domain with contacts' do
xml = EppXml::Domain.create({
xml = domain_create_xml({
_anonymus: [
{ contact: { value: 'sh8013', attrs: { type: 'admin' } } }
]
@ -671,7 +692,7 @@ describe 'EPP Domain', epp: true do
end
it 'does not create a domain without admin contact' do
xml = EppXml::Domain.create({
xml = domain_create_xml({
_anonymus: [
{ contact: { value: 'sh8013', attrs: { type: 'tech' } } }
]
@ -733,7 +754,7 @@ describe 'EPP Domain', epp: true do
end
it 'sets ok status by default' do
response = epp_request(EppXml::Domain.info, :xml)
response = epp_request(domain_info_xml, :xml)
inf_data = response[:parsed].css('resData infData')
expect(inf_data.css('status').first[:s]).to eq('ok')
end
@ -767,7 +788,7 @@ describe 'EPP Domain', epp: true do
d.save
xml = EppXml::Domain.info(name: { value: 'Example.ee' })
xml = domain_info_xml(name: { value: 'Example.ee' })
response = epp_request(xml, :xml)
expect(response[:results][0][:result_code]).to eq('1000')
@ -821,20 +842,20 @@ describe 'EPP Domain', epp: true do
d.touch
response = epp_request(EppXml::Domain.info, :xml)
response = epp_request(domain_info_xml, :xml)
inf_data = response[:parsed].css('resData infData')
expect(inf_data.css('upDate').text).to eq(d.updated_at.to_time.utc.to_s)
end
it 'returns error when domain can not be found' do
response = epp_request(EppXml::Domain.info(name: { value: 'test.ee' }), :xml)
response = epp_request(domain_info_xml(name: { value: 'test.ee' }), :xml)
expect(response[:results][0][:result_code]).to eq('2303')
expect(response[:results][0][:msg]).to eq('Domain not found')
end
it 'updates domain and adds objects', pending: true do
xml = EppXml::Domain.update({
xml = domain_update_xml({
add: [
{
ns: [
@ -917,7 +938,7 @@ describe 'EPP Domain', epp: true do
it 'updates a domain and removes objects' do
Fabricate(:contact, code: 'mak21')
xml = EppXml::Domain.update({
xml = domain_update_xml({
add: [
{
ns: [
@ -955,7 +976,7 @@ describe 'EPP Domain', epp: true do
d = Domain.last
expect(d.dnskeys.count).to eq(2)
xml = EppXml::Domain.update({
xml = domain_update_xml({
rem: [
{
ns: [
@ -1006,7 +1027,7 @@ describe 'EPP Domain', epp: true do
it 'does not add duplicate objects to domain' do
Fabricate(:contact, code: 'mak21')
xml = EppXml::Domain.update({
xml = domain_update_xml({
add: [
ns: [
{ hostObj: { value: 'ns1.example.com' } }
@ -1032,7 +1053,7 @@ describe 'EPP Domain', epp: true do
]
}
response = epp_request(EppXml::Domain.update(xml_params), :xml)
response = epp_request(domain_update_xml(xml_params), :xml)
expect(response[:results][0][:result_code]).to eq('1000')
d = Domain.last
@ -1042,7 +1063,7 @@ describe 'EPP Domain', epp: true do
end
it 'does not assign invalid status to domain' do
xml = EppXml::Domain.update({
xml = domain_update_xml({
add: [
status: { value: '', attrs: { s: 'invalidStatus' } }
]
@ -1073,7 +1094,7 @@ describe 'EPP Domain', epp: true do
end
it 'checks a domain' do
response = epp_request(EppXml::Domain.check, :xml)
response = epp_request(domain_check_xml, :xml)
expect(response[:result_code]).to eq('1000')
expect(response[:msg]).to eq('Command completed successfully')
@ -1083,7 +1104,7 @@ describe 'EPP Domain', epp: true do
Fabricate(:domain, name: 'example.ee', registrar: zone)
response = epp_request(EppXml::Domain.check, :xml)
response = epp_request(domain_check_xml, :xml)
domain = response[:parsed].css('resData chkData cd').first
name = domain.css('name').first
reason = domain.css('reason').first
@ -1094,7 +1115,7 @@ describe 'EPP Domain', epp: true do
end
it 'checks multiple domains' do
xml = EppXml::Domain.check({
xml = domain_check_xml({
_anonymus: [
{ name: { value: 'one.ee' } },
{ name: { value: 'two.ee' } },
@ -1116,7 +1137,7 @@ describe 'EPP Domain', epp: true do
end
it 'checks invalid format domain' do
xml = EppXml::Domain.check({
xml = domain_check_xml({
_anonymus: [
{ name: { value: 'one.ee' } },
{ name: { value: 'notcorrectdomain' } }