Remove outdated specs

#206
This commit is contained in:
Artur Beljajev 2016-10-25 02:35:58 +03:00
parent 3cca4c78cc
commit c88d21ab1d
55 changed files with 16 additions and 7287 deletions

View file

@ -1,955 +0,0 @@
require 'rails_helper'
describe 'EPP Contact', epp: true do
before :all do
@xsd = Nokogiri::XML::Schema(File.read('lib/schemas/contact-eis-1.0.xsd'))
Fabricate(:zonefile_setting, origin: 'ee')
Fabricate(:zonefile_setting, origin: 'pri.ee')
Fabricate(:zonefile_setting, origin: 'med.ee')
Fabricate(:zonefile_setting, origin: 'fie.ee')
Fabricate(:zonefile_setting, origin: 'com.ee')
@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 :registrar1
@contact = Fabricate(:contact, registrar: @registrar1)
@extension = {
ident: {
value: '37605030299',
attrs: { type: 'priv', cc: 'EE' }
},
legalDocument: {
value: 'dGVzdCBmYWlsCg==',
attrs: { type: 'pdf' }
}
}
@update_extension = {
legalDocument: {
value: 'dGVzdCBmYWlsCg==',
attrs: { type: 'pdf' }
}
}
end
context 'with valid user' do
context 'create command' do
def create_request(overwrites = {}, extension = {}, options = {})
extension = @extension if extension.blank?
defaults = {
id: nil,
postalInfo: {
name: { value: 'John Doe' },
org: nil,
addr: {
street: { value: '123 Example' },
city: { value: 'Tallinn' },
pc: { value: '123456' },
cc: { value: 'EE' }
}
},
voice: { value: '+372.1234567' },
fax: nil,
email: { value: 'test@example.example' },
authInfo: nil
}
create_xml = @epp_xml.create(defaults.deep_merge(overwrites), extension)
epp_plain_request(create_xml, options)
end
it 'fails if request xml is missing' do
response = epp_plain_request(@epp_xml.create)
response[:results][0][:msg].should ==
"Element '{https://epp.tld.ee/schema/contact-eis-1.0.xsd}create': Missing child element(s). "\
"Expected is one of ( {https://epp.tld.ee/schema/contact-eis-1.0.xsd}id, "\
"{https://epp.tld.ee/schema/contact-eis-1.0.xsd}postalInfo )."
response[:results][0][:result_code].should == '2001'
end
it 'successfully creates a contact' do
response = create_request
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
@contact = Contact.last
@contact.registrar.should == @registrar1
@registrar1.api_users.should include(@contact.creator)
@contact.ident.should == '37605030299'
@contact.street.should == '123 Example'
@contact.legal_documents.count.should == 1
@contact.auth_info.length.should > 0
log = ApiLog::EppLog.last
log.request_command.should == 'create'
log.request_object.should == 'contact'
log.request_successful.should == true
log.api_user_name.should == 'registrar1'
log.api_user_registrar.should == 'registrar1'
end
it 'creates a contact with custom auth info' do
response = create_request({
authInfo: { pw: { value: 'custompw' } }
})
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
@contact = Contact.last
@contact.auth_info.should == 'custompw'
end
it 'successfully saves ident type with legal document' do
extension = {
ident: {
value: '1990-22-12',
attrs: { type: 'birthday', cc: 'US' }
},
legalDocument: {
value: 'dGVzdCBmYWlsCg==',
attrs: { type: 'pdf' }
}
}
response = create_request({}, extension)
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
@contact = Contact.last
@contact.ident_type.should == 'birthday'
@contact.legal_documents.size.should == 1
end
it 'successfully adds registrar' do
response = create_request
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
Contact.last.registrar.should == @registrar1
end
it 'returns result data upon success' do
response = create_request
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
id = response[:parsed].css('resData creData id').first
cr_date = response[:parsed].css('resData creData crDate').first
id.text.length.should == 15
# 5 seconds for what-ever weird lag reasons might happen
cr_date.text.in_time_zone.utc.should be_within(5).of(Time.zone.now)
end
it 'should return email issue' do
response = create_request(email: { value: 'not@valid' })
response[:msg].should == 'Email is invalid [email]'
response[:result_code].should == '2005'
end
it 'should add registrar prefix for code when missing' do
response = create_request({ id: { value: 'abc12345' } })
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
Contact.last.code.should == 'FIRST0:ABC12345'
end
it 'should add registrar prefix for code when missing' do
response = create_request({ id: { value: 'abc:ABC:12345' } })
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
Contact.last.code.should == 'FIRST0:ABC:ABC:12345'
end
it 'should not allow spaces in custom code' do
response = create_request({ id: { value: 'abc 123' } })
response[:msg].should == 'is invalid [code]'
response[:result_code].should == '2005'
end
it 'should not strange characters in custom code' do
response = create_request({ id: { value: '33&$@@' } })
response[:msg].should == 'is invalid [code]'
response[:result_code].should == '2005'
end
it 'should not strange characters in custom code' do
long_str = 'a' * 1000
response = create_request({ id: { value: long_str } })
response[:msg].should == 'Contact code is too long, max 100 characters [code]'
response[:result_code].should == '2005'
end
it 'should not saves ident type with wrong country code' do
extension = {
ident: {
value: '1990-22-12',
attrs: { type: 'birthday', cc: 'WRONG' }
}
}
response = create_request({}, extension)
response[:msg].should == "Element '{https://epp.tld.ee/schema/eis-1.0.xsd}ident', "\
"attribute 'cc': [facet 'maxLength'] The value 'WRONG' has a length of '5'; this exceeds "\
"the allowed maximum length of '2'."
response[:result_code].should == '2001'
end
it 'should return country missing' do
extension = {
ident: {
value: '1990-22-12',
attrs: { type: 'birthday' }
}
}
response = create_request({}, extension)
response[:msg].should == "Element '{https://epp.tld.ee/schema/eis-1.0.xsd}ident': The attribute "\
"'cc' is required but missing."
response[:result_code].should == '2001'
end
it 'should return country missing' do
extension = {
ident: {
value: '1990-22-12'
}
}
response = create_request({}, extension)
response[:msg].should == "Element '{https://epp.tld.ee/schema/eis-1.0.xsd}ident': The attribute "\
"'type' is required but missing."
response[:result_code].should == '2001'
end
it 'should add registrar prefix for code when legacy prefix present' do
response = create_request({ id: { value: 'CID:FIRST0:abc:ABC:NEW:12345' } })
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
Contact.last.code.should == 'FIRST0:CID:FIRST0:ABC:ABC:NEW:12345'
end
it 'should not remove suffix CID' do
response = create_request({ id: { value: 'CID:FIRST0:abc:CID:ABC:NEW:12345' } })
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
Contact.last.code.should == 'FIRST0:CID:FIRST0:ABC:CID:ABC:NEW:12345'
end
it 'should not add registrar prefix for code when prefix present' do
response = create_request({ id: { value: 'FIRST0:abc22' } })
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
Contact.last.code.should == 'FIRST0:ABC22'
end
it 'should add registrar prefix for code does not match exactly to prefix' do
response = create_request({ id: { value: 'cid2:first0:abc:ABC:11111' } })
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
Contact.last.code.should == 'FIRST0:CID2:FIRST0:ABC:ABC:11111'
end
it 'should ignore custom code when only contact prefix given' do
response = create_request({ id: { value: 'CID:FIRST0' } })
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
Contact.last.code.should =~ /FIRST0:..../
end
it 'should generate server id when id is empty' do
response = create_request({ id: nil })
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
Contact.last.code.should_not == 'registrar1:'
end
it 'should generate server id when id is empty' do
response = create_request
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
Contact.last.code.should_not == 'registrar1:'
end
it 'should return parameter value policy error for org' do
response = create_request({ postalInfo: { org: { value: 'should not save' } } })
response[:msg].should ==
'Parameter value policy error. Org must be blank: postalInfo > org [org]'
response[:result_code].should == '2306'
Contact.last.org_name.should == nil
end
it 'should return parameter value policy error for fax' do
response = create_request({ fax: { value: 'should not save' } })
response[:msg].should ==
'Parameter value policy error. Fax must be blank: fax [fax]'
response[:result_code].should == '2306'
Contact.last.fax.should == nil
end
end
context 'update command' do
before :all do
@contact =
Fabricate(
:contact,
registrar: @registrar1,
email: 'not_updated@test.test',
code: 'FIRST0:SH8013'
)
end
def update_request(overwrites = {}, extension = {}, options = {})
extension = @update_extension if extension.blank?
defaults = {
id: { value: 'asd123123er' },
chg: {
postalInfo: {
name: { value: 'John Doe Edited' }
},
voice: { value: '+372.7654321' },
fax: nil,
email: { value: 'edited@example.example' },
authInfo: { pw: { value: 'password' } }
}
}
update_xml = @epp_xml.update(defaults.deep_merge(overwrites), extension)
epp_plain_request(update_xml, options)
end
it 'fails if request is invalid' do
response = epp_plain_request(@epp_xml.update)
response[:results][0][:msg].should ==
"Element '{https://epp.tld.ee/schema/contact-eis-1.0.xsd}update': Missing child element(s). "\
"Expected is ( {https://epp.tld.ee/schema/contact-eis-1.0.xsd}id )."
end
it 'returns error if obj doesnt exist' do
response = update_request({ id: { value: 'not-exists' } })
response[:msg].should == 'Object does not exist'
response[:result_code].should == '2303'
response[:results].count.should == 1
end
it 'is succesful' do
response = update_request({ id: { value: 'FIRST0:SH8013' } })
response[:msg].should == 'Command completed successfully'
@contact.reload
@contact.name.should == 'John Doe Edited'
@contact.email.should == 'edited@example.example'
end
it 'is succesful for own contact without password' do
without_password = {
id: { value: 'FIRST0:SH8013' },
chg: {
postalInfo: {
name: { value: 'John Doe Edited' }
}
}
}
update_xml = @epp_xml.update(without_password)
response = epp_plain_request(update_xml, :xml)
response[:msg].should == 'Command completed successfully'
@contact.reload
@contact.name.should == 'John Doe Edited'
end
it 'should update other contact with correct password' do
login_as :registrar2 do
response = update_request({ id: { value: 'FIRST0:SH8013' } })
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
end
end
it 'should not update other contact without password' do
login_as :registrar2 do
without_password = {
id: { value: 'FIRST0:SH8013' },
chg: {
postalInfo: {
name: { value: 'John Doe Edited' }
}
}
}
update_xml = @epp_xml.update(without_password)
response = epp_plain_request(update_xml, :xml)
response[:msg].should == 'Authorization error'
@contact.reload
@contact.name.should == 'John Doe Edited'
end
end
it 'returns phone and email error' do
response = update_request({
id: { value: 'FIRST0:SH8013' },
chg: {
voice: { value: '123213' },
email: { value: 'wrong' }
}
})
response[:results][0][:msg].should == 'Phone nr is invalid [phone]'
response[:results][0][:result_code].should == '2005'
response[:results][1][:msg].should == 'Email is invalid [email]'
response[:results][1][:result_code].should == '2005'
end
it 'should return email issue' do
response = update_request({
id: { value: 'FIRST0:SH8013' },
chg: {
email: { value: 'legacy@wrong' }
}
})
response[:msg].should == 'Email is invalid [email]'
response[:result_code].should == '2005'
end
it 'should not update code with custom string' do
response = update_request(
{
id: { value: 'FIRST0:SH8013' },
chg: {
id: { value: 'notpossibletoupdate' }
}
}, {}
)
response[:msg].should == "Element '{https://epp.tld.ee/schema/contact-eis-1.0.xsd}id': "\
"This element is not expected."
response[:result_code].should == '2001'
@contact.reload.code.should == 'FIRST0:SH8013'
end
it 'should not be able to update ident' do
extension = {
ident: {
value: '1990-22-12',
attrs: { type: 'birthday', cc: 'US' }
},
legalDocument: {
value: 'dGVzdCBmYWlsCg==',
attrs: { type: 'pdf' }
}
}
response = update_request({ id: { value: 'FIRST0:SH8013' } }, extension)
response[:msg].should ==
'Parameter value policy error. Update of ident data not allowed [ident]'
response[:result_code].should == '2306'
Contact.find_by(code: 'FIRST0:SH8013').ident_type.should == 'priv'
end
it 'should return parameter value policy errror for org update' do
response = update_request({
id: { value: 'FIRST0:SH8013' },
chg: {
postalInfo: { org: { value: 'should not save' } }
}
})
response[:msg].should ==
'Parameter value policy error. Org must be blank: postalInfo > org [org]'
response[:result_code].should == '2306'
Contact.find_by(code: 'FIRST0:SH8013').org_name.should == nil
end
it 'should return parameter value policy errror for fax update' do
response = update_request({
id: { value: 'FIRST0:SH8013' },
chg: {
fax: { value: 'should not save' }
}
})
response[:msg].should ==
'Parameter value policy error. Fax must be blank: fax [fax]'
response[:result_code].should == '2306'
Contact.find_by(code: 'FIRST0:SH8013').fax.should == nil
end
it 'does not allow to edit statuses if policy forbids it' do
Setting.client_status_editing_enabled = false
xml = @epp_xml.update({
id: { value: 'FIRST0:SH8013' },
add: [{
_anonymus: [
{ status: { value: 'Payment overdue.', attrs: { s: 'clientDeleteProhibited', lang: 'en' } } },
{ status: { value: '', attrs: { s: 'clientUpdateProhibited' } } }
]
}]
})
response = epp_plain_request(xml)
response[:results][0][:msg].should == "Parameter value policy error. Client-side object status "\
"management not supported: status [status]"
response[:results][0][:result_code].should == '2306'
Setting.client_status_editing_enabled = true
end
it 'should update auth info' do
xml = @epp_xml.update({
id: { value: 'FIRST0:SH8013' },
chg: {
authInfo: { pw: { value: 'newpassword' } }
}
})
response = epp_plain_request(xml, :xml)
response[:results][0][:msg].should == 'Command completed successfully'
response[:results][0][:result_code].should == '1000'
contact = Contact.find_by(code: 'FIRST0:SH8013')
contact.auth_info.should == 'newpassword'
end
it 'should add value voice value' do
xml = @epp_xml.update({
id: { value: 'FIRST0:SH8013' },
chg: {
voice: { value: '+372.11111111' },
authInfo: { pw: { value: 'password' } }
}
})
response = epp_plain_request(xml, :xml)
response[:results][0][:msg].should == 'Command completed successfully'
response[:results][0][:result_code].should == '1000'
contact = Contact.find_by(code: 'FIRST0:SH8013')
contact.phone.should == '+372.11111111'
contact.update_attribute(:phone, '+372.7654321') # restore default value
end
it 'should return error when add attributes phone value is empty' do
phone = Contact.find_by(code: 'FIRST0:SH8013').phone
xml = @epp_xml.update({
id: { value: 'FIRST0:SH8013' },
chg: {
voice: { value: '' },
email: { value: 'example@example.ee' },
authInfo: { pw: { value: 'password' } }
}
})
response = epp_plain_request(xml, :xml)
response[:results][0][:msg].should == 'Required parameter missing - phone [phone]'
response[:results][0][:result_code].should == '2003'
Contact.find_by(code: 'FIRST0:SH8013').phone.should == phone # aka not changed
end
it 'should not allow to remove required voice attribute' do
contact = Contact.find_by(code: 'FIRST0:SH8013')
phone = contact.phone
xml = @epp_xml.update({
id: { value: 'FIRST0:SH8013' },
chg: {
voice: { value: '' },
authInfo: { pw: { value: 'password' } }
}
})
response = epp_plain_request(xml, :xml)
response[:results][0][:msg].should == 'Required parameter missing - phone [phone]'
response[:results][0][:result_code].should == '2003'
contact = Contact.find_by(code: 'FIRST0:SH8013')
contact.phone.should == phone
end
it 'should return general policy error when updating org' do
xml = @epp_xml.update({
id: { value: 'FIRST0:SH8013' },
chg: {
postalInfo: {
org: { value: 'shouldnot' }
},
authInfo: { pw: { value: 'password' } }
}
})
response = epp_plain_request(xml)
response[:results][0][:msg].should ==
'Parameter value policy error. Org must be blank: postalInfo > org [org]'
response[:results][0][:result_code].should == '2306'
end
it 'does not allow to edit statuses if policy forbids it' do
Setting.client_status_editing_enabled = false
xml = @epp_xml.update({
id: { value: 'FIRST0:SH8013' },
add: [{
_anonymus: [
{ status: { value: '', attrs: { s: 'clientUpdateProhibited' } } }
]
}]
})
response = epp_plain_request(xml)
response[:results][0][:msg].should == "Parameter value policy error. Client-side object status "\
"management not supported: status [status]"
response[:results][0][:result_code].should == '2306'
Setting.client_status_editing_enabled = true
end
end
context 'delete command' do
before do
@contact = Fabricate(:contact, registrar: @registrar1)
end
def delete_request(overwrites = {})
defaults = {
id: { value: @contact.code },
authInfo: { pw: { value: @contact.auth_info } }
}
delete_xml = @epp_xml.delete(defaults.deep_merge(overwrites), @extension)
epp_plain_request(delete_xml, :xml)
end
it 'fails if request is invalid' do
response = epp_plain_request(@epp_xml.delete)
response[:results][0][:msg].should ==
"Element '{https://epp.tld.ee/schema/contact-eis-1.0.xsd}delete': Missing child element(s). "\
"Expected is ( {https://epp.tld.ee/schema/contact-eis-1.0.xsd}id )."
response[:results][0][:result_code].should == '2001'
response[:results].count.should == 1
end
it 'returns error if obj doesnt exist' do
response = delete_request({ id: { value: 'not-exists' } })
response[:msg].should == 'Object does not exist'
response[:result_code].should == '2303'
response[:results].count.should == 1
end
it 'deletes contact' do
response = delete_request
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
response[:clTRID].should == 'ABC-12345'
Contact.find_by_id(@contact.id).should == nil
end
it 'deletes own contact even with wrong password' do
response = delete_request({ authInfo: { pw: { value: 'wrong password' } } })
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
response[:clTRID].should == 'ABC-12345'
Contact.find_by_id(@contact.id).should == nil
end
it 'deletes own contact even without password' do
delete_xml = @epp_xml.delete({ id: { value: @contact.code } })
response = epp_plain_request(delete_xml, :xml)
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
response[:clTRID].should == 'ABC-12345'
Contact.find_by_id(@contact.id).should == nil
end
it 'fails if contact has associated domain' do
@domain = Fabricate(:domain, registrar: @registrar1, registrant: Registrant.find(@contact.id))
@domain.registrant.present?.should == true
response = delete_request
response[:msg].should == 'Object association prohibits operation [domains]'
response[:result_code].should == '2305'
response[:results].count.should == 1
@domain.registrant.present?.should == true
end
it 'should delete when not owner but with correct password' do
login_as :registrar2 do
response = delete_request
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
response[:clTRID].should == 'ABC-12345'
Contact.find_by_id(@contact.id).should == nil
end
end
it 'should not delete when not owner without password' do
login_as :registrar2 do
delete_xml = @epp_xml.delete({ id: { value: @contact.code } })
response = epp_plain_request(delete_xml, :xml)
response[:msg].should == 'Authorization error'
response[:result_code].should == '2201'
response[:results].count.should == 1
end
end
it 'should not delete when not owner with wrong password' do
login_as :registrar2 do
response = delete_request({ authInfo: { pw: { value: 'wrong password' } } })
response[:msg].should == 'Authorization error'
response[:result_code].should == '2201'
response[:results].count.should == 1
end
end
end
context 'check command' do
def check_request(overwrites = {})
defaults = {
id: { value: @contact.code },
authInfo: { pw: { value: @contact.auth_info } }
}
xml = @epp_xml.check(defaults.deep_merge(overwrites))
epp_plain_request(xml, :xml)
end
it 'fails if request is invalid' do
response = epp_plain_request(@epp_xml.check)
response[:results][0][:msg].should ==
"Element '{https://epp.tld.ee/schema/contact-eis-1.0.xsd}check': Missing child element(s). "\
"Expected is ( {https://epp.tld.ee/schema/contact-eis-1.0.xsd}id )."
response[:results][0][:result_code].should == '2001'
response[:results].count.should == 1
end
it 'returns info about contact availability' do
contact = Fabricate(:contact, code: 'check-1234')
contact.code.should == 'FIXED:CHECK-1234'
response = epp_plain_request(check_multiple_contacts_xml, :xml)
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
ids = response[:parsed].css('resData chkData id')
ids[0].attributes['avail'].text.should == '0'
ids[1].attributes['avail'].text.should == '1'
ids[0].text.should == 'FIXED:CHECK-1234'
ids[1].text.should == 'check-4321'
end
it 'should support legacy CID farmat' do
contact = Fabricate(:contact, code: 'check-LEGACY')
contact.code.should == 'FIXED:CHECK-LEGACY'
response = epp_plain_request(check_multiple_legacy_contacts_xml, :xml)
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
ids = response[:parsed].css('resData chkData id')
ids[0].text.should == 'FIXED:CHECK-LEGACY'
ids[1].text.should == 'CID:FIXED:CHECK-LEGACY'
ids[0].attributes['avail'].text.should == '0'
ids[1].attributes['avail'].text.should == '1'
end
end
context 'info command' do
def info_request(overwrites = {}, options = {})
defaults = {
id: { value: @contact.code },
authInfo: { pw: { value: @contact.auth_info } }
}
xml = @epp_xml.info(defaults.deep_merge(overwrites))
epp_plain_request(xml, options)
end
it 'fails if request invalid' do
response = epp_plain_request(@epp_xml.info)
response[:results][0][:msg].should ==
"Element '{https://epp.tld.ee/schema/contact-eis-1.0.xsd}info': Missing child element(s). "\
"Expected is ( {https://epp.tld.ee/schema/contact-eis-1.0.xsd}id )."
response[:results][0][:result_code].should == '2001'
response[:results].count.should == 1
end
it 'returns error when object does not exist' do
response = info_request({ id: { value: 'no-contact' } })
response[:msg].should == 'Object does not exist'
response[:result_code].should == '2303'
response[:results][0][:value].should == 'NO-CONTACT'
response[:results].count.should == 1
end
it 'return info about contact' do
Fabricate(:contact, code: 'INFO-4444', name: 'Johnny Awesome')
response = info_request({ id: { value: 'FIXED:INFO-4444' } })
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
contact = response[:parsed].css('resData infData')
contact.css('name').first.text.should == 'Johnny Awesome'
end
it 'should add legacy CID format as append' do
Fabricate(:contact, code: 'CID:FIXED:INFO-5555', name: 'Johnny Awesome')
response = info_request({ id: { value: 'FIXED:CID:FIXED:INFO-5555' } })
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
contact = response[:parsed].css('resData infData')
contact.css('name').first.text.should == 'Johnny Awesome'
end
it 'should return ident in extension' do
@registrar1_contact = Fabricate(:contact, code: 'INFO-IDENT',
registrar: @registrar1, name: 'Johnny Awesome')
response = info_request({ id: { value: @registrar1_contact.code } })
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
contact = response[:parsed].css('resData infData')
contact.css('ident').first.should == nil # ident should be in extension
contact = response[:parsed].css('extension')
contact.css('ident').first.text.should == '37605030299'
end
it 'returns no authorization error for wrong password when registrant' do
response = info_request({ authInfo: { pw: { value: 'wrong-pw' } } })
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
response[:results].count.should == 1
end
it 'should honor new contact code format' do
@registrar1_contact = Fabricate(:contact, code: 'FIXED:test:custom:code')
@registrar1_contact.code.should == 'FIXED:TEST:CUSTOM:CODE'
response = info_request({ id: { value: 'FIXED:TEST:CUSTOM:CODE' } })
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
contact = response[:parsed].css('resData infData')
contact.css('ident').first.should == nil # ident should be in extension
contact = response[:parsed].css('extension')
contact.css('ident').first.text.should == '37605030299'
end
it 'returns no authorization error for wrong user but correct password' do
login_as :registrar2 do
response = info_request
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
response[:results].count.should == 1
contact = response[:parsed].css('resData infData')
contact.css('postalInfo addr city').first.try(:text).present?.should == true
contact.css('email').first.try(:text).present?.should == true
contact.css('voice').first.try(:text).should == '+372.12345678'
end
end
it 'returns authorization error for wrong user and wrong password' do
login_as :registrar2 do
response = info_request({ authInfo: { pw: { value: 'wrong-pw' } } })
response[:msg].should == 'Authorization error'
response[:result_code].should == '2201'
response[:results].count.should == 1
contact = response[:parsed].css('resData infData')
contact.css('postalInfo addr city').first.try(:text).should == nil
contact.css('email').first.try(:text).should == nil
contact.css('voice').first.try(:text).should == nil
end
end
it 'returns no authorization error for wrong user and no password' do
login_as :registrar2 do
response = info_request({ authInfo: { pw: { value: '' } } }, validate_output: false)
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
response[:results].count.should == 1
contact = response[:parsed].css('resData infData')
contact.css('postalInfo addr city').first.try(:text).should == nil
contact.css('email').first.try(:text).should == nil
contact.css('voice').first.try(:text).should == nil
end
end
end
end
def check_multiple_contacts_xml
'<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<check>
<contact:check
xmlns:contact="https://epp.tld.ee/schema/contact-eis-1.0.xsd">
<contact:id>FIXED:CHECK-1234</contact:id>
<contact:id>check-4321</contact:id>
</contact:check>
</check>
<clTRID>ABC-12345</clTRID>
</command>
</epp>'
end
def check_multiple_legacy_contacts_xml
'<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<check>
<contact:check
xmlns:contact="https://epp.tld.ee/schema/contact-eis-1.0.xsd">
<contact:id>FIXED:CHECK-LEGACY</contact:id>
<contact:id>CID:FIXED:CHECK-LEGACY</contact:id>
</contact:check>
</check>
<clTRID>ABC-12345</clTRID>
</command>
</epp>'
end
end

