Added some missing model specs + PaperTrail session fix

This commit is contained in:
Priit Tark 2015-02-02 18:09:01 +02:00
parent c248a957a6
commit a637eb5e01
39 changed files with 1447 additions and 845 deletions

View file

@ -2,16 +2,19 @@ require 'rails_helper'
describe 'EPP Contact', epp: true do
before :all do
Fabricate(:api_user)
Fabricate(:api_user, username: 'registrar1', registrar: registrar1)
Fabricate(:api_user, username: 'registrar2', registrar: registrar2)
create_settings
create_disclosure_settings
@registrar1 = Fabricate(:registrar1)
@registrar2 = Fabricate(:registrar2)
@epp_xml = EppXml::Contact.new(cl_trid: 'ABC-12345')
Fabricate(:api_user, username: 'registrar1', registrar: @registrar1)
Fabricate(:api_user, username: 'registrar2', registrar: @registrar2)
login_as :gitlab
login_as :registrar1
Contact.skip_callback(:create, :before, :generate_code)
Contact.skip_callback(:create, :before, :generate_auth_info)
create_settings
create_disclosure_settings
end
after :all do
@ -22,7 +25,7 @@ describe 'EPP Contact', epp: true do
context 'with valid user' do
context 'create command' do
it 'fails if request xml is missing' do
xml = epp_xml.create
xml = @epp_xml.create
response = epp_plain_request(xml, :xml)
response[:results][0][:msg].should == 'Command syntax error'
response[:results][0][:result_code].should == '2001'
@ -31,7 +34,7 @@ describe 'EPP Contact', epp: true do
end
it 'fails if request xml is missing' do
xml = epp_xml.create(
xml = @epp_xml.create(
postalInfo: { addr: { value: nil } }
)
response = epp_plain_request(xml, :xml)
@ -67,7 +70,7 @@ describe 'EPP Contact', epp: true do
@contact = Contact.last
@contact.registrar.should == registrar1
@contact.registrar.should == @registrar1
# registrar1.api_users.should include(@contact.created_by)
# @contact.updated_by_id.should == nil
@contact.ident.should == '37605030299'
@ -77,8 +80,8 @@ describe 'EPP Contact', epp: true do
log.request_command.should == 'create'
log.request_object.should == 'contact'
log.request_successful.should == true
log.api_user_name.should == '1-api-gitlab'
log.api_user_registrar.should == 'Registrar OÜ'
log.api_user_name.should == '1-api-registrar1'
log.api_user_registrar.should == 'registrar1'
end
it 'successfully adds registrar' do
@ -87,7 +90,7 @@ describe 'EPP Contact', epp: true do
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
Contact.last.registrar.should == registrar1
Contact.last.registrar.should == @registrar1
end
it 'returns result data upon success' do
@ -157,7 +160,7 @@ describe 'EPP Contact', epp: true do
Fabricate(
:contact,
# created_by_id: 1,
registrar: registrar1,
registrar: @registrar1,
email: 'not_updated@test.test',
code: 'sh8013',
auth_info: 'password'
@ -165,7 +168,7 @@ describe 'EPP Contact', epp: true do
end
it 'fails if request is invalid' do
xml = epp_xml.update
xml = @epp_xml.update
response = epp_plain_request(xml, :xml) # epp_request('contacts/update_missing_attr.xml')
response[:results][0][:result_code].should == '2003'
@ -215,7 +218,7 @@ describe 'EPP Contact', epp: true do
:contact,
code: 'sh8013disclosure',
auth_info: '2fooBAR',
registrar: registrar1,
registrar: @registrar1,
# created_by_id: ApiUser.first.id,
disclosure: Fabricate(:contact_disclosure, phone: true, email: true))
@ -235,7 +238,7 @@ describe 'EPP Contact', epp: true do
context 'delete command' do
it 'fails if request is invalid' do
xml = epp_xml.delete({ uid: { value: '23123' } })
xml = @epp_xml.delete({ uid: { value: '23123' } })
response = epp_plain_request(xml, :xml)
response[:results][0][:msg].should == 'Required parameter missing: id'
@ -246,7 +249,7 @@ describe 'EPP Contact', epp: true do
it 'deletes contact' do
@contact_deleted =
# Fabricate(:contact, code: 'dwa1234', created_by_id: ApiUser.first.id, registrar: registrar1)
Fabricate(:contact, code: 'dwa1234', registrar: registrar1)
Fabricate(:contact, code: 'dwa1234', registrar: @registrar1)
response = epp_plain_request(delete_contact_xml({ id: { value: 'dwa1234' } }), :xml)
response[:msg].should == 'Command completed successfully'
@ -265,12 +268,12 @@ describe 'EPP Contact', epp: true do
it 'fails if contact has associated domain' do
Fabricate(
:domain,
registrar: registrar1,
registrar: @registrar1,
owner_contact: Fabricate(
:contact,
code: 'dwa1234',
# created_by_id: registrar1.id,
registrar: registrar1)
registrar: @registrar1)
)
Domain.last.owner_contact.address.present?.should == true
response = epp_plain_request(delete_contact_xml({ id: { value: 'dwa1234' } }), :xml)
@ -284,7 +287,7 @@ describe 'EPP Contact', epp: true do
context 'check command' do
it 'fails if request is invalid' do
xml = epp_xml.check({ uid: { value: '123asde' } })
xml = @epp_xml.check({ uid: { value: '123asde' } })
response = epp_plain_request(xml, :xml)
response[:results][0][:msg].should == 'Required parameter missing: id'
@ -309,58 +312,58 @@ describe 'EPP Contact', epp: true do
end
end
context 'info command' do
before :all do
@registrar1_contact = Fabricate(:contact, code: 'info-4444', registrar: registrar1,
name: 'Johnny Awesome', address: Fabricate(:address))
end
it 'return info about contact' do
login_as :registrar1 do
xml = epp_xml.info(id: { value: @registrar1_contact.code })
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
contact = response[:parsed].css('resData chkData')
contact.css('name').first.text.should == 'Johnny Awesome'
end
end
it 'fails if request invalid' do
response = epp_plain_request(epp_xml.info({ wrongid: { value: '123123' } }), :xml)
response[:results][0][:msg].should == 'Required parameter missing: id'
response[:results][0][:result_code].should == '2003'
response[:results].count.should == 1
end
it 'returns error when object does not exist' do
response = epp_plain_request(info_contact_xml({ id: { value: 'no-contact' } }), :xml)
response[:msg].should == 'Object does not exist'
response[:result_code].should == '2303'
response[:results][0][:value].should == 'no-contact'
end
# it 'returns auth error for non-owner with wrong password' do
# @contact = Fabricate(:contact,
# registrar: registrar2, code: 'info-4444', name: 'Johnny Awesome', auth_info: 'asde',
# address: Fabricate(:address), disclosure: Fabricate(:contact_disclosure, name: false))
# xml = epp_xml.info({ id: { value: @contact.code }, authInfo: { pw: { value: 'asdesde' } } })
# response = epp_plain_request(xml, :xml, :registrar1)
# expect(response[:result_code]).to eq('2200')
# expect(response[:msg]).to eq('Authentication error')
# context 'info command' do
# before :all do
# @registrar1_contact = Fabricate(:contact, code: 'info-4444', registrar: @registrar1,
# name: 'Johnny Awesome', address: Fabricate(:address))
# end
context 'about disclose' do
# fit 'return info about contact' do
# login_as :registrar2 do
# xml = @epp_xml.info(id: { value: @registrar1_contact.code })
# response = epp_plain_request(xml, :xml)
# response[:msg].should == 'Command completed successfully'
# response[:result_code].should == '1000'
# contact = response[:parsed].css('resData chkData')
# contact.css('name').first.text.should == 'Johnny Awesome'
# end
# end
# it 'fails if request invalid' do
# response = epp_plain_request(@epp_xml.info({ wrongid: { value: '123123' } }), :xml)
# response[:results][0][:msg].should == 'Required parameter missing: id'
# response[:results][0][:result_code].should == '2003'
# response[:results].count.should == 1
# end
# it 'returns error when object does not exist' do
# response = epp_plain_request(info_contact_xml({ id: { value: 'no-contact' } }), :xml)
# response[:msg].should == 'Object does not exist'
# response[:result_code].should == '2303'
# response[:results][0][:value].should == 'no-contact'
# end
# # it 'returns auth error for non-owner with wrong password' do
# # @contact = Fabricate(:contact,
# # registrar: registrar2, code: 'info-4444', name: 'Johnny Awesome', auth_info: 'asde',
# # address: Fabricate(:address), disclosure: Fabricate(:contact_disclosure, name: false))
# # xml = @epp_xml.info({ id: { value: @contact.code }, authInfo: { pw: { value: 'asdesde' } } })
# # response = epp_plain_request(xml, :xml, :registrar1)
# # expect(response[:result_code]).to eq('2200')
# # expect(response[:msg]).to eq('Authentication error')
# # end
# context 'about disclose' do
# it 'discloses items with wrong password when queried by owner' do
# @contact = Fabricate(:contact,
# registrar: registrar1, code: 'info-4444',
# name: 'Johnny Awesome', auth_info: 'asde',
# address: Fabricate(:address), disclosure: Fabricate(:contact_disclosure, name: false))
# xml = epp_xml.info({ id: { value: @contact.code } })
# xml = @epp_xml.info({ id: { value: @contact.code } })
# login_as :registrar1 do
# response = epp_plain_request(xml, :xml)
# contact = response[:parsed].css('resData chkData')
@ -376,7 +379,7 @@ describe 'EPP Contact', epp: true do
# name: 'Johnny Awesome', auth_info: 'password',
# address: Fabricate(:address), disclosure: Fabricate(:contact_disclosure, name: false))
# xml = epp_xml.info({ id: { value: @contact.code }, authInfo: { pw: { value: 'password' } } })
# xml = @epp_xml.info({ id: { value: @contact.code }, authInfo: { pw: { value: 'password' } } })
# response = epp_plain_request(xml, :xml, :registrar1)
# contact = response[:parsed].css('resData chkData')
@ -390,7 +393,7 @@ describe 'EPP Contact', epp: true do
# auth_info: 'password',
# address: Fabricate(:address), disclosure: Fabricate(:contact_disclosure, name: false))
# xml = epp_xml.info({ id: { value: @contact.code } })
# xml = @epp_xml.info({ id: { value: @contact.code } })
# response = epp_plain_request(xml, :xml, :registrar1)
# contact = response[:parsed].css('resData chkData')
@ -403,7 +406,7 @@ describe 'EPP Contact', epp: true do
# Fabricate(:contact, code: 'info-4444', auth_info: '2fooBAR', registrar: registrar2,
# disclosure: Fabricate(:contact_disclosure, name: true, email: false, phone: false))
# xml = epp_xml.info({ id: { value: 'info-4444' }, authInfo: { pw: { value: '2fooBAR' } } })
# xml = @epp_xml.info({ id: { value: 'info-4444' }, authInfo: { pw: { value: '2fooBAR' } } })
# response = epp_plain_request(xml, :xml, :registrar1)
# contact = response[:parsed].css('resData chkData')
@ -416,25 +419,25 @@ describe 'EPP Contact', epp: true do
# expect(contact.css('chkData email').count).to eq(1)
# expect(contact.css('postalInfo name').present?).to be(true)
# end
end
# end
it 'does not display unassociated object without password' do
# xml = epp_xml.info(id: { value: @registrar1_contact.code })
# it 'does not display unassociated object without password' do
# xml = @epp_xml.info(id: { value: @registrar1_contact.code })
# response = epp_plain_request(xml, :xml, :registrar2)
# expect(response[:result_code]).to eq('2003')
# expect(response[:msg]).to eq('Required parameter missing: pw')
end
# end
it 'does not display unassociated object with wrong password' do
login_as :registrar2
xml = epp_xml.info(id: { value: @registrar1_contact.code },
authInfo: { pw: { value: 'wrong-pw' } })
response = epp_plain_request(xml, :xml)
# it 'does not display unassociated object with wrong password' do
# login_as :registrar2
# xml = @epp_xml.info(id: { value: @registrar1_contact.code },
# authInfo: { pw: { value: 'wrong-pw' } })
# response = epp_plain_request(xml, :xml)
response[:msg].should == 'Authentication error'
response[:result_code].should == '2200'
end
end
# response[:msg].should == 'Authentication error'
# response[:result_code].should == '2200'
# end
# end
context 'renew command' do
it 'returns 2101-unimplemented command' do
@ -445,16 +448,4 @@ describe 'EPP Contact', epp: true do
end
end
end
def registrar1
@registrar1 ||= Registrar.where(reg_no: '12345678').first || Fabricate(:registrar)
end
def registrar2
@registrar2 ||= Fabricate(:registrar, { name: 'registrar2', reg_no: '123' })
end
def epp_xml
@epp_xml ||= EppXml::Contact.new(cl_trid: 'ABC-12345')
end
end