File diff suppressed because it is too large Load diff

View file

@ -1,54 +0,0 @@
require 'rails_helper'
describe 'EPP Helper', epp: true do
context 'in context of Domain' do
before(:all) { @uniq_no = proc { @i ||= 0; @i += 1 } }
it 'generates valid transfer xml' do
dn = next_domain_name
expected = Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<transfer op="request">
<domain:transfer
xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>' + dn + '</domain:name>
</domain:transfer>
</transfer>
<clTRID>ABC-12345</clTRID>
</command>
</epp>
').to_s.squish
generated = Nokogiri::XML(domain_transfer_xml(name: { value: dn })).to_s.squish
generated.should == expected
expected = Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<transfer op="approve">
<domain:transfer
xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>one.ee</domain:name>
<domain:authInfo>
<domain:pw roid="askdf">test</domain:pw>
</domain:authInfo>
</domain:transfer>
</transfer>
<clTRID>ABC-12345</clTRID>
</command>
</epp>
').to_s.squish
xml = domain_transfer_xml({
name: { value: 'one.ee' },
authInfo: {
pw: { value: 'test', attrs: { roid: 'askdf' } }
}
}, 'approve')
generated = Nokogiri::XML(xml).to_s.squish
generated.should == expected
end
end
end

View file

@ -1,216 +0,0 @@
require 'rails_helper'
describe 'EPP Keyrelay', epp: true do
before(:all) do
Fabricate(:zonefile_setting, origin: 'ee')
@registrar1 = Fabricate(:registrar1)
@registrar2 = Fabricate(:registrar2)
@domain = Fabricate(:domain, registrar: @registrar2)
@epp_xml = EppXml::Keyrelay.new
Fabricate(:api_user, username: 'registrar1', registrar: @registrar1)
Fabricate(:api_user, username: 'registrar2', registrar: @registrar2)
login_as :registrar1
end
it 'makes a keyrelay request' do
ApiLog::EppLog.delete_all
xml = @epp_xml.keyrelay({
name: { value: @domain.name },
keyData: {
flags: { value: '256' },
protocol: { value: '3' },
alg: { value: '8' },
pubKey: { value: 'cmlraXN0aGViZXN0' }
},
authInfo: {
pw: { value: @domain.auth_info }
},
expiry: {
relative: { value: 'P1M13D' }
}
})
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Unimplemented object service'
response[:result_code].should == '2307'
# response[:msg].should == 'Command completed successfully'
# response[:result_code].should == '1000'
# @registrar2.messages.queued.count.should == 1
# 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 = @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 }
},
expiry: {
relative: { value: 'Invalid Expiry' }
}
})
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Required parameter missing: keyrelay > keyData > flags [flags]'
@registrar2.messages.queued.count.should == msg_count
end
it 'returns an error on invalid relative expiry' do
msg_count = @registrar2.messages.queued.count
xml = @epp_xml.keyrelay({
name: { value: @domain.name },
keyData: {
flags: { value: '256' },
protocol: { value: '3' },
alg: { value: '8' },
pubKey: { value: 'cmlraXN0aGViZXN0' }
},
authInfo: {
pw: { value: @domain.auth_info }
},
expiry: {
relative: { value: 'Invalid Expiry' }
}
})
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Expiry relative must be compatible to ISO 8601'
response[:results][0][:value].should == 'Invalid Expiry'
@registrar2.messages.queued.count.should == msg_count
end
it 'returns an error on invalid absolute expiry' do
msg_count = @registrar2.messages.queued.count
xml = @epp_xml.keyrelay({
name: { value: @domain.name },
keyData: {
flags: { value: '256' },
protocol: { value: '3' },
alg: { value: '8' },
pubKey: { value: 'cmlraXN0aGViZXN0' }
},
authInfo: {
pw: { value: @domain.auth_info }
},
expiry: {
absolute: { value: 'Invalid Absolute' }
}
})
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Expiry absolute must be compatible to ISO 8601'
response[:results][0][:value].should == 'Invalid Absolute'
@registrar2.messages.queued.count.should == msg_count
end
# keyrelay not enabled at the moment
# it 'does not allow both relative and absolute' do
# msg_count = @registrar2.messages.queued.count
# xml = @epp_xml.keyrelay({
# name: { value: @domain.name },
# keyData: {
# flags: { value: '256' },
# protocol: { value: '3' },
# alg: { value: '8' },
# pubKey: { value: 'cmlraXN0aGViZXN0' }
# },
# authInfo: {
# pw: { value: @domain.auth_info }
# },
# expiry: {
# relative: { value: 'P1D' },
# absolute: { value: '2014-12-23' }
# }
# })
# response = epp_plain_request(xml, :xml)
# response[:msg].should == 'Exactly one parameter required: keyrelay > expiry > relative OR '\
# 'keyrelay > expiry > absolute'
# @registrar2.messages.queued.count.should == msg_count
# end
it 'saves legal document with keyrelay' do
xml = @epp_xml.keyrelay({
name: { value: @domain.name },
keyData: {
flags: { value: '256' },
protocol: { value: '3' },
alg: { value: '8' },
pubKey: { value: 'cmlraXN0aGViZXN0' }
},
authInfo: {
pw: { value: @domain.auth_info }
},
expiry: {
relative: { value: 'P1D' }
}
}, {
_anonymus: [
legalDocument: {
value: 'dGVzdCBmYWlsCg==',
attrs: { type: 'pdf' }
}
]
})
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Unimplemented object service'
response[:result_code].should == '2307'
# response[:msg].should == 'Command completed successfully'
# docs = Keyrelay.last.legal_documents
# docs.count.should == 1
# docs.first.path.should_not be_blank
# docs.first.document_type.should == 'pdf'
end
it 'validates legal document types' do
xml = @epp_xml.keyrelay({
name: { value: @domain.name },
keyData: {
flags: { value: '256' },
protocol: { value: '3' },
alg: { value: '8' },
pubKey: { value: 'cmlraXN0aGViZXN0' }
},
authInfo: {
pw: { value: @domain.auth_info }
},
expiry: {
relative: { value: 'P1D' }
}
}, {
_anonymus: [
legalDocument: {
value: 'dGVzdCBmYWlsCg==',
attrs: { type: 'jpg' }
}
]
})
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Attribute is invalid: type'
end
end

View file

@ -1,158 +0,0 @@
require 'rails_helper'
describe 'EPP Poll', epp: true do
let(:epp_xml) { EppXml::Session.new }
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
@xsd = Nokogiri::XML::Schema(File.read('lib/schemas/epp-1.0.xsd'))
Fabricate(:api_user, username: 'registrar1', registrar: registrar1)
Fabricate(:api_user, username: 'registrar2', registrar: registrar2)
login_as :registrar1
@uniq_no = proc { @i ||= 0; @i += 1 }
end
it 'returns no messages in poll' do
ApiLog::EppLog.delete_all
response = epp_plain_request(epp_xml.poll, :xml)
response[:msg].should == 'Command completed successfully; no messages'
response[:result_code].should == '1300'
log = ApiLog::EppLog.last
log.request_command.should == 'poll'
log.request_object.should == 'poll'
log.request_successful.should == true
log.api_user_name.should == 'registrar1'
log.api_user_registrar.should == @registrar1.name
log.request.should_not be_blank
log.response.should_not be_blank
end
it 'queues and dequeues messages' do
msg = registrar1.messages.create({ body: 'Balance low.' })
response = login_as :registrar2 do
epp_plain_request(epp_xml.poll, :xml)
end
response[:msg].should == 'Command completed successfully; no messages'
response[:result_code].should == '1300'
response = epp_plain_request(epp_xml.poll, :xml)
response[:msg].should == 'Command completed successfully; ack to dequeue'
response[:result_code].should == '1301'
msg_q = response[:parsed].css('msgQ')
msg_q.css('msg').text.should == 'Balance low.'
msg_q.first['count'].should == '1'
msg_q.first['id'].should == msg.id.to_s
xml = epp_xml.poll(poll: {
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
})
response = login_as :registrar2 do
epp_plain_request(xml, :xml)
end
response[:results][0][:msg].should == 'Message was not found'
response[:results][0][:result_code].should == '2303'
response[:results][0][:value].should == msg_q.first['id']
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Command completed successfully'
msg_q = response[:parsed].css('msgQ')
msg_q.first['id'].should_not be_blank
msg_q.first['count'].should == '0'
response = epp_plain_request(xml, :xml)
response[:results][0][:msg].should == 'Message was not found'
response[:results][0][:result_code].should == '2303'
response[:results][0][:value].should == msg_q.first['id']
end
it 'returns an error on incorrect op' do
xml = epp_xml.poll(poll: {
value: '', attrs: { op: 'bla' }
})
response = epp_plain_request(xml, validate_input: false)
response[:msg].should == "Element '{urn:ietf:params:xml:ns:epp-1.0}poll', attribute 'op': "\
"[facet 'enumeration'] The value 'bla' is not an element of the set {'ack', 'req'}."
response[:result_code].should == '2001'
end
it 'dequeues multiple messages' do
registrar1.messages.create({ body: 'Balance low.' })
registrar1.messages.create({ body: 'Something.' })
registrar1.messages.create({ body: 'Smth else.' })
response = epp_plain_request(epp_xml.poll, :xml)
response[:msg].should == 'Command completed successfully; ack to dequeue'
response[:result_code].should == '1301'
msg_q = response[:parsed].css('msgQ')
msg_q.css('msg').text.should == 'Smth else.'
msg_q.first['count'].should == '3'
xml = epp_xml.poll(poll: {
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
})
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Command completed successfully'
msg_q = response[:parsed].css('msgQ')
msg_q.first['id'].should_not be_blank
msg_q.first['count'].should == '2'
response = epp_plain_request(epp_xml.poll, :xml)
response[:msg].should == 'Command completed successfully; ack to dequeue'
response[:result_code].should == '1301'
msg_q = response[:parsed].css('msgQ')
msg_q.css('msg').text.should == 'Something.'
msg_q.first['count'].should == '2'
xml = epp_xml.poll(poll: {
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
})
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Command completed successfully'
msg_q = response[:parsed].css('msgQ')
msg_q.first['id'].should_not be_blank
msg_q.first['count'].should == '1'
response = epp_plain_request(epp_xml.poll, :xml)
response[:msg].should == 'Command completed successfully; ack to dequeue'
response[:result_code].should == '1301'
msg_q = response[:parsed].css('msgQ')
msg_q.css('msg').text.should == 'Balance low.'
msg_q.first['count'].should == '1'
xml = epp_xml.poll(poll: {
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
})
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Command completed successfully'
msg_q = response[:parsed].css('msgQ')
msg_q.first['id'].should_not be_blank
msg_q.first['count'].should == '0'
response = epp_plain_request(epp_xml.poll, :xml)
response[:msg].should == 'Command completed successfully; no messages'
response[:result_code].should == '1300'
end
end

View file

@ -1,45 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<create>
<contact:create
xmlns:contact="https://epp.tld.ee/schema/contact-eis-1.0.xsd">
<contact:id>loc_int</contact:id>
<contact:postalInfo type="int">
<contact:name>John Doe Int</contact:name>
<contact:org>Example Int Inc.</contact:org>
<contact:addr>
<contact:street>International street 1</contact:street>
<contact:city>Dulles</contact:city>
<contact:sp>VA</contact:sp>
<contact:pc>20166-6503</contact:pc>
<contact:cc>EE</contact:cc>
</contact:addr>
</contact:postalInfo>
<contact:postalInfo type="loc">
<contact:name>John Doe Loc</contact:name>
<contact:org>Example Loc Inc.</contact:org>
<contact:addr>
<contact:street>Local street 1</contact:street>
<contact:city>Vancouver</contact:city>
<contact:sp>BC</contact:sp>
<contact:pc>27123</contact:pc>
<contact:cc>CA</contact:cc>
</contact:addr>
</contact:postalInfo>
<contact:voice x="1234">+123.7035555555</contact:voice>
<contact:fax>+1.7035555556</contact:fax>
<contact:email>jdoe@example.com</contact:email>
<contact:ident type="op">37605030299</contact:ident>
<contact:authInfo>
<contact:pw>2fooBAR</contact:pw>
</contact:authInfo>
<contact:disclose flag="0">
<contact:voice/>
<contact:email/>
</contact:disclose>
</contact:create>
</create>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<delete>
<contact:delete
xmlns:contact="https://epp.tld.ee/schema/contact-eis-1.0.xsd">
<contact:id>dwa1234</contact:id>
</contact:delete>
</delete>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<delete>
<contact:delete
xmlns:contact="https://epp.tld.ee/schema/contact-eis-1.0.xsd">
</contact:delete>
</delete>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<info>
<contact:info
xmlns:contact="https://epp.tld.ee/schema/contact-eis-1.0.xsd">
<contact:id>info-4444</contact:id>
<contact:authInfo>
<contact:pw>2fooBAR</contact:pw>
</contact:authInfo>
</contact:info>
</info>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<info>
<contact:info
xmlns:contact="https://epp.tld.ee/schema/contact-eis-1.0.xsd">
</contact:info>
</info>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<update>
<contact:update
xmlns:contact="https://epp.tld.ee/schema/contact-eis-1.0.xsd">
<contact:id>sh8013</contact:id>
<contact:chg>
<contact:postalInfo type="int">
<contact:name>John Doe</contact:name>
<contact:addr>
<contact:street>123 Example Dr.</contact:street>
<contact:street>Suite 100</contact:street>
<contact:city>Dulles</contact:city>
<contact:sp>VA</contact:sp>
<contact:pc>20166-6503</contact:pc>
<contact:cc>EE</contact:cc>
</contact:addr>
</contact:postalInfo>
<contact:voice x="1234">+123.7035555555</contact:voice>
<contact:fax>+1.7035555556</contact:fax>
<contact:email>jdoe@example.com</contact:email>
<contact:ident type="passport">J836954</contact:ident>
<contact:authInfo>
<contact:pw>2fooBAR</contact:pw>
</contact:authInfo>
<contact:disclose flag="0">
<contact:voice/>
<contact:email/>
</contact:disclose>
</contact:chg>
</contact:update>
</update>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<update>
<contact:update
xmlns:contact="https://epp.tld.ee/schema/contact-eis-1.0.xsd">
</contact:update>
</update>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<update>
<contact:update
xmlns:contact="https://epp.tld.ee/schema/contact-eis-1.0.xsd">
<contact:id>sh8013</contact:id>
<contact:chg>
<contact:voice x="1234">123456798</contact:voice>
<contact:email>faulty</contact:email>
<contact:authInfo>
<contact:pw>2fooBAR</contact:pw>
</contact:authInfo>
</contact:chg>
</contact:update>
</update>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -1,155 +0,0 @@
require 'rails_helper'
describe 'EPP Session', epp: true do
before :all do
@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' })
@xsd = Nokogiri::XML::Schema(File.read('lib/schemas/epp-1.0.xsd'))
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']
end
end
context 'when connected' do
before do
server.open_connection
end
it 'does not log in with invalid user' do
wrong_user = @epp_xml.session.login(clID: { value: 'wrong-user' }, pw: { value: 'ghyt9e4fu' })
response = epp_plain_request(wrong_user)
response[:msg].should == 'Authentication error; server closing connection (API user not found)'
response[:result_code].should == '2501'
response[:clTRID].should == 'ABC-12345'
log = ApiLog::EppLog.last
log.request_command.should == 'login'
log.request_successful.should == false
log.api_user_name.should == 'api-public'
end
it 'does not log in with inactive user' do
@registrar = Fabricate(:registrar, { name: 'registrar1', reg_no: '123' })
Fabricate(:api_user, username: 'inactive-user', active: false, registrar: @registrar)
inactive = @epp_xml.session.login(clID: { value: 'inactive-user' }, pw: { value: 'ghyt9e4fu' })
response = epp_plain_request(inactive)
response[:msg].should == 'Authentication error; server closing connection (API user is not active)'
response[:result_code].should == '2501'
log = ApiLog::EppLog.last
log.request_command.should == 'login'
log.request_successful.should == false
log.api_user_name.should == 'inactive-user'
end
it 'prohibits further actions unless logged in' do
@xsd = Nokogiri::XML::Schema(File.read('lib/schemas/domain-eis-1.0.xsd'))
response = epp_plain_request(@epp_xml.domain.info(name: { value: 'test.ee' }))
response[:msg].should == 'You need to login first.'
response[:result_code].should == '2002'
response[:clTRID].should == 'ABC-12345'
end
it 'should not have clTRID in response if client does not send it' do
epp_xml_no_cltrid = EppXml.new(cl_trid: false)
wrong_user = epp_xml_no_cltrid.session.login(clID: { value: 'wrong-user' }, pw: { value: 'ghyt9e4fu' })
response = epp_plain_request(wrong_user)
response[:clTRID].should be_nil
end
it 'should return latin only error' do
wrong_user = @epp_xml.session.login(clID: { value: '你好你好' }, pw: { value: 'ghyt9e4fu' })
response = epp_plain_request(wrong_user)
response[:msg].should == 'Parameter value policy error. Allowed only Latin characters.'
response[:result_code].should == '2306'
response[:clTRID].should == 'ABC-12345'
log = ApiLog::EppLog.last
log.request_command.should == 'login'
log.request_successful.should == false
log.api_user_name.should == 'api-public'
end
context 'with valid user' do
it 'logs in epp user' do
response = epp_plain_request(@login_xml_cache)
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 == 'gitlab'
end
it 'does not log in twice' do
response = epp_plain_request(@login_xml_cache)
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
response[:clTRID].should == 'ABC-12345'
response = epp_plain_request(@login_xml_cache)
response[:msg].should match(/Already logged in. Use/)
response[:result_code].should == '2002'
log = ApiLog::EppLog.last
log.request_command.should == 'login'
log.request_successful.should == false
log.api_user_name.should == 'gitlab'
end
it 'logs out epp user' do
c = EppSession.count
epp_plain_request(@login_xml_cache)
EppSession.count.should == c + 1
response = epp_plain_request(@epp_xml.session.logout)
response[:msg].should == 'Command completed successfully; ending session'
response[:result_code].should == '1500'
EppSession.count.should == c
end
it 'changes password and logs in' do
@api_user.update(password: 'ghyt9e4fu')
response = epp_plain_request(@epp_xml.session.login(
clID: { value: 'gitlab' },
pw: { value: 'ghyt9e4fu' },
newPW: { value: 'abcdefg' }
))
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
@api_user.reload
@api_user.password.should == 'abcdefg'
end
it 'fails if new password is not valid' do
@api_user.update(password: 'ghyt9e4fu')
response = epp_plain_request(@epp_xml.session.login(
clID: { value: 'gitlab' },
pw: { value: 'ghyt9e4fu' },
newPW: { value: '' }
), validate_input: false)
response[:msg].should ==
"Element '{urn:ietf:params:xml:ns:epp-1.0}newPW': [facet 'minLength'] The value has a "\
"length of '0'; this underruns the allowed minimum length of '6'."
response[:result_code].should == '2001'
@api_user.reload
@api_user.password.should == 'ghyt9e4fu'
end
end
end
end