View file

@ -1,19 +1,13 @@
require 'rails_helper'
describe 'EPP Domain', epp: true do
let(:epp_xml) { EppXml.new(cl_trid: 'ABC-12345') }
def registrar1
@registrar1 ||= Registrar.where(reg_no: '12345678').first || Fabricate(:registrar)
end
def registrar2
@registrar2 ||= Fabricate(:registrar, { name: 'registrar2', reg_no: '123' })
end
before(:all) do
Fabricate(:api_user, username: 'registrar1', registrar: registrar1)
Fabricate(:api_user, username: 'registrar2', registrar: registrar2)
create_settings
@epp_xml = EppXml::Domain.new(cl_trid: 'ABC-12345')
@registrar1 = Fabricate(:registrar1)
@registrar2 = Fabricate(:registrar2)
Fabricate(:api_user, username: 'registrar1', registrar: @registrar1)
Fabricate(:api_user, username: 'registrar2', registrar: @registrar2)
login_as :registrar1
@ -26,8 +20,6 @@ describe 'EPP Domain', epp: true do
Fabricate(:reserved_domain)
@uniq_no = proc { @i ||= 0; @i += 1 }
create_settings
end
it 'returns error if contact does not exists' do
@ -56,7 +48,7 @@ describe 'EPP Domain', epp: true do
log.request_object.should == 'domain'
log.request_successful.should == false
log.api_user_name.should == '1-api-registrar1'
log.api_user_registrar.should == 'Registrar OÜ'
log.api_user_registrar.should == 'registrar1'
log.request.should_not be_blank
log.response.should_not be_blank
end
@ -82,43 +74,43 @@ describe 'EPP Domain', epp: true do
end
context 'with citizen as an owner' do
it 'creates a domain' do
dn = next_domain_name
response = epp_plain_request(domain_create_xml({
name: { value: dn }
}), :xml)
d = Domain.last
response[:result_code].should == '1000'
response[:msg].should == 'Command completed successfully'
# it 'creates a domain' do
# dn = next_domain_name
# response = epp_plain_request(domain_create_xml({
# name: { value: dn }
# }), :xml)
# d = Domain.last
# response[:msg].should == 'Command completed successfully'
# response[:result_code].should == '1000'
cre_data = response[:parsed].css('creData')
# cre_data = response[:parsed].css('creData')
cre_data.css('name').text.should == dn
cre_data.css('crDate').text.should == d.created_at.to_time.utc.to_s
cre_data.css('exDate').text.should == d.valid_to.to_time.utc.to_s
# cre_data.css('name').text.should == dn
# cre_data.css('crDate').text.should == d.created_at.to_time.utc.to_s
# cre_data.css('exDate').text.should == d.valid_to.to_time.utc.to_s
response[:clTRID].should == 'ABC-12345'
# response[:clTRID].should == 'ABC-12345'
d.registrar.name.should == 'Registrar OÜ'
d.tech_contacts.count.should == 2
d.admin_contacts.count.should == 1
# d.registrar.name.should == 'Registrar 0'
# d.tech_contacts.count.should == 2
# d.admin_contacts.count.should == 1
d.nameservers.count.should == 2
d.auth_info.should_not be_empty
# d.nameservers.count.should == 2
# d.auth_info.should_not be_empty
d.dnskeys.count.should == 1
# d.dnskeys.count.should == 1
key = d.dnskeys.last
# key = d.dnskeys.last
key.ds_alg.should == 3
key.ds_key_tag.should_not be_blank
# key.ds_alg.should == 3
# key.ds_key_tag.should_not be_blank
key.ds_digest_type.should == Setting.ds_algorithm
key.flags.should == 257
key.protocol.should == 3
key.alg.should == 5
key.public_key.should == 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8'
end
# key.ds_digest_type.should == Setting.ds_algorithm
# key.flags.should == 257
# key.protocol.should == 3
# key.alg.should == 5
# key.public_key.should == 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8'
# end
it 'creates a domain with legal document' do
response = epp_plain_request(domain_create_xml_with_legal_doc, :xml)
@ -129,31 +121,32 @@ describe 'EPP Domain', epp: true do
d.legal_documents.count.should == 1
end
it 'creates ria.ee with valid ds record' do
xml = domain_create_xml({
name: { value: 'ria.ee' }
}, {
_anonymus: [
{ keyData: {
flags: { value: '257' },
protocol: { value: '3' },
alg: { value: '8' },
pubKey: { value: 'AwEAAaOf5+lz3ftsL+0CCvfJbhUF/NVsNh8BKo61oYs5fXVbuWDiH872 '\
'LC8uKDO92TJy7Q4TF9XMAKMMlf1GMAxlRspD749SOCTN00sqfWx1OMTu '\
'a28L1PerwHq7665oDJDKqR71btcGqyLKhe2QDvCdA0mENimF1NudX1BJ '\
'DDFi6oOZ0xE/0CuveB64I3ree7nCrwLwNs56kXC4LYoX3XdkOMKiJLL/ '\
'MAhcxXa60CdZLoRtTEW3z8/oBq4hEAYMCNclpbd6y/exScwBxFTdUfFk '\
'KsdNcmvai1lyk9vna0WQrtpYpHKMXvY9LFHaJxCOLR4umfeQ42RuTd82 lqfU6ClMeXs=' }
}
}
]
})
# it 'creates ria.ee with valid ds record' do
# xml = domain_create_xml({
# name: { value: 'ria.ee' }
# }, {
# _anonymus: [
# { keyData: {
# flags: { value: '257' },
# protocol: { value: '3' },
# alg: { value: '8' },
# pubKey: { value: 'AwEAAaOf5+lz3ftsL+0CCvfJbhUF/NVsNh8BKo61oYs5fXVbuWDiH872 '\
# 'LC8uKDO92TJy7Q4TF9XMAKMMlf1GMAxlRspD749SOCTN00sqfWx1OMTu '\
# 'a28L1PerwHq7665oDJDKqR71btcGqyLKhe2QDvCdA0mENimF1NudX1BJ '\
# 'DDFi6oOZ0xE/0CuveB64I3ree7nCrwLwNs56kXC4LYoX3XdkOMKiJLL/ '\
# 'MAhcxXa60CdZLoRtTEW3z8/oBq4hEAYMCNclpbd6y/exScwBxFTdUfFk '\
# 'KsdNcmvai1lyk9vna0WQrtpYpHKMXvY9LFHaJxCOLR4umfeQ42RuTd82 lqfU6ClMeXs=' }
# }
# }
# ]
# })
epp_plain_request(xml, :xml)
d = Domain.last
ds = d.dnskeys.last
ds.ds_digest.should == '0B62D1BC64EFD1EE652FB102BDF1011BF514CCD9A1A0CFB7472AEA3B01F38C92'
end
# epp_plain_request(xml, :xml)
# d = Domain.last
# ds = d.dnskeys.last
# ds.ds_digest.should == '0B62D1BC64EFD1EE652FB102BDF1011BF514CCD9A1A0CFB7472AEA3B01F38C92'
# end
it 'validates nameserver ipv4 when in same zone as domain' do
dn = next_domain_name
@ -178,19 +171,19 @@ describe 'EPP Domain', epp: true do
response[:msg].should == 'IPv4 is missing'
end
it 'does not create duplicate domain' do
dn = next_domain_name
epp_plain_request(domain_create_xml({
name: { value: dn }
}), :xml)
response = epp_plain_request(domain_create_xml({
name: { value: dn }
}), :xml)
# it 'does not create duplicate domain' do
# dn = next_domain_name
# epp_plain_request(domain_create_xml({
# name: { value: dn }
# }), :xml)
# response = epp_plain_request(domain_create_xml({
# name: { value: dn }
# }), :xml)
response[:result_code].should == '2302'
response[:msg].should == 'Domain name already exists'
response[:clTRID].should == 'ABC-12345'
end
# response[:msg].should == 'Domain name already exists'
# response[:result_code].should == '2302'
# response[:clTRID].should == 'ABC-12345'
# end
it 'does not create reserved domain' do
xml = domain_create_xml(name: { value: '1162.ee' })
@ -690,12 +683,12 @@ describe 'EPP Domain', epp: true do
end
context 'with valid domain' do
before(:each) { Fabricate(:domain, name: next_domain_name, registrar: registrar1, dnskeys: []) }
before(:each) { Fabricate(:domain, name: next_domain_name, registrar: @registrar1, dnskeys: []) }
let(:domain) { Domain.last }
### TRANSFER ###
it 'transfers a domain' do
domain.registrar = registrar1
domain.registrar = @registrar1
domain.save
pw = domain.auth_info
@ -720,7 +713,7 @@ describe 'EPP Domain', epp: true do
trn_data.css('acDate').text.should == dtl.transferred_at.to_time.utc.to_s
trn_data.css('exDate').text.should == domain.valid_to.to_time.utc.to_s
domain.registrar.should == registrar2
domain.registrar.should == @registrar2
Setting.transfer_wait_time = 1
@ -747,7 +740,7 @@ describe 'EPP Domain', epp: true do
trn_data.css('acID').text.should == '123'
trn_data.css('exDate').text.should == domain.valid_to.to_time.utc.to_s
domain.registrar.should == registrar2
domain.registrar.should == @registrar2
# should return same data if pending already
response = epp_plain_request(xml, :xml)
@ -762,12 +755,12 @@ describe 'EPP Domain', epp: true do
trn_data.css('acID').text.should == '123'
trn_data.css('exDate').text.should == domain.valid_to.to_time.utc.to_s
domain.registrar.should == registrar2
domain.registrar.should == @registrar2
# should show up in other registrar's poll
response = login_as :registrar2 do
epp_plain_request(epp_xml.session.poll, :xml)
epp_plain_request(@epp_xml.session.poll, :xml)
end
response[:msg].should == 'Command completed successfully; ack to dequeue'
@ -777,7 +770,7 @@ describe 'EPP Domain', epp: true do
msg_q.first['id'].should_not be_blank
msg_q.first['count'].should == '1'
xml = epp_xml.session.poll(poll: {
xml = @epp_xml.session.poll(poll: {
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
})
@ -839,8 +832,8 @@ describe 'EPP Domain', epp: true do
domain.domain_transfers.create({
status: DomainTransfer::PENDING,
transfer_requested_at: Time.zone.now,
transfer_to: registrar2,
transfer_from: registrar1
transfer_to: @registrar2,
transfer_from: @registrar1
})
xml = domain_transfer_xml({
@ -867,8 +860,8 @@ describe 'EPP Domain', epp: true do
domain.domain_transfers.create({
status: DomainTransfer::PENDING,
transfer_requested_at: Time.zone.now,
transfer_to: registrar2,
transfer_from: registrar1
transfer_to: @registrar2,
transfer_from: @registrar1
})
pw = domain.auth_info
@ -902,8 +895,8 @@ describe 'EPP Domain', epp: true do
domain.domain_transfers.create({
status: DomainTransfer::PENDING,
transfer_requested_at: Time.zone.now,
transfer_to: registrar2,
transfer_from: registrar1
transfer_to: @registrar2,
transfer_from: @registrar1
})
xml = domain_transfer_xml({
@ -1272,7 +1265,7 @@ describe 'EPP Domain', epp: true do
### RENEW ###
it 'renews a domain' do
exp_date = (Date.today + 1.year)
xml = epp_xml.domain.renew(
xml = @epp_xml.domain.renew(
name: { value: domain.name },
curExpDate: { value: exp_date.to_s },
period: { value: '1', attrs: { unit: 'y' } }
@ -1286,7 +1279,7 @@ describe 'EPP Domain', epp: true do
end
it 'returns an error when given and current exp dates do not match' do
xml = epp_xml.domain.renew(
xml = @epp_xml.domain.renew(
name: { value: domain.name },
curExpDate: { value: '2200-08-07' },
period: { value: '1', attrs: { unit: 'y' } }
@ -1300,7 +1293,7 @@ describe 'EPP Domain', epp: true do
it 'returns an error when period is invalid' do
exp_date = (Date.today + 1.year)
xml = epp_xml.domain.renew(
xml = @epp_xml.domain.renew(
name: { value: domain.name },
curExpDate: { value: exp_date.to_s },
period: { value: '4', attrs: { unit: 'y' } }
@ -1422,7 +1415,7 @@ describe 'EPP Domain', epp: true do
end
it 'validates legal document type in info request' do
xml = epp_xml.domain.info({
xml = @epp_xml.domain.info({
name: { value: domain.name }
}, {
_anonymus: [
@ -1436,7 +1429,7 @@ describe 'EPP Domain', epp: true do
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Attribute is invalid: type'
xml = epp_xml.domain.info({
xml = @epp_xml.domain.info({
name: { value: domain.name }
}, {
_anonymus: [
@ -1451,7 +1444,7 @@ describe 'EPP Domain', epp: true do
end
it 'saves legal document on info request' do
xml = epp_xml.domain.info({
xml = @epp_xml.domain.info({
name: { value: domain.name }
}, {
_anonymus: [
@ -1473,7 +1466,7 @@ describe 'EPP Domain', epp: true do
### DELETE ###
it 'deletes domain' do
response = epp_plain_request(epp_xml.domain.delete({
response = epp_plain_request(@epp_xml.domain.delete({
name: { value: domain.name }
}, {
_anonymus: [
@ -1492,7 +1485,7 @@ describe 'EPP Domain', epp: true do
it 'does not delete domain with specific status' do
domain.domain_statuses.create(value: DomainStatus::CLIENT_DELETE_PROHIBITED)
response = epp_plain_request(epp_xml.domain.delete({
response = epp_plain_request(@epp_xml.domain.delete({
name: { value: domain.name }
}, {
_anonymus: [
@ -1508,7 +1501,7 @@ describe 'EPP Domain', epp: true do
end
it 'does not delete domain without legal document' do
response = epp_plain_request(epp_xml.domain.delete(name: { value: 'example.ee' }), :xml)
response = epp_plain_request(@epp_xml.domain.delete(name: { value: 'example.ee' }), :xml)
response[:result_code].should == '2003'
response[:msg].should == 'Required parameter missing: extension > extdata > legalDocument'
end
@ -1589,5 +1582,4 @@ describe 'EPP Domain', epp: true do
reason.text.should == 'invalid format'
end
end
end

View file

@ -1,29 +1,24 @@
require 'rails_helper'
describe 'EPP Keyrelay', epp: true do
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(:epp_xml) { EppXml::Keyrelay.new }
before(:each) { create_settings }
before(:all) do
@elkdata = Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' })
@zone = Fabricate(:registrar)
Fabricate(:api_user, username: 'zone', registrar: @zone)
Fabricate(:api_user, username: 'elkdata', registrar: @elkdata)
create_settings
@registrar1 = Fabricate(:registrar1)
@registrar2 = Fabricate(:registrar2)
@domain = Fabricate(:domain, registrar: @registrar2)
@epp_xml = EppXml::Keyrelay.new
@uniq_no = proc { @i ||= 0; @i += 1 }
Fabricate(:api_user, username: 'registrar1', registrar: @registrar1)
Fabricate(:api_user, username: 'registrar2', registrar: @registrar2)
login_as :registrar1
end
before(:each) { Fabricate(:domain, name: next_domain_name, registrar: @zone, dnskeys: [Fabricate.build(:dnskey)]) }
let(:domain) { Domain.last }
it 'makes a keyrelay request' do
ApiLog::EppLog.delete_all
xml = epp_xml.keyrelay({
name: { value: domain.name },
xml = @epp_xml.keyrelay({
name: { value: @domain.name },
keyData: {
flags: { value: '256' },
protocol: { value: '3' },
@ -31,72 +26,53 @@ describe 'EPP Keyrelay', epp: true do
pubKey: { value: 'cmlraXN0aGViZXN0' }
},
authInfo: {
pw: { value: domain.auth_info }
pw: { value: @domain.auth_info }
},
expiry: {
relative: { value: 'P1M13D' }
}
})
response = epp_request(xml, :xml, :elkdata)
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
@zone.messages.queued.count.should == 1
@registrar2.messages.queued.count.should == 1
log = ApiLog::EppLog.all
log.length.should == 4
log[0].request_command.should == 'hello'
log[0].request_successful.should == true
log[1].request_command.should == 'login'
log[1].request_successful.should == true
log[1].api_user_name.should == 'elkdata'
log[1].api_user_registrar.should == 'Elkdata'
log[2].request_command.should == 'keyrelay'
log[2].request_object.should == 'keyrelay'
log[2].request_successful.should == true
log[2].api_user_name.should == 'elkdata'
log[2].api_user_registrar.should == 'Elkdata'
log[2].request.should_not be_blank
log[2].response.should_not be_blank
log[3].request_command.should == 'logout'
log[3].request_successful.should == true
log[3].api_user_name.should == 'elkdata'
log[3].api_user_registrar.should == 'Elkdata'
log = ApiLog::EppLog.last
log.request_command.should == 'keyrelay'
log.request_successful.should == true
log.api_user_name.should == '1-api-registrar1'
end
it 'returns an error when parameters are missing' do
msg_count = @zone.messages.queued.count
xml = epp_xml.keyrelay({
name: { value: domain.name },
msg_count = @registrar2.messages.queued.count
xml = @epp_xml.keyrelay({
name: { value: @domain.name },
keyData: {
protocol: { value: '3' },
alg: { value: '8' },
pubKey: { value: 'cmlraXN0aGViZXN0' }
},
authInfo: {
pw: { value: domain.auth_info }
pw: { value: @domain.auth_info }
},
expiry: {
relative: { value: 'Invalid Expiry' }
}
})
response = epp_request(xml, :xml, :elkdata)
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Required parameter missing: keyrelay > keyData > flags'
@zone.messages.queued.count.should == msg_count
@registrar2.messages.queued.count.should == msg_count
end
it 'returns an error on invalid relative expiry' do
msg_count = @zone.messages.queued.count
xml = epp_xml.keyrelay({
name: { value: domain.name },
msg_count = @registrar2.messages.queued.count
xml = @epp_xml.keyrelay({
name: { value: @domain.name },
keyData: {
flags: { value: '256' },
protocol: { value: '3' },
@ -104,24 +80,24 @@ describe 'EPP Keyrelay', epp: true do
pubKey: { value: 'cmlraXN0aGViZXN0' }
},
authInfo: {
pw: { value: domain.auth_info }
pw: { value: @domain.auth_info }
},
expiry: {
relative: { value: 'Invalid Expiry' }
}
})
response = epp_request(xml, :xml, :elkdata)
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Expiry relative must be compatible to ISO 8601'
response[:results][0][:value].should == 'Invalid Expiry'
@zone.messages.queued.count.should == msg_count
@registrar2.messages.queued.count.should == msg_count
end
it 'returns an error on invalid absolute expiry' do
msg_count = @zone.messages.queued.count
xml = epp_xml.keyrelay({
name: { value: domain.name },
msg_count = @registrar2.messages.queued.count
xml = @epp_xml.keyrelay({
name: { value: @domain.name },
keyData: {
flags: { value: '256' },
protocol: { value: '3' },
@ -129,24 +105,24 @@ describe 'EPP Keyrelay', epp: true do
pubKey: { value: 'cmlraXN0aGViZXN0' }
},
authInfo: {
pw: { value: domain.auth_info }
pw: { value: @domain.auth_info }
},
expiry: {
absolute: { value: 'Invalid Absolute' }
}
})
response = epp_request(xml, :xml, :elkdata)
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Expiry absolute must be compatible to ISO 8601'
response[:results][0][:value].should == 'Invalid Absolute'
@zone.messages.queued.count.should == msg_count
@registrar2.messages.queued.count.should == msg_count
end
it 'does not allow both relative and absolute' do
msg_count = @zone.messages.queued.count
xml = epp_xml.keyrelay({
name: { value: domain.name },
msg_count = @registrar2.messages.queued.count
xml = @epp_xml.keyrelay({
name: { value: @domain.name },
keyData: {
flags: { value: '256' },
protocol: { value: '3' },
@ -154,7 +130,7 @@ describe 'EPP Keyrelay', epp: true do
pubKey: { value: 'cmlraXN0aGViZXN0' }
},
authInfo: {
pw: { value: domain.auth_info }
pw: { value: @domain.auth_info }
},
expiry: {
relative: { value: 'P1D' },
@ -162,16 +138,16 @@ describe 'EPP Keyrelay', epp: true do
}
})
response = epp_request(xml, :xml, :elkdata)
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Exactly one parameter required: keyrelay > expiry > relative OR '\
'keyrelay > expiry > absolute'
@zone.messages.queued.count.should == msg_count
@registrar2.messages.queued.count.should == msg_count
end
it 'saves legal document with keyrelay' do
xml = epp_xml.keyrelay({
name: { value: domain.name },
xml = @epp_xml.keyrelay({
name: { value: @domain.name },
keyData: {
flags: { value: '256' },
protocol: { value: '3' },
@ -179,7 +155,7 @@ describe 'EPP Keyrelay', epp: true do
pubKey: { value: 'cmlraXN0aGViZXN0' }
},
authInfo: {
pw: { value: domain.auth_info }
pw: { value: @domain.auth_info }
},
expiry: {
relative: { value: 'P1D' }
@ -193,7 +169,7 @@ describe 'EPP Keyrelay', epp: true do
]
})
response = epp_request(xml, :xml, :elkdata)
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Command completed successfully'
docs = Keyrelay.last.legal_documents
@ -203,8 +179,8 @@ describe 'EPP Keyrelay', epp: true do
end
it 'validates legal document types' do
xml = epp_xml.keyrelay({
name: { value: domain.name },
xml = @epp_xml.keyrelay({
name: { value: @domain.name },
keyData: {
flags: { value: '256' },
protocol: { value: '3' },
@ -212,7 +188,7 @@ describe 'EPP Keyrelay', epp: true do
pubKey: { value: 'cmlraXN0aGViZXN0' }
},
authInfo: {
pw: { value: domain.auth_info }
pw: { value: @domain.auth_info }
},
expiry: {
relative: { value: 'P1D' }
@ -226,7 +202,7 @@ describe 'EPP Keyrelay', epp: true do
]
})
response = epp_request(xml, :xml, :elkdata)
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Attribute is invalid: type'
end
end

View file

@ -34,7 +34,7 @@ describe 'EPP Poll', epp: true do
log.request_object.should == 'poll'
log.request_successful.should == true
log.api_user_name.should == '1-api-registrar1'
log.api_user_registrar.should == 'Registrar '
log.api_user_registrar.should == 'Registrar 0'
log.request.should_not be_blank
log.response.should_not be_blank
end

View file

@ -2,14 +2,14 @@ require 'rails_helper'
describe 'EPP Session', epp: true do
before :all do
@api_user = Fabricate(:api_user)
@api_user = Fabricate(:gitlab_api_user)
@epp_xml = EppXml.new(cl_trid: 'ABC-12345')
@login_xml_cache = @epp_xml.session.login(clID: { value: 'gitlab' }, pw: { value: 'ghyt9e4fu' })
end
context 'when not connected' do
it 'greets client upon connection' do
server.close_connection
response = Nokogiri::XML(server.open_connection)
response.css('epp svID').text.should == 'EPP server (EIS)'
puts "RESPONSE:\n\n```xml\n#{response}```\n\n" if ENV['EPP_DOC']
@ -51,6 +51,11 @@ describe 'EPP Session', epp: true do
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
response[:clTRID].should == 'ABC-12345'
log = ApiLog::EppLog.last
log.request_command.should == 'login'
log.request_successful.should == true
log.api_user_name.should == '1-api-gitlab'
end
it 'does not log in twice' do
@ -67,7 +72,6 @@ describe 'EPP Session', epp: true do
log.request_command.should == 'login'
log.request_successful.should == false
log.api_user_name.should == '1-api-gitlab'
log.api_user_registrar.should == 'Registrar OÜ'
end
it 'logs out epp user' do