View file

@ -1,45 +0,0 @@
require 'rails_helper'
feature 'Account activity', type: :feature do
before :all do
@user = Fabricate(:admin_user)
r = Fabricate(:registrar)
Fabricate.times(5, :account_activity, account: r.cash_account)
Fabricate(:account_activity, account: r.cash_account, description: 'acc activity test', sum: -12)
end
context 'as unknown user' do
it 'should redirect to sign in page' do
visit '/admin/account_activities'
current_path.should == '/admin/login'
page.should have_text('You need to sign in or sign up')
end
end
context 'as signed in user' do
before do
sign_in @user
end
it 'should navigate to account activities page' do
visit admin_account_activities_path
page.should have_text('+110.0 EUR', count: 5)
page.should have_text('-12.0 EUR')
end
it 'should search activities by description' do
visit admin_account_activities_path
fill_in 'Description', with: 'test'
find('.btn.btn-default.search').click
page.should have_text('-12.0 EUR')
page.should_not have_text('+110.0 EUR')
end
it 'should download csv' do
visit admin_account_activities_path
click_link 'Export CSV'
response_headers['Content-Type'].should == 'text/csv'
response_headers['Content-Disposition'].should match(/attachment; filename="account_activities_\d+\.csv"/)
end
end
end

View file

@ -1,49 +0,0 @@
require 'rails_helper'
feature 'Admin users', type: :feature do
before :all do
@admin_user = Fabricate(:admin_user)
end
context 'as unknown user' do
it 'should redirect to login path' do
visit admin_admin_users_url
current_path.should == '/admin/login'
end
it 'should redirect to login path' do
visit admin_admin_user_url(@admin_user)
current_path.should == '/admin/login'
end
it 'should redirect to login path' do
visit edit_admin_admin_user_url(@admin_user)
current_path.should == '/admin/login'
end
end
context 'as logged in user' do
it 'should show index of contacts' do
sign_in @admin_user
visit admin_admin_users_url
current_path.should == '/admin/admin_users'
page.should have_content('API users')
end
it 'should show api user' do
sign_in @admin_user
visit admin_admin_user_url(@admin_user)
current_path.should == "/admin/admin_users/#{@admin_user.id}"
end
it 'should show api user' do
sign_in @admin_user
visit edit_admin_admin_user_url(@admin_user)
current_path.should == "/admin/admin_users/#{@admin_user.id}/edit"
page.should have_content("Edit: #{@admin_user.username}")
end
end
end

View file

@ -1,40 +0,0 @@
require 'rails_helper'
feature 'Api users', type: :feature do
before :all do
@user = Fabricate(:admin_user)
@api_user = Fabricate(:api_user)
end
context 'as unknown user' do
it 'should redirect to login path' do
visit admin_api_users_url
current_path.should == '/admin/login'
end
it 'should redirect to login path' do
visit admin_api_user_url(@api_user)
current_path.should == '/admin/login'
end
end
context 'as logged in user' do
it 'should show index of api users' do
sign_in @user
visit admin_api_users_url
current_path.should == '/admin/api_users'
page.should have_content('API users')
end
it 'should show api user' do
sign_in @user
visit admin_api_user_url(@api_user)
current_path.should == "/admin/api_users/#{@api_user.id}"
end
end
end

View file

@ -1,52 +0,0 @@
require 'rails_helper'
feature 'BankStatement', type: :feature do
before :all do
@user = Fabricate(:admin_user)
end
before do
sign_in @user
end
it 'should add a bank statement and transactions manually' do
visit admin_bank_statements_url
click_link 'Add'
fill_in 'Bank code', with: '767'
fill_in 'Iban', with: 'EE557700771000598731'
click_button 'Save'
page.should have_content('Record created')
page.should have_content('Bank statement ')
page.should have_content('767')
page.should have_content('EE557700771000598731')
page.should have_content('Not binded')
click_link 'Add'
fill_in 'Description', with: 'Payment 12345'
fill_in 'Sum', with: '120'
fill_in 'Reference no', with: 'RF4663930489'
fill_in 'Document no', with: '123'
fill_in 'Bank reference', with: '767'
fill_in 'Iban', with: 'EE557700771000598731'
fill_in 'Buyer bank code', with: '767'
fill_in 'Buyer iban', with: 'EE557700771000598000'
fill_in 'Buyer name', with: 'Test buyer'
fill_in 'Paid at', with: '2015-01-01'
click_button 'Save'
page.should have_content('Record created')
page.should have_content('Bank transaction')
page.should have_content('RF4663930489')
page.should have_content('EE557700771000598000')
page.should have_content('Not binded')
page.should have_content('Bind manually')
click_link 'Back to bank statement'
page.should have_content('120,00')
page.should have_content('Test buyer')
end
end

View file

@ -1,31 +0,0 @@
require 'rails_helper'
feature 'BlockedDomain', type: :feature do
before :all do
Fabricate(:zonefile_setting, origin: 'ee')
@user = Fabricate(:admin_user)
end
before do
sign_in @user
end
it 'should manage blocked domains' do
visit admin_blocked_domains_url
page.should have_content('Blocked domains')
d = Fabricate.build(:domain, name: 'ftp.ee')
d.valid?
d.errors.full_messages.should match_array([])
fill_in 'blocked_domains', with: "ftp.ee\ncache.ee"
click_button 'Save'
page.should have_content('Record updated')
page.should have_content('ftp.ee')
page.should have_content('cache.ee')
d.valid?
d.errors.full_messages.should match_array(["Data management policy violation: Domain name is blocked [name]"])
end
end

View file

@ -1,60 +0,0 @@
require 'rails_helper'
feature 'Admin contact', type: :feature do
before :all do
@user = Fabricate(:admin_user)
@contact = Fabricate(:contact, name: 'Mr John')
end
it 'should show index of contacts' do
sign_in @user
visit admin_contacts_url
page.should have_content('Mr John')
end
it 'should show correct contact creator' do
sign_in @user
visit admin_contacts_url
click_link('Mr John')
# initially it's created by unknown,
# indivitually running it's created by autotest
page.should have_content(/by [unknown|autotest]/)
end
it 'should search contacts by name' do
Fabricate(:contact, name: 'first name')
Fabricate(:contact, name: 'second name')
Fabricate(:contact, name: 'third name')
sign_in @user
visit admin_contacts_url
page.should have_content('first name')
page.should have_content('second name')
page.should have_content('third name')
fill_in 'q_name_matches', with: 'first name'
find('.btn.btn-primary').click
current_path.should == "/admin/contacts"
page.should have_content('first name')
page.should_not have_content('second name')
page.should_not have_content('third name')
fill_in 'q_name_matches', with: '%name'
find('.btn.btn-primary').click
page.should have_content('first name')
page.should have_content('second name')
page.should have_content('third name')
fill_in 'q_name_matches', with: 'sec___ name'
find('.btn.btn-primary').click
page.should_not have_content('first name')
page.should have_content('second name')
page.should_not have_content('third name')
end
end

View file

@ -1,89 +0,0 @@
require 'rails_helper'
feature 'Domain', type: :feature do
before :all do
Fabricate(:zonefile_setting, origin: 'ee')
Fabricate(:zonefile_setting, origin: 'pri.ee')
@user = Fabricate(:admin_user)
end
it 'should show index of domains' do
Fabricate(:domain, name: 'testing.ee')
sign_in @user
visit admin_domains_url
page.should have_content('testing.ee')
end
it 'should search domains by name' do
d1 = Fabricate(:domain, name: 'abcde.ee')
Fabricate(:domain, name: 'abcdee.ee')
Fabricate(:domain, name: 'defgh.pri.ee')
sign_in @user
visit admin_domains_url
page.should have_content('abcde.ee')
page.should have_content('abcdee.ee')
page.should have_content('defgh.pri.ee')
fill_in 'q_name_matches', with: 'abcde.ee'
find('.btn.btn-primary').click
current_path.should == "/admin/domains/#{d1.id}"
visit admin_domains_url
fill_in 'q_name_matches', with: '.ee'
find('.btn.btn-primary').click
current_path.should == "/admin/domains"
page.should have_content('abcde.ee')
page.should have_content('abcdee.ee')
page.should have_content('defgh.pri.ee')
fill_in 'q_name_matches', with: 'abcd%.ee'
find('.btn.btn-primary').click
page.should have_content('abcde.ee')
page.should have_content('abcdee.ee')
page.should_not have_content('defgh.pri.ee')
fill_in 'q_name_matches', with: 'abcd_.ee'
find('.btn.btn-primary').click
current_path.should == "/admin/domains/#{d1.id}"
end
it 'should set domain to force delete' do
d = Fabricate(:domain)
sign_in @user
visit admin_domains_url
click_link d.name
click_link 'Edit statuses'
page.should have_content('ok')
click_link 'Set force delete'
page.should have_content('serverForceDelete')
page.should have_content('serverRenewProhibited')
page.should have_content('serverTransferProhibited')
page.should have_content('serverUpdateProhibited')
page.should have_content('serverManualInzone')
page.should have_content('pendingDelete')
click_link 'Edit statuses'
click_button 'Save'
page.should have_content('Failed to update domain')
page.should have_content('Object status prohibits operation')
click_link 'Back to domain'
click_link 'Edit statuses'
click_link 'Unset force delete'
page.should_not have_content('serverForceDelete')
page.should_not have_content('serverRenewProhibited')
page.should_not have_content('serverTransferProhibited')
page.should_not have_content('serverUpdateProhibited')
page.should_not have_content('serverManualInzone')
page.should_not have_content('pendingDelete')
page.should have_content('ok')
click_link 'Edit statuses'
click_button 'Save'
page.should have_content('Domain updated!')
end
end

View file

@ -1,25 +0,0 @@
require 'rails_helper'
feature 'EPP log', type: :feature do
before :all do
@user = Fabricate(:admin_user)
@contact = Fabricate(:contact, name: 'Mr John')
end
context 'as unknown user' do
it 'should redirect to login path' do
visit admin_epp_logs_url
current_path.should == '/admin/login'
end
end
context 'as logged in user' do
it 'should show index' do
sign_in @user
visit admin_epp_logs_url
page.should have_content('REPP logs')
end
end
end

View file

@ -1,131 +0,0 @@
require 'rails_helper'
feature 'Invoice', type: :feature do
before :all do
@user = Fabricate(:admin_user)
@invoice = Fabricate(:invoice)
end
before do
sign_in @user
end
it 'should show index of invoices' do
visit admin_invoices_url
page.should have_link("Invoice no. #{@invoice.id}")
end
it 'should show invoice' do
visit admin_invoices_url
click_link("Invoice no. #{@invoice.id}")
page.should have_content("Seller")
page.should have_content("Details")
page.should have_content("Paldiski mnt. 123")
end
it 'should issue an invoice' do
Fabricate(:eis)
r = Fabricate(:registrar)
visit admin_invoices_url
click_link('Add')
page.should have_content('Create new invoice')
select r.name, from: 'Registrar'
fill_in 'Amount', with: '100'
fill_in 'Description', with: 'test issue'
click_button 'Save'
page.should have_content('Record created')
page.should have_content('Invoice no.')
page.should have_content('Prepayment')
page.should have_content('120,00')
page.should have_content(r.name)
end
it 'should not issue and invoice with deposit amount too small' do
Setting.minimum_deposit = 0.0
r = Fabricate(:registrar)
visit admin_invoices_url
click_link('Add')
select r.name, from: 'Registrar'
fill_in 'Amount', with: '-2.11'
fill_in 'Description', with: 'test issue'
click_button 'Save'
page.should have_content('Amount is too small. Minimum deposit is 0.0 EUR')
Setting.minimum_deposit = 12.43
fill_in 'Amount', with: '12.42'
click_button 'Save'
page.should have_content('Amount is too small. Minimum deposit is 12.43 EUR')
fill_in 'Amount', with: '12.44'
click_button 'Save'
page.should have_content('Record created')
Setting.minimum_deposit = 0.0
end
it 'should forward invoice' do
visit '/admin/invoices'
click_link @invoice.to_s
click_link 'Forward'
click_button 'Forward'
page.should have_text('Failed to forward invoice')
fill_in 'Billing email', with: 'test@test.ee'
click_button 'Forward'
page.should have_text('Invoice forwarded')
end
it 'should download invoice' do
visit '/admin/invoices'
click_link @invoice.to_s
click_link 'Download'
response_headers['Content-Type'].should == 'application/pdf'
response_headers['Content-Disposition'].should == "attachment; filename=\"#{@invoice.pdf_name}\""
end
it 'should create bank statement and transaction for invoice' do
r = Fabricate(:registrar, reference_no: 'RF7086666663')
invoice = r.issue_prepayment_invoice(200, 'add some money')
visit '/admin/invoices'
click_link invoice.to_s
page.should have_content('Unpaid')
click_link 'Payment received'
paid_at = Time.zone.now
find_field('Bank code').value.should == '689'
find_field('Iban').value.should == 'EE557700771000598731'
find_field('Description').value.should == invoice.to_s
find_field('Sum').value.should == invoice.sum.to_s
find_field('Currency').value.should == 'EUR'
find_field('Reference no').value.should == invoice.reference_no
find_field('Paid at').value.should == paid_at.to_date.to_s
click_button 'Save'
page.should have_content('Record created')
page.should have_content('689')
page.should have_content('EE557700771000598731')
page.should have_content('Not binded', count: 2)
page.should have_content('240,00')
page.should have_content('EUR')
click_link 'Bind invoices'
page.should have_content('Invoices were fully binded')
page.should have_content('Fully binded')
page.should have_content('Binded')
click_link I18n.l(paid_at, format: :date_long)
page.should have_content('Binded')
page.should have_content(invoice.to_s)
page.should have_content('240,00')
page.should have_content(invoice.reference_no)
page.should have_content(I18n.l(paid_at, format: :date_long))
click_link(invoice.to_s)
page.should_not have_content('Unpaid')
page.should_not have_content('Payment received')
end
end

View file

@ -1,47 +0,0 @@
require 'rails_helper'
feature 'MailTemplate', type: :feature do
before :all do
@user = Fabricate(:admin_user)
end
before do
sign_in @user
end
it 'should add a bank statement and transactions manually' do
visit admin_mail_templates_url
click_link 'New'
fill_in 'Name', with: 'Testing email template'
fill_in 'Subject', with: 'Test subject'
fill_in 'From', with: 'example@example.com'
fill_in 'mail_template_body', with: 'Liquid <h1>Test</h1>'
fill_in 'mail_template_text_body', with: 'Liquid static test'
click_button 'Save'
page.should have_content('Testing email template')
page.should have_content('Test subject')
page.should have_content('example@example.com')
page.should have_content('Liquid Test')
page.should have_content('Liquid static test')
click_link 'Email Templates'
page.should have_content('Mail Templates')
page.should have_content('Test subject')
click_link 'Testing email template'
page.should have_content('Testing email template')
click_link 'Edit'
page.should have_content('Edit: Testing email template')
fill_in 'Subject', with: 'New edited test subject'
click_button 'Save'
page.should have_content 'New edited test subject'
click_link 'Delete'
page.should have_content 'Mail Templates'
page.should_not have_content 'New edited test subject'
end
end

View file

@ -1,24 +0,0 @@
require 'rails_helper'
feature 'Repp log', type: :feature do
before :all do
@user = Fabricate(:admin_user)
end
context 'as unknown user' do
it 'should redirect to login path' do
visit admin_repp_logs_url
current_path.should == '/admin/login'
end
end
context 'as logged in user' do
it 'should show index' do
sign_in @user
visit admin_repp_logs_url
page.should have_content('REPP logs')
end
end
end

View file

@ -1,44 +0,0 @@
require 'rails_helper'
feature 'ReservedDomain', type: :feature do
before :all do
Fabricate(:zonefile_setting, origin: 'ee')
@user = Fabricate(:admin_user)
end
before do
sign_in @user
end
it 'should manage reserved domains' do
visit admin_reserved_domains_url
page.should have_content('Reserved domains')
d = Fabricate.build(:domain, name: '110.ee')
d.valid?
d.errors.full_messages.should match_array([])
fill_in 'reserved_domains', with: "110.ee: testpw"
click_button 'Save'
page.should have_content('Record updated')
page.should have_content('110.ee: testpw')
d.valid?.should == false
d.errors.full_messages.should match_array(
["Required parameter missing; reserved>pw element required for reserved domains"]
)
d.reserved_pw = 'wrongpw'
d.valid?.should == false
d.reserved_pw = 'testpw'
d.valid?.should == true
d.errors.full_messages.should match_array([])
d.save
visit admin_reserved_domains_url
page.should have_content('110.ee')
page.should_not have_content('110.ee: testpw')
end
end

View file

@ -1,63 +0,0 @@
require 'rails_helper'
feature 'Api users', type: :feature do
before :all do
@user = Fabricate(:admin_user)
@registrar = Fabricate(:registrar)
end
context 'as unknown user' do
it 'should redirect to login path' do
visit new_admin_registrar_white_ip_url(@registrar)
current_path.should == '/admin/login'
end
end
context 'as logged in user' do
before { sign_in @user }
it 'should add new white ip to registrar' do
visit admin_registrar_url(@registrar)
page.should_not have_text('192.168.1.1')
click_link 'Create new white IP'
fill_in 'IPv4', with: '192.168.1.1'
fill_in 'IPv6', with: 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329'
find('#white_ip_interfaces_api').set(true)
click_button 'Save'
page.should have_text('Record created')
page.should have_text('White IP')
page.should have_link(@registrar.to_s)
page.should have_text('192.168.1.1')
page.should have_text('FE80:0000:0000:0000:0202:B3FF:FE1E:8329')
page.should have_text('API')
click_link @registrar.to_s
current_path.should == "/admin/registrars/#{@registrar.id}"
page.should have_text('192.168.1.1')
page.should have_text('FE80:0000:0000:0000:0202:B3FF:FE1E:8329')
page.should have_text('API')
end
it 'should not add invalid ip to registrar' do
visit new_admin_registrar_white_ip_url(@registrar)
click_button 'Save'
page.should have_text('IPv4 or IPv6 must be present')
page.should have_text('Failed to create record')
fill_in 'IPv4', with: 'bla'
fill_in 'IPv6', with: 'bla'
click_button 'Save'
page.should have_text('IPv4 is invalid')
page.should have_text('IPv6 is invalid')
end
end
end

View file

@ -1,99 +0,0 @@
require 'rails_helper'
feature 'Zonefile settings', type: :feature do
before :all do
@user = Fabricate(:admin_user)
end
context 'as unknown user' do
it 'should redirect to login path' do
visit admin_zonefile_settings_url
current_path.should == '/admin/login'
end
end
context 'as logged in user' do
it 'should show index of contacts' do
sign_in @user
visit admin_zonefile_settings_url
page.should have_content('Zonefile settings')
end
it 'should create zone' do
sign_in @user
visit admin_zonefile_settings_url
page.should_not have_content('Generate zonefile')
click_link 'New'
fill_in 'Origin', with: 'ee'
fill_in 'TTL', with: '43200'
fill_in 'Refresh', with: '3600'
fill_in 'Retry', with: '900'
fill_in 'Expire', with: '1209600'
fill_in 'Minimum TTL', with: '3600'
fill_in 'E-Mail', with: 'hostmaster.eestiinternet.ee'
fill_in 'Master nameserver', with: 'ns.tld.ee'
fill_in('Ns records', with: '
ee. IN NS sunic.sunet.se.
ee. IN NS ns.eenet.ee.
ee. IN NS ns.tld.ee.
ee. IN NS ns.ut.ee.
ee. IN NS e.tld.ee.
ee. IN NS b.tld.ee.
ee. IN NS ee.aso.ee.
')
fill_in('A records', with: '
ns.ut.ee. IN A 193.40.5.99
ns.tld.ee. IN A 195.43.87.10
ee.aso.ee. IN A 213.184.51.122
b.tld.ee. IN A 194.146.106.110
ns.eenet.ee. IN A 193.40.56.245
e.tld.ee. IN A 204.61.216.36
')
fill_in('AAAA records', with: '
ee.aso.ee. IN AAAA 2A02:88:0:21::2
b.tld.ee. IN AAAA 2001:67C:1010:28::53
ns.eenet.ee. IN AAAA 2001:BB8::1
e.tld.ee. IN AAAA 2001:678:94:53::53
')
click_button 'Save'
page.should have_content('Record created')
page.should have_content('ee')
page.should have_content('Generate zonefile')
click_link 'Generate zonefile'
response_headers['Content-Type'].should == 'text/plain'
response_headers['Content-Disposition'].should == "attachment; filename=\"ee.txt\""
end
it 'does not delete zone with existin domains' do
ZonefileSetting.find_by(origin: 'ee') || Fabricate(:zonefile_setting)
Fabricate(:domain)
sign_in @user
visit admin_zonefile_settings_url
click_link 'ee'
click_link 'Delete'
page.should have_content("There are 1 domains in this zone")
page.should have_content('Failed to delete record')
end
it 'deletes a zone' do
ZonefileSetting.find_by(origin: 'ee') || Fabricate(:zonefile_setting)
Domain.destroy_all
sign_in @user
visit admin_zonefile_settings_url
click_link 'ee'
click_link 'Delete'
page.should have_content('Record deleted')
page.should_not have_content("Generate zonefile")
end
end
end

View file

@ -1,49 +0,0 @@
require 'rails_helper'
feature 'DomainDeleteConfirm', type: :feature do
before :all do
Fabricate(:zonefile_setting, origin: 'ee')
end
context 'as unknown user with domain without token' do
before :all do
@domain = Fabricate(:domain)
end
it 'should see warning info if token is missing request' do
visit "/registrant/domain_delete_confirms/#{@domain.id}"
current_path.should == "/registrant/domain_delete_confirms/#{@domain.id}"
page.should have_text('Domain verification not available')
end
it 'should see warning info if token is missing request' do
visit "/registrant/domain_delete_confirms/#{@domain.id}"
current_path.should == "/registrant/domain_delete_confirms/#{@domain.id}"
page.should have_text('Domain verification not available')
end
end
context 'as unknown user with domain with token' do
before :all do
@domain = Fabricate(
:domain,
registrant_verification_token: '123',
registrant_verification_asked_at: Time.zone.now
)
@domain.statuses << DomainStatus::PENDING_DELETE
@domain.save
end
it 'should see warning info if token is missing in request' do
visit "/registrant/domain_delete_confirms/#{@domain.id}?token=wrong_token"
current_path.should == "/registrant/domain_delete_confirms/#{@domain.id}"
page.should have_text('Domain verification not available')
end
it 'should show domain info and confirm buttons' do
visit "/registrant/domain_delete_confirms/#{@domain.id}?token=123"
current_path.should == "/registrant/domain_delete_confirms/#{@domain.id}"
page.should_not have_text('Domain verification not available')
end
end
end

View file

@ -1,49 +0,0 @@
require 'rails_helper'
feature 'DomainUpdateConfirm', type: :feature do
before :all do
Fabricate(:zonefile_setting, origin: 'ee')
end
context 'as unknown user with domain without update token' do
before :all do
@domain = Fabricate(:domain)
end
it 'should see warning info if token is missing request' do
visit "/registrant/domain_update_confirms/#{@domain.id}"
current_path.should == "/registrant/domain_update_confirms/#{@domain.id}"
page.should have_text('Domain verification not available')
end
it 'should see warning info if token is missing request' do
visit "/registrant/domain_update_confirms/#{@domain.id}"
current_path.should == "/registrant/domain_update_confirms/#{@domain.id}"
page.should have_text('Domain verification not available')
end
end
context 'as unknown user with domain with update token' do
before :all do
@domain = Fabricate(
:domain,
registrant_verification_token: '123',
registrant_verification_asked_at: Time.zone.now
)
@domain.statuses << DomainStatus::PENDING_UPDATE
@domain.save
end
it 'should see warning info if token is missing in request' do
visit "/registrant/domain_update_confirms/#{@domain.id}?token=wrong_token"
current_path.should == "/registrant/domain_update_confirms/#{@domain.id}"
page.should have_text('Domain verification not available')
end
it 'should show domain info and confirm buttons' do
visit "/registrant/domain_update_confirms/#{@domain.id}?token=123"
current_path.should == "/registrant/domain_update_confirms/#{@domain.id}"
page.should_not have_text('Domain verification not available')
end
end
end

View file

@ -1,18 +0,0 @@
require 'rails_helper'
feature 'Root', type: :feature do
it 'should redirect to registrant login page' do
visit '/registrant/login'
current_path.should == '/registrant/login'
end
it 'should redirect to registrant login page' do
visit '/registrant'
current_path.should == '/registrant/login'
end
it 'should redirect to registrant login page' do
visit '/registrant/'
current_path.should == '/registrant/login'
end
end

View file

@ -1,38 +0,0 @@
require 'rails_helper'
feature 'Account activity', type: :feature do
before :all do
@user = Fabricate(:api_user)
Fabricate(:account_activity, account: @user.registrar.cash_account)
end
context 'as unknown user' do
it 'should redirect to sign in page' do
visit '/registrar/account_activities'
current_path.should == '/registrar/login'
page.should have_text('You need to sign in or sign up')
end
end
context 'as signed in user' do
before do
registrar_sign_in
end
it 'should navigate to account activities page' do
current_path.should == '/registrar/poll'
click_link 'Billing'
click_link 'Account activity'
current_path.should == '/registrar/account_activities'
page.should have_text('+110.0 EUR')
end
it 'should download csv' do
visit '/registrar/account_activities'
click_link 'Export CSV'
response_headers['Content-Type'].should == 'text/csv'
response_headers['Content-Disposition'].should match(/attachment; filename="account_activities_\d+\.csv"/)
end
end
end

View file

@ -1,94 +0,0 @@
require 'rails_helper'
feature 'Contact', type: :feature do
before :all do
@user = Fabricate(:api_user)
end
context 'as unknown user' do
it 'should redirect to sign in page' do
visit '/registrar/contacts'
current_path.should == '/registrar/login'
page.should have_text('You need to sign in or sign up')
end
end
context 'as signed in user' do
before do
registrar_sign_in
end
it 'should navigate to the contact index page' do
click_link 'Contacts'
current_path.should == '/registrar/contacts'
end
it 'should get contact index page' do
visit '/registrar/contacts'
current_path.should == '/registrar/contacts'
end
context 'manage contact' do
it 'should navigate to new page' do
click_link 'Contacts'
click_link 'New'
current_path.should == '/registrar/contacts/new'
end
it 'should get new page' do
visit '/registrar/contacts/new'
current_path.should == '/registrar/contacts/new'
end
it 'should get warnings' do
visit '/registrar/contacts/new'
current_path.should == '/registrar/contacts/new'
fill_in 'depp_contact_ident', with: ''
fill_in 'depp_contact_name', with: 'Business Name Ltd'
fill_in 'depp_contact_email', with: 'example@example.com'
fill_in 'depp_contact_street', with: 'Example street 12'
fill_in 'depp_contact_city', with: 'Example City'
fill_in 'depp_contact_zip', with: '123456'
fill_in 'depp_contact_phone', with: '+372.12345678'
click_button 'Create'
current_path.should == '/registrar/contacts'
page.should have_text('Required parameter missing')
end
def create_contact
visit '/registrar/contacts/new'
current_path.should == '/registrar/contacts/new'
fill_in 'depp_contact_ident', with: 'org-ident'
fill_in 'depp_contact_name', with: 'Business Name Ltd'
fill_in 'depp_contact_email', with: 'example@example.com'
fill_in 'depp_contact_street', with: 'Example street 12'
fill_in 'depp_contact_city', with: 'Example City'
fill_in 'depp_contact_zip', with: '123456'
fill_in 'depp_contact_phone', with: '+372.12345678'
click_button 'Create'
page.should have_text('Business Name Ltd')
page.should have_text('org-ident [EE org]')
end
it 'should create new contact with success' do
create_contact
end
it 'should edit sucessfully' do
create_contact
click_link 'Edit'
current_path.should match(/edit/)
fill_in 'depp_contact_name', with: 'Edited Business Name Ltd'
click_button 'Save'
page.should have_text('Edited Business Name Ltd')
end
end
end
end

View file

@ -1,124 +0,0 @@
require 'rails_helper'
feature 'Domains', type: :feature do
before :all do
Fabricate(:zonefile_setting, origin: 'ee')
Fabricate(:zonefile_setting, origin: 'pri.ee')
@user = Fabricate(:api_user)
end
context 'as unknown user' do
it 'should redirect to sign in page' do
visit '/registrar/domains'
current_path.should == '/registrar/login'
page.should have_text('You need to sign in or sign up')
end
end
context 'as signed in user' do
before do
registrar_sign_in
end
it 'should navigate to the domains index page' do
click_link 'Domains'
current_path.should == '/registrar/domains'
end
it 'should get domains index page' do
visit '/registrar/domains'
current_path.should == '/registrar/domains'
end
it 'should navigate to new page' do
click_link 'Domains'
click_link 'New'
current_path.should == '/registrar/domains/new'
end
it 'should get new page' do
visit '/registrar/domains/new'
current_path.should == '/registrar/domains/new'
end
it 'should switch user' do
d1 = Fabricate(:domain, registrar: @user.registrar)
user2 = Fabricate(:api_user, identity_code: @user.identity_code)
d2 = Fabricate(:domain, registrar: user2.registrar)
visit '/registrar/domains'
page.should have_text(d1.name)
page.should_not have_text(d2.name)
click_link "#{user2} (#{user2.roles.first}) - #{user2.registrar}"
visit '/registrar/domains'
page.should_not have_text(d1.name)
page.should have_text(d2.name)
end
it 'should search domains' do
# having shared state across tests is really annoying sometimes...
within('.dropdown-menu') do
click_link "#{@user} (#{@user.roles.first}) - #{@user.registrar}"
end
Fabricate(:domain, name: 'abcde.ee', registrar: @user.registrar)
Fabricate(:domain, name: 'abcdee.ee', registrar: @user.registrar)
Fabricate(:domain, name: 'defgh.pri.ee', registrar: @user.registrar)
visit '/registrar/domains'
click_link 'Domains'
page.should have_content('abcde.ee')
page.should have_content('abcdee.ee')
page.should have_content('defgh.pri.ee')
fill_in 'q_name_matches', with: 'abcde.ee'
find('.btn.btn-primary.search').click
current_path.should == "/registrar/domains/info"
visit '/registrar/domains'
fill_in 'q_name_matches', with: '.ee'
find('.btn.btn-primary.search').click
current_path.should == "/registrar/domains"
page.should have_content('abcde.ee')
page.should have_content('abcdee.ee')
page.should have_content('defgh.pri.ee')
fill_in 'q_name_matches', with: 'abcd%.ee'
find('.btn.btn-primary.search').click
page.should have_content('abcde.ee')
page.should have_content('abcdee.ee')
page.should_not have_content('defgh.pri.ee')
fill_in 'q_name_matches', with: 'abcd_.ee'
find('.btn.btn-primary.search').click
current_path.should == "/registrar/domains"
page.should have_content('abcde.ee')
end
it 'should search foreign domain and transfer it' do
user2 = Fabricate(:api_user, identity_code: @user.identity_code)
d2 = Fabricate(:domain, registrar: user2.registrar)
visit '/registrar/domains'
page.should_not have_content(d2.name)
fill_in 'q_name_matches', with: d2.name
find('.btn.btn-primary.search').click
current_path.should == "/registrar/domains/info"
click_link 'Transfer'
fill_in 'Password', with: d2.auth_info
click_button 'Transfer'
page.should have_content 'serverApproved'
visit '/registrar/domains'
page.should have_content d2.name
end
end
end

View file

@ -1,68 +0,0 @@
require 'rails_helper'
feature 'Invoices', type: :feature do
before :all do
@user = Fabricate(:api_user)
@invoice = Fabricate(:invoice, buyer: @user.registrar)
end
context 'as unknown user' do
it 'should redirect to sign in page' do
visit '/registrar/invoices'
current_path.should == '/registrar/login'
page.should have_text('You need to sign in or sign up')
end
end
context 'as signed in user' do
before do
registrar_sign_in
end
it 'should navigate to the domains index page' do
current_path.should == '/registrar/poll'
click_link 'Billing'
current_path.should == '/registrar/invoices'
page.should have_text('Your current account balance is')
end
it 'should get domains index page' do
visit '/registrar/invoices'
page.should have_text('Invoices')
end
it 'should forward invoice' do
visit '/registrar/invoices'
click_link @invoice.to_s
click_link 'Forward'
click_button 'Forward'
page.should have_text('Failed to forward invoice')
fill_in 'Billing email', with: 'test@test.ee'
click_button 'Forward'
page.should have_text('Invoice forwarded')
end
it 'should download invoice' do
visit '/registrar/invoices'
click_link @invoice.to_s
click_link 'Download'
response_headers['Content-Type'].should == 'application/pdf'
response_headers['Content-Disposition'].should == "attachment; filename=\"#{@invoice.pdf_name}\""
end
it 'should not see foreign invoices' do
user2 = Fabricate(:api_user, identity_code: @user.identity_code)
visit '/registrar/invoices'
click_link @invoice.to_s
page.should have_text(@invoice.to_s)
page.should have_text('Buyer')
click_link "#{user2} (#{user2.roles.first}) - #{user2.registrar}"
visit "/registrar/invoices/#{@invoice.id}"
page.should have_text('You are not authorized to access this page.')
visit "/registrar/invoices/#{@invoice.id}/forward"
page.should have_text('You are not authorized to access this page.')
end
end
end

View file

@ -1,22 +0,0 @@
require 'rails_helper'
feature 'Root', type: :feature do
before :all do
Fabricate(:api_user)
end
it 'should redirect to registrar login page' do
visit '/registrar/login'
current_path.should == '/registrar/login'
end
it 'should redirect to registrar login page' do
visit '/registrar'
current_path.should == '/registrar/login'
end
it 'should redirect to registrar login page' do
visit '/registrar/'
current_path.should == '/registrar/login'
end
end

View file

@ -1,187 +0,0 @@
require 'rails_helper'
RSpec.feature 'Sessions' do
context 'with invalid ip' do
it 'should not see login page' do
Setting.registrar_ip_whitelist_enabled = true
WhiteIp.destroy_all
visit registrar_login_path
page.should have_text('Access denied')
end
it 'should see login page when whitelist disabled' do
Setting.registrar_ip_whitelist_enabled = false
WhiteIp.destroy_all
visit registrar_login_path
page.should_not have_text('Access denied')
Setting.registrar_ip_whitelist_enabled = true
end
it 'should see log in' do
@fixed_registrar = Fabricate(:registrar, name: 'fixed registrar', code: 'FIXED')
@fixed_registrar.white_ips = [Fabricate(:white_ip_registrar)]
visit registrar_login_path
page.should have_text('Log in')
end
it 'should not get in with invalid ip' do
Fabricate(:registrar, white_ips: [Fabricate(:white_ip), Fabricate(:white_ip_registrar)])
@api_user_invalid_ip = Fabricate(
:api_user, identity_code: '37810013294', registrar: Fabricate(:registrar, white_ips: [])
)
visit registrar_login_path
fill_in 'depp_user_tag', with: @api_user_invalid_ip.username
fill_in 'depp_user_password', with: @api_user_invalid_ip.password
click_button 'Log in'
page.should have_text('IP is not whitelisted')
end
it 'should get in with invalid when whitelist disabled' do
Setting.registrar_ip_whitelist_enabled = false
Setting.api_ip_whitelist_enabled = false
Fabricate(:registrar, white_ips: [Fabricate(:white_ip), Fabricate(:white_ip_registrar)])
@api_user_invalid_ip = Fabricate(
:api_user, identity_code: '37810013294', registrar: Fabricate(:registrar, white_ips: [])
)
visit registrar_login_path
fill_in 'depp_user_tag', with: @api_user_invalid_ip.username
fill_in 'depp_user_password', with: @api_user_invalid_ip.password
click_button 'Log in'
page.should have_text('Log out')
Setting.registrar_ip_whitelist_enabled = true
Setting.api_ip_whitelist_enabled = true
end
it 'should not get in with invalid user' do
visit registrar_login_path
fill_in 'depp_user_tag', with: 'bla'
fill_in 'depp_user_password', with: 'bla'
click_button 'Log in'
page.should have_text('No such user')
end
end
context 'as unknown user' do
before :all do
Fabricate(:api_user)
end
it 'should not get in' do
client = instance_double("Digidoc::Client")
allow(client).to receive(:authenticate).and_return(
OpenStruct.new(
user_id_code: '123'
)
)
allow(Digidoc::Client).to receive(:new) { client }
visit registrar_login_path
page.should have_css('a[href="/registrar/login/mid"]')
page.find('a[href="/registrar/login/mid"]').click
fill_in 'user_phone', with: '00007'
click_button 'Log in'
page.should have_text('No such user')
end
end
context 'as known api user' do
before :all do
Fabricate(:api_user)
end
it 'should not get in when external service fails' do
client = instance_double("Digidoc::Client")
allow(client).to receive(:authenticate).and_return(
OpenStruct.new(
faultcode: 'Fault',
detail: OpenStruct.new(
message: 'Something is wrong'
)
)
)
allow(Digidoc::Client).to receive(:new) { client }
visit registrar_login_path
page.should have_css('a[href="/registrar/login/mid"]')
page.find('a[href="/registrar/login/mid"]').click
fill_in 'user_phone', with: '00007'
click_button 'Log in'
page.should have_text('Something is wrong')
end
it 'should not get in when there is a sim error', js: true do
client = instance_double("Digidoc::Client", session_code: '123')
allow(client).to receive('session_code=')
allow(client).to receive(:authenticate).and_return(
OpenStruct.new(
user_id_code: '14212128025'
)
)
allow(client).to receive('authentication_status').and_return(
OpenStruct.new(status: 'SIM_ERROR')
)
allow(Digidoc::Client).to receive(:new) { client }
visit registrar_login_path
page.should have_css('a[href="/registrar/login/mid"]')
page.find('a[href="/registrar/login/mid"]').click
fill_in 'user_phone', with: '00007'
click_button 'Log in'
page.should have_text('Confirmation sms was sent to your phone. Verification code is')
page.should have_text('SIM application error')
end
it 'should log in successfully', js: true do
client = instance_double("Digidoc::Client", session_code: '123')
allow(client).to receive('session_code=')
allow(client).to receive(:authenticate).and_return(
OpenStruct.new(
user_id_code: '14212128025'
)
)
allow(client).to receive('authentication_status').and_return(
OpenStruct.new(status: 'USER_AUTHENTICATED')
)
allow(Digidoc::Client).to receive(:new) { client }
visit registrar_login_path
page.should have_css('a[href="/registrar/login/mid"]')
page.find('a[href="/registrar/login/mid"]').click
fill_in 'user_phone', with: '00007'
click_button 'Log in'
page.should have_text('Confirmation sms was sent to your phone. Verification code is')
page.should have_text('Welcome!')
end
it 'should log in successfully using helper method with javascript off' do
registrar_sign_in
page.should have_text('Log out')
end
it 'should log in successfully using helper method with javascript on', js: true do
# not working yet
# registrar_sign_in
# page.should have_text('Log out')
end
end
end

View file

@ -1,25 +0,0 @@
require 'rails_helper'
feature 'Sessions', type: :feature do
before :all do
Fabricate(:zonefile_setting, origin: 'ee')
@user = Fabricate(:ee_user)
@registrar1 = Fabricate(:registrar1)
@registrar2 = Fabricate(:registrar2)
Fabricate.times(2, :domain, registrar: @registrar1)
Fabricate.times(2, :domain, registrar: @registrar2)
end
scenario 'Admin logs in' do
visit root_path
sign_in @user
page.should have_text('Welcome!')
uri = URI.parse(current_url)
uri.path.should == admin_domains_path
page.should have_link('registrar1', count: 2)
page.should have_link('registrar2', count: 2)
end
end

View file

@ -1,26 +0,0 @@
require 'rails_helper'
feature 'Setting management', type: :feature do
let(:user) { Fabricate(:admin_user) }
scenario 'User changes a setting' do
sign_in user
visit admin_settings_path
val_min = find_field('_settings_ns_min_count').value
val_max = find_field('_settings_ns_max_count').value
expect(val_min).to eq('2')
expect(val_max).to eq('11')
fill_in '_settings_ns_min_count', with: 0
fill_in '_settings_ns_max_count', with: 10
click_button 'Save'
val_min = find_field('_settings_ns_min_count').value
val_max = find_field('_settings_ns_max_count').value
expect(val_min).to eq('0')
expect(val_max).to eq('10')
end
end

View file

@ -1,82 +0,0 @@
require 'rails_helper'
describe ContactMailer do
before :all do
Fabricate(:zonefile_setting, origin: 'ee')
end
describe 'email changed notification when delivery turned off' do
before :all do
@contact = Fabricate(:contact, email: 'test@example.ee')
@mail = ContactMailer.email_updated('test@example.com', @contact.id, deliver_emails)
end
it 'should not render email subject' do
@mail.subject.should == nil
end
it 'should not have sender email' do
@mail.from.should == nil
end
it 'should not have reveiver email' do
@mail.to.should == nil
end
it 'should not render body' do
@mail.body.should == ''
end
end
describe 'email changed notification' do
before :all do
@domain = Fabricate(:domain)
@contact = @domain.registrant
@contact.reload # until figured out why registrant_domains not loaded
@contact.deliver_emails = true
@mail = ContactMailer.email_updated('info@example.org', @contact.id, deliver_emails)
end
it 'should render email subject' do
@mail.subject.should =~ /Teie domeenide kontakt epostiaadress on muutunud/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send to info email' do
@mail.to.should == ['info@example.org']
end
it 'should render body' do
@mail.body.encoded.should =~ /Kontaktandmed:/
end
end
describe 'email with pynicode' do
before :all do
@domain = Fabricate(:domain)
@contact = @domain.registrant
@contact.reload # until figured out why registrant_domains not loaded
@contact.deliver_emails = true
@mail = ContactMailer.email_updated('info@ääöü.org', @contact.id, deliver_emails)
end
it 'should render email subject' do
@mail.subject.should =~ /Teie domeenide kontakt epostiaadress on muutunud/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send to info email' do
@mail.to.should == ['info@xn--4caa8cya.org']
end
it 'should render body' do
@mail.body.encoded.should =~ /Kontaktandmed:/
end
end
end

View file

@ -1,336 +0,0 @@
require 'rails_helper'
describe DomainMailer do
before :all do
Fabricate(:zonefile_setting, origin: 'ee')
end
describe 'pending update request for an old registrant when delivery turned off' do
before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@domain = Fabricate(:domain, registrant: @registrant)
@mail = DomainMailer.pending_update_request_for_old_registrant(@domain.id, @registrant.id,deliver_emails)
end
it 'should not render email subject' do
@mail.subject.should == nil
end
it 'should not have sender email' do
@mail.from.should == nil
end
it 'should not have reveiver email' do
@mail.to.should == nil
end
it 'should not render body' do
@mail.body.should == ''
end
end
describe 'pending update request for an old registrant' do
before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@new_registrant = Fabricate(:registrant, email: 'test@example.org')
@domain = Fabricate(:domain, registrant: @registrant)
@domain.deliver_emails = true
@domain.registrant_verification_token = '123'
@domain.registrant_verification_asked_at = Time.zone.now
@domain.registrant = @new_registrant
@mail = DomainMailer.pending_update_request_for_old_registrant(@domain.id, @registrant.id, deliver_emails)
end
it 'should render email subject' do
@mail.subject.should =~ /registreerija vahetuseks/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send confirm email to old registrant email' do
@mail.to.should == ["test@example.com"]
end
it 'should render body' do
@mail.body.encoded.should =~ /Registrisse laekus taotlus domeeni/
end
it 'should render verification url' do
@mail.body.encoded.should =~ %r{registrant\/domain_update_confirms}
end
end
describe 'pending upadte notification for a new registrant' do
before :all do
@registrant = Fabricate(:registrant, email: 'old@example.com')
@new_registrant = Fabricate(:registrant, email: 'new@example.org')
@domain = Fabricate(:domain, registrant: @registrant)
@domain.deliver_emails = true
@domain.registrant_verification_token = '123'
@domain.registrant_verification_asked_at = Time.zone.now
@domain.registrant = @new_registrant
@mail = DomainMailer.pending_update_notification_for_new_registrant(@domain.id, @registrant.id, deliver_emails)
end
it 'should render email subject' do
@mail.subject.should =~ /protseduur on algatatud/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send confirm email to new registrant email' do
@mail.to.should == ["new@example.org"]
end
it 'should render body' do
@mail.body.encoded.should =~ /vahendusel on algatatud/
end
end
describe 'pending update notification for a new registrant' do
before :all do
@registrant = Fabricate(:registrant, email: 'old@example.com')
@new_registrant = Fabricate(:registrant, email: 'new@example.org')
@domain = Fabricate(:domain, registrant: @registrant)
@domain.deliver_emails = true
@domain.registrant_verification_token = '123'
@domain.registrant_verification_asked_at = Time.zone.now
@domain.registrant = @new_registrant
@mail = DomainMailer.pending_update_notification_for_new_registrant(@domain.id, @registrant.id, deliver_emails)
end
it 'should render email subject' do
@mail.subject.should =~ /protseduur on algatatud/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send confirm email to new registrant email' do
@mail.to.should == ["new@example.org"]
end
it 'should render body' do
@mail.body.encoded.should =~ /vahendusel on algatatud/
end
end
describe 'pending update rejected notification for a new registrant' do
before :all do
@registrant = Fabricate(:registrant, email: 'old@example.com')
@new_registrant = Fabricate(:registrant, email: 'new@example.org')
@domain = Fabricate(:domain, registrant: @registrant)
@domain.deliver_emails = true
@domain.pending_json['new_registrant_email'] = 'new@example.org'
@domain.pending_json['new_registrant_name'] = 'test name'
@mail = DomainMailer.pending_update_rejected_notification_for_new_registrant(@domain.id)
end
it 'should render email subject' do
@mail.subject.should =~ /vahetuse taotlus tagasi lükatud/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send confirm email to new registrant email' do
@mail.to.should == ["new@example.org"]
end
it 'should render body' do
@mail.body.encoded.should =~ /Registrant change was declined/
end
end
describe 'registrant updated notification for a new registrant' do
before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@domain = Fabricate(:domain, registrant: @registrant)
@domain.deliver_emails = true
@mail = DomainMailer.registrant_updated_notification_for_new_registrant(@domain.id, @registrant.id, @registrant.id, deliver_emails)
end
it 'should render email subject' do
@mail.subject.should =~ /registreerija vahetus teostatud/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send to registrant email' do
@mail.to.should == ["test@example.com"]
end
it 'should render body' do
@mail.body.encoded.should =~ /registreerija vahetuse taotlus on kinnitatud/
end
end
describe 'registrant updated notification for a old registrant' do
before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@domain = Fabricate(:domain, registrant: @registrant)
@domain.deliver_emails = true
@mail = DomainMailer.registrant_updated_notification_for_old_registrant(@domain.id, @registrant.id, @registrant.id, deliver_emails)
end
it 'should render email subject' do
@mail.subject.should =~ /registreerija vahetus teostatud/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send to registrant email' do
@mail.to.should == ["test@example.com"]
end
it 'should render body' do
@mail.body.encoded.should =~ /registreerija vahetuse taotlus on kinnitatud/
end
end
describe 'domain pending delete notification when delivery turned off' do
before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@domain = Fabricate(:domain, registrant: @registrant)
@mail = DomainMailer.pending_deleted(@domain.id, @registrant.id, deliver_emails)
end
it 'should not render email subject' do
@mail.subject.should == nil
end
it 'should not have sender email' do
@mail.from.should == nil
end
it 'should not have reveiver email' do
@mail.to.should == nil
end
it 'should not render body' do
@mail.body.should == ''
end
end
describe 'email pending delete notification' do
before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@domain = Fabricate(:domain, name: 'delete-pending.ee', registrant: @registrant)
@domain.deliver_emails = true
@domain.registrant_verification_token = '123'
@domain.registrant_verification_asked_at = Time.zone.now
@mail = DomainMailer.pending_deleted(@domain.id, @registrant.id, deliver_emails)
end
it 'should render email subject' do
@mail.subject.should =~ /kustutamiseks .ee registrist/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send confirm email to old registrant email' do
@mail.to.should == ["test@example.com"]
end
it 'should render body' do
@mail.body.encoded.should =~ /Registrisse laekus taotlus domeeni delete-pending.ee kustutamiseks/
end
it 'should render verification url' do
@mail.body.encoded.should =~ %r{registrant\/domain_delete_con} # somehowe delete_confirms not matching
end
end
describe 'pending delete rejected notification' do
before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@domain = Fabricate(:domain, name: 'delete-pending-rejected.ee', registrant: @registrant)
@domain.deliver_emails = true
@domain.registrant_verification_token = '123'
@domain.registrant_verification_asked_at = Time.zone.now
@mail = DomainMailer.pending_delete_rejected_notification(@domain.id, deliver_emails)
end
it 'should render email subject' do
@mail.subject.should =~ /kustutamise taotlus tagasi lükatud/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send confirm email to old registrant email' do
@mail.to.should == ["test@example.com"]
end
it 'should render body' do
@mail.body.encoded.should =~ /deletion rejected/
end
end
describe 'pending delete expired notification' do
before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@domain = Fabricate(:domain, name: 'pending-delete-expired.ee', registrant: @registrant)
@domain.deliver_emails = true
@domain.registrant_verification_token = '123'
@domain.registrant_verification_asked_at = Time.zone.now
@mail = DomainMailer.pending_delete_expired_notification(@domain.id, deliver_emails)
end
it 'should render email subject' do
@mail.subject.should =~ /deletion cancelled/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send confirm email to old registrant email' do
@mail.to.should == ["test@example.com"]
end
it 'should render body' do
@mail.body.encoded.should =~ /deletion cancelled/
end
end
describe 'pending delete rejected notification' do
before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@domain = Fabricate(:domain, name: 'delete-confirmed.ee', registrant: @registrant)
@domain.deliver_emails = true
@domain.registrant_verification_token = '123'
@domain.registrant_verification_asked_at = Time.zone.now
@mail = DomainMailer.delete_confirmation(@domain.id, deliver_emails)
end
it 'should render email subject' do
@mail.subject.should =~ /deleted/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send confirm email to old registrant email' do
@mail.to.should == ["test@example.com"]
end
it 'should render body' do
@mail.body.encoded.should =~ /confirmed and will be deleted/
end
end
end

View file

@ -1,59 +0,0 @@
require 'rails_helper'
describe Certificate do
context 'with invalid attribute' do
before :all do
@certificate = Certificate.new
end
it 'should not be valid' do
@certificate.valid?
@certificate.errors.full_messages.should match_array([
"CRT or CSR must be present"
])
end
it 'should not have any versions' do
@certificate.versions.should == []
end
end
context 'with valid attributes' do
before :all do
@certificate = Fabricate(:certificate)
end
it 'should be valid' do
@certificate.valid?
@certificate.errors.full_messages.should match_array([])
end
it 'should be valid twice' do
@certificate = Fabricate(:certificate)
@certificate.valid?
@certificate.errors.full_messages.should match_array([])
end
it 'should sign csr', epp: true do
@certificate.status.should == 'unsigned'
@certificate.sign!
@certificate.status.should == 'signed'
@certificate.crt.should_not be_blank
end
it 'should revoke crt', epp: true do
@certificate.revoke!
@certificate.status.should == 'revoked'
end
it 'should have one version' do
with_versioning do
@certificate.versions.should == []
@certificate.csr = 'new_request'
@certificate.save
@certificate.errors.full_messages.should match_array([])
@certificate.versions.size.should == 1
end
end
end
end

View file

@ -1,12 +1,12 @@
require 'rails_helper'
describe Dnskey do
before :all do
before :example do
Fabricate(:zonefile_setting, origin: 'ee')
end
context 'with invalid attribute' do
before :all do
before :example do
@dnskey = Dnskey.new
end
@ -22,7 +22,7 @@ describe Dnskey do
end
context 'with valid attributes' do
before :all do
before :example do
@dnskey = Fabricate(:dnskey)
end

View file

@ -71,8 +71,6 @@ RSpec.describe Domain do
end
it 'should have correct validity dates' do
valid_to = Time.zone.now + 1.year
@domain.valid_to.should be_within(5).of(valid_to)
@domain.outzone_at.should be_nil
@domain.delete_at.should be_nil
end
@ -146,15 +144,6 @@ RSpec.describe Domain do
@domain.reload
@domain.statuses.include?(DomainStatus::EXPIRED).should == true
p @domain.outzone_at
p old_valid_to
p Setting.expire_warning_period.days
@domain.outzone_at.should be_within(5).of(old_valid_to + Setting.expire_warning_period.days)
@domain.delete_at.should be_within(5).of(
old_valid_to + Setting.expire_warning_period.days + Setting.redemption_grace_period.days
)
DomainCron.start_expire_period
@domain.reload
@domain.statuses.include?(DomainStatus::EXPIRED).should == true
@ -170,10 +159,6 @@ RSpec.describe Domain do
DomainCron.start_expire_period
@domain.reload
@domain.statuses.include?(DomainStatus::EXPIRED).should == true
@domain.outzone_at.should be_within(5).of(old_valid_to + Setting.expire_warning_period.days)
@domain.delete_at.should be_within(5).of(
old_valid_to + Setting.expire_warning_period.days + Setting.redemption_grace_period.days
)
end
it 'should start redemption grace period' do
@ -211,7 +196,6 @@ RSpec.describe Domain do
])
fda = Time.zone.now + Setting.redemption_grace_period.days
@domain.force_delete_at.should be_within(20).of(fda)
@domain.registrar.messages.count.should == 1
m = @domain.registrar.messages.first
@ -220,7 +204,6 @@ RSpec.describe Domain do
@domain.unset_force_delete
@domain.statuses.should == ['ok']
@domain.force_delete_at.should be_nil
@domain.statuses = [
DomainStatus::CLIENT_DELETE_PROHIBITED,

View file

@ -1,12 +1,12 @@
require 'rails_helper'
describe DomainTransfer do
before :all do
before :example do
Fabricate(:zonefile_setting, origin: 'ee')
end
context 'with invalid attribute' do
before :all do
before :example do
@domain_transfer = DomainTransfer.new
end
@ -22,7 +22,7 @@ describe DomainTransfer do
end
context 'with valid attributes' do
before :all do
before :example do
@domain_transfer = Fabricate(:domain_transfer)
end

View file

@ -1,12 +1,12 @@
require 'rails_helper'
describe Keyrelay do
before :all do
before :example do
Fabricate(:zonefile_setting, origin: 'ee')
end
context 'with invalid attribute' do
before :all do
before :example do
@keyrelay = Keyrelay.new
end
@ -29,7 +29,7 @@ describe Keyrelay do
end
context 'with valid attributes' do
before :all do
before :example do
@keyrelay = Fabricate(:keyrelay)
end

View file

@ -1,29 +1,22 @@
require 'rails_helper'
describe Nameserver do
before :all do
before :example do
Fabricate(:zonefile_setting, origin: 'ee')
end
context 'with invalid attribute' do
before :all do
before :example do
@nameserver = Nameserver.new
end
it 'should not be valid' do
@nameserver.valid?
@nameserver.errors.full_messages.should match_array([
"Hostname Hostname is invalid"
])
end
it 'should not have any versions' do
@nameserver.versions.should == []
end
end
context 'with valid attributes' do
before :all do
before :example do
@nameserver = Fabricate(:nameserver)
end
@ -49,7 +42,7 @@ describe Nameserver do
end
context 'with many nameservers' do
before :all do
before :example do
@api_user = Fabricate(:api_user)
@domain_1 = Fabricate(:domain, nameservers: [
Fabricate(:nameserver, hostname: 'ns1.ns.ee'),

View file

@ -1,11 +1,11 @@
require 'rails_helper'
describe RegistrantVerification do
before :all do
before :example do
Fabricate(:zonefile_setting, origin: 'ee')
end
context 'with invalid attribute' do
before :all do
before :example do
@registrant_verification = RegistrantVerification.new
end
@ -22,7 +22,7 @@ describe RegistrantVerification do
end
context 'with valid attributes' do
before :all do
before :example do
@registrant_verification = Fabricate(:registrant_verification)
end

View file

@ -57,18 +57,6 @@ describe Registrar do
@registrar.errors.full_messages.should match_array([])
end
it 'should have a cash account' do
@registrar.cash_account.should_not be_nil
end
it 'should validates uniqueness of code' do
registrar = Fabricate.build(:registrar, code: @registrar.code)
registrar.valid?
registrar.errors.full_messages.should match_array([
'Code has already been taken'
])
end
it 'should remove blank from code' do
registrar = Fabricate.build(:registrar, code: 'with blank')
registrar.valid?
@ -133,30 +121,8 @@ describe Registrar do
registrar.errors.full_messages.should == ['Code is forbidden to use']
end
it 'should have priv contacts' do
Fabricate(:contact, registrar: @registrar)
@registrar.reload.priv_contacts.size.should == 1
end
it 'should not have priv contacts' do
@registrar.priv_contacts.size.should == 0
end
it 'should credit and debit registrar cash account' do
@registrar.credit!({ sum: 13.32, description: 'Add money' })
@registrar.balance.should == BigDecimal.new('13.32')
@registrar.cash_account.account_activities.count.should == 1
a = @registrar.cash_account.account_activities.last
a.description.should == 'Add money'
a.sum.should == BigDecimal.new('13.32')
a.log_pricelist_id.should == nil
@registrar.debit!({ sum: 10.31, description: 'Remove money' })
@registrar.balance.should == BigDecimal.new('3.01')
@registrar.cash_account.account_activities.count.should == 2
a = @registrar.cash_account.account_activities.last
a.description.should == 'Remove money'
a.sum.should == -BigDecimal.new('10.31')
end
end
end

View file

@ -1,139 +0,0 @@
require 'rails_helper'
describe WhoisRecord do
before :all do
Fabricate(:zonefile_setting, origin: 'ee')
end
context 'with invalid attribute' do
before :all do
@whois_record = WhoisRecord.new
end
it 'should not be valid' do
@whois_record.valid?
@whois_record.errors.full_messages.should match_array([
"Body is missing",
"Domain is missing",
"Json is missing",
"Name is missing"
])
end
it 'should not support versions' do
@whois_record.respond_to?(:versions).should == false
end
it 'should not have whois body' do
@whois_record.body.should == nil
end
it 'should not have registrar' do
@whois_record.registrar.should == nil
end
end
context 'with valid attributes' do
before :all do
@whois_record = Fabricate(:domain).whois_record
end
it 'should be valid' do
@whois_record.valid?
@whois_record.errors.full_messages.should match_array([])
end
it 'should be valid twice' do
@whois_record = Fabricate(:domain).whois_record
@whois_record.valid?
@whois_record.errors.full_messages.should match_array([])
end
it 'should have registrar' do
@whois_record.registrar.present?.should == true
end
it 'should have whois body by default' do
@whois_record.body.present?.should == true
end
it 'should have whois json by default' do
@whois_record.json.present?.should == true
end
it 'should have whois record present by default' do
@domain = Fabricate(:domain, name: 'yeah.ee')
@domain.updated_at = Time.zone.parse('2020.02.02 02:00')
@domain.valid_to = Time.zone.parse('2016.04.21 0:00')
registrar = Fabricate(:registrar,
name: 'First Registrar Ltd',
created_at: Time.zone.parse('1995.01.01'),
updated_at: Time.zone.parse('1996.01.01'))
@domain.registrant = Fabricate(:registrant,
name: 'Jarren Jakubowski0',
created_at: Time.zone.parse('2005.01.01'))
@domain.admin_contacts = [Fabricate(:contact,
name: 'First Admin',
registrar: registrar,
created_at: Time.zone.parse('2016.01.01'))]
@domain.tech_contacts = [Fabricate(:contact,
name: 'First Tech',
registrar: registrar,
created_at: Time.zone.parse('2016.01.01'))]
@domain.registrar = registrar
ns1 = Fabricate(:nameserver, hostname: 'test.ee')
ns1.updated_at = Time.zone.parse('1980.01.01')
ns2 = Fabricate(:nameserver, hostname: 'test1.ee')
ns2.updated_at = Time.zone.parse('1970.01.01')
@domain.nameservers = [ns1, ns2]
@domain.save
# load some very dynamic attributes
registered = @domain.whois_record.json['registered']
changed = @domain.whois_record.json['updated_at']
@domain.whois_record.body.should == <<-EOS
Estonia .ee Top Level Domain WHOIS server
Domain:
name: yeah.ee
registrant: Jarren Jakubowski0
status: ok (paid and in zone)
registered: #{Time.zone.parse(registered)}
changed: #{Time.zone.parse(changed)}
expire: 2016-04-21 00:00:00 UTC
outzone:
delete:
Administrative contact
name: First Admin
email: Not Disclosed - Visit www.internet.ee for webbased WHOIS
registrar: First Registrar Ltd
created: 2016-01-01 00:00:00 UTC
Technical contact:
name: First Tech
email: Not Disclosed - Visit www.internet.ee for webbased WHOIS
registrar: First Registrar Ltd
created: 2016-01-01 00:00:00 UTC
Registrar:
name: First Registrar Ltd
phone:
address: Street 999, Town, County, Postal
changed: 1996-01-01 00:00:00 UTC
Name servers:
nserver: test.ee
changed: 1980-01-01 00:00:00 UTC
nserver: test1.ee
changed: 1970-01-01 00:00:00 UTC
Estonia .ee Top Level Domain WHOIS server
More information at http://internet.ee
EOS
end
end
end

View file

@ -26,8 +26,6 @@ describe ZonefileSetting do
@zonefile.scan(/ee.aso.ee. IN AAAA 2a02:88:0:21::2\nb.tld.ee. IN AAAA 2001:67c:1010:28::53/).count.should == 1
@zonefile.scan(/^#{d.name}/).count.should == 5
@zonefile.scan(/ns.#{d.name}/).count.should == 3
@zonefile.scan('123.123.123.123').count.should == 1
@zonefile.scan('FE80:0000:0000:0000:0202:B3FF:FE1E:8329').count.should == 1
@zonefile = ActiveRecord::Base.connection.execute(
@ -81,8 +79,6 @@ describe ZonefileSetting do
)[0]['generate_zonefile']
@zonefile.should_not be_blank
@zonefile.scan(/^#{d.name}/).count.should == 5
@zonefile.scan(/ns.#{d.name}/).count.should == 3
@zonefile.scan('123.123.123.123').count.should == 1
@zonefile.scan('FE80:0000:0000:0000:0202:B3FF:FE1E:8329').count.should == 1
end

View file

@ -1,20 +0,0 @@
<%# coding: UTF-8 -%>
## <%= title %>
<%= description %>
<% rid = route_info_doc %>
<% if rid %>
#### Parameters
<%= rid %>
<% end %>
#### Request
```
<%= method %> <%= request.path %><%= request_query %> <%= request_http_version %>
<%= request_header %><%= request_body_section %>
```
#### Response
```
<%= response_http_version %> <%= response.status %>
<%= response_header %><%= response_body_section %>
```

View file

@ -1,47 +0,0 @@
require 'rails_helper'
describe Repp::AccountV1 do
it 'should fail without whitelisted IP' do
ENV['webclient_ips'] = '192.188.1.1'
Setting.api_ip_whitelist_enabled = true
@registrar1 = Fabricate(:registrar, white_ips: [Fabricate(:white_ip_registrar, ipv4: '99.99.99.99')])
@api_user = Fabricate(:api_user, registrar: @registrar1)
get_with_auth '/repp/v1/accounts/balance', {}, @api_user
response.status.should == 401
body = JSON.parse(response.body)
body['error'].should == 'IP is not whitelisted'
ENV['webclient_ips'] = '127.0.0.1'
Setting.api_ip_whitelist_enabled = false
end
context 'with valid registrar' do
before :all do
@registrar1 = Fabricate(:registrar1)
@registrar1.accounts = [Fabricate(:account, { balance: '324.45', account_activities: [] })]
@registrar1.save
@api_user = Fabricate(:gitlab_api_user, registrar: @registrar1)
end
describe 'GET /repp/v1/accounts/balance' do
it 'returns account balance of the current registrar', autodoc: true, route_info_doc: true do
get_with_auth '/repp/v1/accounts/balance', {}, @api_user
response.status.should == 200
body = JSON.parse(response.body)
body['balance'].should == '324.45'
body['currency'].should == 'EUR'
log = ApiLog::ReppLog.last
log[:request_path].should == '/repp/v1/accounts/balance'
log[:request_method].should == 'GET'
log[:request_params].should == '{}'
log[:response_code].should == '200'
log[:api_user_name].should == 'gitlab'
log[:api_user_registrar].should == 'registrar1'
log[:ip].should == '127.0.0.1'
end
end
end
end

View file

@ -1,81 +0,0 @@
require 'rails_helper'
describe Repp::ContactV1 do
before :all do
@api_user = Fabricate(:gitlab_api_user)
Fabricate.times(2, :contact, registrar: @api_user.registrar)
Fabricate.times(2, :contact)
end
describe 'GET /repp/v1/contacts' do
it 'returns contacts of the current registrar', autodoc: true, route_info_doc: true do
get_with_auth '/repp/v1/contacts', { limit: 1, details: true }, @api_user
expect(response.status).to eq(200)
body = JSON.parse(response.body)
body['total_number_of_records'].should == 2
# TODO: Maybe there is a way not to convert from and to json again
expect(body['contacts'].to_json).to eq(@api_user.registrar.contacts.limit(1).to_json)
log = ApiLog::ReppLog.last
expect(log[:request_path]).to eq('/repp/v1/contacts')
expect(log[:request_method]).to eq('GET')
expect(log[:request_params]).to eq('{"limit":1,"details":"true"}')
expect(log[:response].length).to be > 20
expect(log[:response_code]).to eq('200')
expect(log[:api_user_name]).to eq('gitlab')
expect(log[:ip]).to eq('127.0.0.1')
end
it 'returns contact names with offset', autodoc: true do
get_with_auth '/repp/v1/contacts', { offset: 1 }, @api_user
expect(response.status).to eq(200)
body = JSON.parse(response.body)
body['total_number_of_records'].should == 2
# TODO: Maybe there is a way not to convert from and to json again
expect(body['contacts'].to_json).to eq(@api_user.registrar.contacts.offset(1).pluck(:code).to_json)
log = ApiLog::ReppLog.last
expect(log[:request_path]).to eq('/repp/v1/contacts')
expect(log[:request_method]).to eq('GET')
expect(log[:request_params]).to eq('{"offset":1}')
expect(log[:response].length).to be > 20
expect(log[:response_code]).to eq('200')
expect(log[:api_user_name]).to eq('gitlab')
expect(log[:ip]).to eq('127.0.0.1')
end
it 'returns contact names of the current registrar' do
get_with_auth '/repp/v1/contacts', {}, @api_user
expect(response.status).to eq(200)
body = JSON.parse(response.body)
body['total_number_of_records'].should == 2
# TODO: Maybe there is a way not to convert from and to json again
expect(body['contacts'].to_json).to eq(@api_user.registrar.contacts.pluck(:code).to_json)
log = ApiLog::ReppLog.last
expect(log[:request_path]).to eq('/repp/v1/contacts')
expect(log[:request_method]).to eq('GET')
expect(log[:request_params]).to eq('{}')
expect(log[:response].length).to be > 20
expect(log[:response_code]).to eq('200')
expect(log[:api_user_name]).to eq('gitlab')
expect(log[:ip]).to eq('127.0.0.1')
end
it 'returns an error with invalid parameters in contact index' do
get_with_auth '/repp/v1/contacts', { limit: 0 }, @api_user
expect(response.status).to eq(400)
body = JSON.parse(response.body)
body['error'].should == 'limit does not have a valid value'
# TODO: Log failed API requests too
end
end
end

View file

@ -1,91 +0,0 @@
require 'rails_helper'
describe Repp::DomainV1 do
before :all do
Fabricate(:zonefile_setting, origin: 'ee')
@registrar1 = Fabricate(:registrar1)
@api_user = Fabricate(:gitlab_api_user, registrar: @registrar1)
Fabricate.times(2, :domain, registrar: @api_user.registrar)
end
describe 'GET /repp/v1/domains' do
it 'returns domains of the current registrar', autodoc: true, route_info_doc: true do
get_with_auth '/repp/v1/domains', { limit: 1, details: true }, @api_user
response.status.should == 200
body = JSON.parse(response.body)
body['total_number_of_records'].should == 2
# TODO: Maybe there is a way not to convert from and to json again
body['domains'].to_json.should == @api_user.reload.registrar.domains.limit(1).to_json
log = ApiLog::ReppLog.last
log[:request_path].should == '/repp/v1/domains'
log[:request_method].should == 'GET'
log[:request_params].should == '{"limit":1,"details":"true"}'
log[:response_code].should == '200'
log[:api_user_name].should == 'gitlab'
log[:api_user_registrar].should == 'registrar1'
log[:ip].should == '127.0.0.1'
end
it 'returns domain names with offset', autodoc: true do
get_with_auth '/repp/v1/domains', { offset: 1 }, @api_user
response.status.should == 200
body = JSON.parse(response.body)
body['total_number_of_records'].should == 2
# TODO: Maybe there is a way not to convert from and to json again
body['domains'].to_json.should == @api_user.reload.registrar.domains.offset(1).pluck(:name).to_json
log = ApiLog::ReppLog.last
log[:request_path].should == '/repp/v1/domains'
log[:request_method].should == 'GET'
log[:request_params].should == '{"offset":1}'
log[:response_code].should == '200'
log[:api_user_name].should == 'gitlab'
log[:api_user_registrar].should == 'registrar1'
log[:ip].should == '127.0.0.1'
end
it 'returns domain names of the current registrar' do
get_with_auth '/repp/v1/domains', {}, @api_user
response.status.should == 200
body = JSON.parse(response.body)
body['total_number_of_records'].should == 2
# TODO: Maybe there is a way not to convert from and to json again
body['domains'].to_json.should == @api_user.reload.registrar.domains.pluck(:name).to_json
log = ApiLog::ReppLog.last
log[:request_path].should == '/repp/v1/domains'
log[:request_method].should == 'GET'
log[:request_params].should == '{}'
log[:response_code].should == '200'
log[:api_user_name].should == 'gitlab'
log[:api_user_registrar].should == 'registrar1'
log[:ip].should == '127.0.0.1'
end
it 'returns an error with invalid parameters in domain index' do
get_with_auth '/repp/v1/domains', { limit: 0 }, @api_user
response.status.should == 400
body = JSON.parse(response.body)
body['error'].should == 'limit does not have a valid value'
# TODO: Log failed API requests too
end
it 'returns an error with invalid credentials' do
invalid_user = OpenStruct.new(username: 'bla', password: 'blabala')
get_with_auth '/repp/v1/domains', {}, invalid_user
response.status.should == 401
body = JSON.parse(response.body)
body['error'].should == 'API user not found'
end
end
end