diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb
deleted file mode 100644
index 4a8f35bb6..000000000
--- a/spec/epp/contact_spec.rb
+++ /dev/null
@@ -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
- '
-
-
-
-
- FIXED:CHECK-1234
- check-4321
-
-
- ABC-12345
-
- '
- end
-
- def check_multiple_legacy_contacts_xml
- '
-
-
-
-
- FIXED:CHECK-LEGACY
- CID:FIXED:CHECK-LEGACY
-
-
- ABC-12345
-
- '
- end
-
-end
diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb
deleted file mode 100644
index ccf13c8b5..000000000
--- a/spec/epp/domain_spec.rb
+++ /dev/null
@@ -1,3157 +0,0 @@
-require 'rails_helper'
-
-describe 'EPP Domain', epp: true do
- before(:all) do
- @xsd = Nokogiri::XML::Schema(File.read('lib/schemas/domain-eis-1.0.xsd'))
- @epp_xml = EppXml.new(cl_trid: 'ABC-12345')
-
- 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, code: 'REGDOMAIN1')
- @registrar1.credit!({ sum: 10000 })
- @registrar2 = Fabricate(:registrar2, code: 'REGDOMAIN2')
- @registrar2.credit!({ sum: 10000 })
- Fabricate(:api_user, username: 'registrar1', registrar: @registrar1)
- Fabricate(:api_user, username: 'registrar2', registrar: @registrar2)
-
- login_as :registrar1
-
- Fabricate(:contact, code: 'FIXED:CITIZEN_1234')
- Fabricate(:contact, code: 'FIXED:SH8013')
- Fabricate(:contact, code: 'FIXED:SH801333')
- Fabricate(:contact, code: 'FIXED:JURIDICAL_1234', ident_type: 'org')
- Fabricate(:reserved_domain)
- Fabricate(:blocked_domain)
- @pricelist_reg_1_year = Fabricate(:pricelist, valid_to: nil)
- @pricelist_reg_2_year = Fabricate(:pricelist, duration: '2years', price: 20, valid_to: nil)
- Fabricate(:pricelist, duration: '3years', price: 30, valid_to: nil)
- @pricelist_renew_1_year = Fabricate(:pricelist, operation_category: 'renew', price: 15, valid_to: nil)
- Fabricate(:pricelist, operation_category: 'renew', duration: '2years', price: 35, valid_to: nil)
- Fabricate(:pricelist, operation_category: 'renew', duration: '3years', price: 62, valid_to: nil)
-
- @uniq_no = proc { @i ||= 0; @i += 1 }
- end
-
- it 'should return error if balance low' do
- f = Fabricate(:pricelist, valid_to: Time.zone.now + 1.day, price: 100000)
-
- dn = next_domain_name
- response = epp_plain_request(domain_create_xml({
- name: { value: dn }
- }))
-
- response[:msg].should == "Billing failure - credit balance low"
- response[:result_code].should == '2104'
- f.delete
- end
-
- it 'returns error if contact does not exists' do
- response = epp_plain_request(domain_create_xml({
- registrant: { value: 'FIXED:CITIZEN_1234' },
- _anonymus: [
- { contact: { value: 'FIXED:CITIZEN_1234', attrs: { type: 'admin' } } },
- { contact: { value: 'sh1111', attrs: { type: 'tech' } } },
- { contact: { value: 'sh2222', attrs: { type: 'tech' } } }
- ]
- }))
-
- response[:results][0][:msg].should == 'Contact was not found'
- response[:results][0][:result_code].should == '2303'
- response[:results][0][:value].should == 'sh1111'
-
- response[:results][1][:msg].should == 'Contact was not found'
- response[:results][1][:result_code].should == '2303'
- response[:results][1][:value].should == 'sh2222'
-
- response[:clTRID].should == 'ABC-12345'
-
- log = ApiLog::EppLog.last
-
- log.request_command.should == 'create'
- log.request_object.should == 'domain'
- log.request_successful.should == false
- log.api_user_name.should == 'registrar1'
- log.api_user_registrar.should == 'registrar1'
- log.request.should_not be_blank
- log.response.should_not be_blank
- end
-
- it 'validates required parameters' do
- epp_xml = EppXml::Domain.new(cl_trid: 'ABC-12345')
- xml = epp_xml.create({
- name: { value: 'test.ee' }
- })
-
- response = epp_plain_request(xml)
- response[:results][0][:result_code].should == '2003'
- response[:results][0][:msg].should ==
- 'Required parameter missing: create > create > ns [ns]'
-
- response[:results][1][:result_code].should == '2003'
- response[:results][1][:msg].should ==
- 'Required parameter missing: create > create > registrant [registrant]'
-
- response[:results][2][:result_code].should == '2003'
- response[:results][2][:msg].should ==
- 'Required parameter missing: create > create > ns > hostAttr [host_attr]'
-
- response[:results][3][:result_code].should == '2003'
- response[:results][3][:msg].should ==
- 'Required parameter missing: extension > extdata > legalDocument [legal_document]'
- end
-
- context 'with citizen as a registrant' do
- it 'creates a domain' do
- dn = next_domain_name
- response = epp_plain_request(domain_create_xml({
- name: { value: dn }
- }))
-
- d = Domain.last
- response[:msg].should == 'Command completed successfully'
- response[:result_code].should == '1000'
-
- cre_data = response[:parsed].css('creData')
-
- cre_data.css('name').text.should == dn
- cre_data.css('crDate').text.should == d.created_at.in_time_zone.utc.utc.iso8601
- cre_data.css('exDate').text.should == d.valid_to.in_time_zone.utc.utc.iso8601
-
- response[:clTRID].should == 'ABC-12345'
-
- d.registrar.name.should == 'registrar1'
- d.tech_contacts.count.should == 2
- d.admin_contacts.count.should == 1
-
- d.nameservers.count.should == 2
- d.auth_info.should_not be_empty
-
- d.dnskeys.count.should == 1
-
- key = d.dnskeys.last
-
- key.ds_alg.should == 5
- key.ds_key_tag.should_not be_blank
-
- key.ds_digest_type.should == Setting.ds_algorithm
- key.flags.should == 257
- key.protocol.should == 3
- key.alg.should == 5
- key.public_key.should == 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8'
- end
-
- it 'creates a domain with legal document' do
- response = epp_plain_request(domain_create_xml_with_legal_doc)
-
- response[:msg].should == 'Command completed successfully'
- response[:result_code].should == '1000'
- d = Domain.last
- d.legal_documents.count.should == 1
- d.reserved.should == false
- end
-
- it 'creates a domain with custom auth info' do
- dn = next_domain_name
- response = epp_plain_request(domain_create_xml({
- name: { value: dn },
- authInfo: { pw: { value: 'asdasd' } }
- }))
-
- d = Domain.last
- response[:msg].should == 'Command completed successfully'
- response[:result_code].should == '1000'
-
- d.auth_info.should == 'asdasd'
- end
-
- # it 'creates ria.ee with valid ds record' do
- # xml = domain_create_xml({
- # name: { value: 'ria.ee' }
- # }, {
- # _anonymus: [
- # { keyData: {
- # flags: { value: '257' },
- # protocol: { value: '3' },
- # alg: { value: '8' },
- # pubKey: { value: 'AwEAAaOf5+lz3ftsL+0CCvfJbhUF/NVsNh8BKo61oYs5fXVbuWDiH872 '\
- # 'LC8uKDO92TJy7Q4TF9XMAKMMlf1GMAxlRspD749SOCTN00sqfWx1OMTu '\
- # 'a28L1PerwHq7665oDJDKqR71btcGqyLKhe2QDvCdA0mENimF1NudX1BJ '\
- # 'DDFi6oOZ0xE/0CuveB64I3ree7nCrwLwNs56kXC4LYoX3XdkOMKiJLL/ '\
- # 'MAhcxXa60CdZLoRtTEW3z8/oBq4hEAYMCNclpbd6y/exScwBxFTdUfFk '\
- # 'KsdNcmvai1lyk9vna0WQrtpYpHKMXvY9LFHaJxCOLR4umfeQ42RuTd82 lqfU6ClMeXs=' }
- # }
- # }
- # ]
- # })
-
- # epp_plain_request(xml)
-
- # d = Domain.last
- # ds = d.dnskeys.last
- # ds.ds_digest.should == '0B62D1BC64EFD1EE652FB102BDF1011BF514CCD9A1A0CFB7472AEA3B01F38C92'
- # end
-
- it 'validates nameserver ipv4 when in same zone as domain' do
- dn = next_domain_name
- xml = domain_create_xml({
- name: { value: dn },
- ns: [
- {
- hostAttr: [
- { hostName: { value: "ns1.#{dn}" } }
- ]
- },
- {
- hostAttr: {
- hostName: { value: "ns2.#{dn}" }
- }
- }
- ]
- })
-
- response = epp_plain_request(xml)
-
- response[:result_code].should == '2306'
- response[:msg].should == 'IPv4 is missing [ipv4]'
- end
-
- # it 'does not create duplicate domain' do
- # dn = next_domain_name
- # epp_plain_request(domain_create_xml({
- # name: { value: dn }
- # }))
- # response = epp_plain_request(domain_create_xml({
- # name: { value: dn }
- # }))
-
- # response[:msg].should == 'Domain name already exists'
- # response[:result_code].should == '2302'
- # response[:clTRID].should == 'ABC-12345'
- # end
-
- it 'does not create domain longer than 63 punicode characters' do
- xml = domain_create_xml(name: { value: "#{'ä' * 63}.ee" })
-
- response = epp_plain_request(xml)
- response[:msg].should == 'Domain name is too long (maximum is 63 characters) [puny_label]'
- response[:result_code].should == '2005'
- response[:clTRID].should == 'ABC-12345'
- end
-
- it 'does not create reserved domain' do
- xml = domain_create_xml(name: { value: '1162.ee' })
-
- response = epp_plain_request(xml)
- response[:msg].should == 'Required parameter missing; reserved>pw element required for reserved domains'
- response[:result_code].should == '2003'
- response[:clTRID].should == 'ABC-12345'
-
- xml = domain_create_xml({name: { value: '1162.ee' }}, {}, {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- },
- reserved: {
- pw: { value: 'wrong_pw' }
- }
- ]
- })
-
- response = epp_plain_request(xml)
- response[:msg].should == 'Invalid authorization information; invalid reserved>pw value'
- response[:result_code].should == '2202'
- end
-
- it 'creates a reserved domain with correct auth info' do
- xml = domain_create_xml({name: { value: '1162.ee' }}, {}, {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- },
- reserved: {
- pw: { value: 'abc' }
- }
- ]
- })
-
- response = epp_plain_request(xml)
- response[:msg].should == 'Command completed successfully'
- response[:result_code].should == '1000'
-
- d = Domain.last
- d.statuses.should match_array(['ok'])
- d.reserved.should == true
- end
-
- it 'does not create blocked domain' do
- xml = domain_create_xml(name: { value: 'ftp.ee' })
-
- response = epp_plain_request(xml)
- response[:msg].should == 'Data management policy violation: Domain name is blocked [name]'
- response[:result_code].should == '2308'
- response[:results][0][:value].should == 'ftp.ee'
- response[:clTRID].should == 'ABC-12345'
- end
-
- it 'does not create domain without contacts and registrant' do
- xml = domain_create_xml(_anonymus: [], registrant: false)
-
- response = epp_plain_request(xml)
- response[:results][0][:result_code].should == '2003'
- response[:results][0][:msg].should ==
- 'Required parameter missing: create > create > registrant [registrant]'
- end
-
- it 'does not create domain without nameservers' do
- xml = domain_create_xml(ns: nil)
- response = epp_plain_request(xml)
-
- response[:results][0][:msg].should ==
- 'Required parameter missing: create > create > ns [ns]'
- response[:results][0][:result_code].should == '2003'
-
- response[:results][1][:msg].should ==
- 'Required parameter missing: create > create > ns > hostAttr [host_attr]'
- response[:results][1][:result_code].should == '2003'
-
- response[:results].count.should == 2
- end
-
- it 'does not create domain with too many nameservers' do
- nameservers = []
- 14.times do |i|
- nameservers << {
- hostAttr: {
- hostName: { value: "ns#{i}.example.net" }
- }
- }
- end
-
- xml = domain_create_xml({
- ns: nameservers
- })
-
- response = epp_plain_request(xml)
- response[:result_code].should == '2004'
- response[:msg].should == 'Nameservers count must be between 2-11 [nameservers]'
- end
-
- it 'returns error when invalid nameservers are present' do
- xml = domain_create_xml({
- ns: [
- {
- hostAttr: {
- hostName: { value: 'invalid1-' }
- }
- },
- {
- hostAttr: {
- hostName: { value: '-invalid2' }
- }
- }
- ]
- })
-
- response = epp_plain_request(xml)
- response[:msg].should == 'Hostname is invalid [hostname]'
- response[:result_code].should == '2005'
- end
-
- it 'checks hostAttr presence' do
- xml = domain_create_xml({
- ns: [
- {
- hostObj: { value: 'ns1.example.ee' }
- },
- {
- hostObj: { value: 'ns2.example.ee' }
- }
- ]
- })
-
- response = epp_plain_request(xml)
- response[:msg].should == 'Required parameter missing: create > create > ns > hostAttr [host_attr]'
- response[:result_code].should == '2003'
- end
-
- it 'creates domain with nameservers with ips' do
- epp_plain_request(domain_create_with_host_attrs)
- Domain.last.nameservers.count.should == 2
- ns = Domain.last.nameservers.first
- ns.ipv4.should == '192.0.2.2'
- ns.ipv6.should == '1080:0:0:0:8:800:200C:417A'
- end
-
- it 'returns error when nameserver has invalid ips' do
- domain_count = Domain.count
- nameserver_count = Nameserver.count
- response = epp_plain_request(domain_create_with_invalid_ns_ip_xml)
- response[:results][0][:result_code].should == '2005'
- response[:results][0][:msg].should == 'IPv4 is invalid [ipv4]'
- response[:results][0][:value].should == '192.0.2.2.invalid'
- response[:results][1][:result_code].should == '2005'
- response[:results][1][:msg].should == 'IPv6 is invalid [ipv6]'
- response[:results][1][:value].should == 'INVALID_IPV6'
- # ensure nothing gets saved to db:
- Domain.count.should == domain_count
- Nameserver.count.should == nameserver_count
- end
-
- it 'creates a domain with period in days' do
- old_balance = @registrar1.balance
- old_activities = @registrar1.cash_account.account_activities.count
- xml = domain_create_xml(period: { value: '365', attrs: { unit: 'd' } })
-
- response = epp_plain_request(xml)
- response[:msg].should == 'Command completed successfully'
- response[:result_code].should == '1000'
- Domain.last.valid_to.should be_within(60).of(1.year.since)
- @registrar1.balance.should be < old_balance
- @registrar1.cash_account.account_activities.count.should == old_activities + 1
- a = @registrar1.cash_account.account_activities.last
- a.description.should == "Create #{Domain.last.name}"
- a.sum.should == -BigDecimal.new('10.0')
- a.activity_type = AccountActivity::CREATE
- a.log_pricelist_id.should == @pricelist_reg_1_year.id
- end
-
- it 'creates a domain with longer periods' do
- old_balance = @registrar1.balance
- old_activities = @registrar1.cash_account.account_activities.count
- xml = domain_create_xml(period: { value: '2', attrs: { unit: 'y' } })
-
- response = epp_plain_request(xml)
- response[:msg].should == 'Command completed successfully'
- response[:result_code].should == '1000'
- Domain.last.valid_to.should be_within(60).of(2.years.since)
- @registrar1.balance.should be < old_balance
- @registrar1.cash_account.account_activities.count.should == old_activities + 1
- a = @registrar1.cash_account.account_activities.last
- a.description.should == "Create #{Domain.last.name}"
- a.sum.should == -BigDecimal.new('20.0')
- a.activity_type = AccountActivity::CREATE
- a.log_pricelist_id.should == @pricelist_reg_2_year.id
- end
-
- it 'creates a domain with longer periods' do
- old_balance = @registrar1.balance
- old_activities = @registrar1.cash_account.account_activities.count
- xml = domain_create_xml(period: { value: '36', attrs: { unit: 'm' } })
-
- response = epp_plain_request(xml)
- response[:msg].should == 'Command completed successfully'
- response[:result_code].should == '1000'
- Domain.last.valid_to.should be_within(60).of(3.years.since)
- @registrar1.balance.should be < old_balance
- @registrar1.cash_account.account_activities.count.should == old_activities + 1
- a = @registrar1.cash_account.account_activities.last
- a.description.should == "Create #{Domain.last.name}"
- a.sum.should == -BigDecimal.new('30.0')
- a.activity_type = AccountActivity::CREATE
- end
-
- it 'creates a domain without period' do
- old_balance = @registrar1.balance
- old_activities = @registrar1.cash_account.account_activities.count
- xml = domain_create_xml(period: nil)
-
- response = epp_plain_request(xml)
- response[:msg].should == 'Command completed successfully'
- response[:result_code].should == '1000'
- Domain.last.valid_to.should be_within(60).of(1.years.since)
- @registrar1.balance.should be < old_balance
- @registrar1.cash_account.account_activities.count.should == old_activities + 1
- a = @registrar1.cash_account.account_activities.last
- a.description.should == "Create #{Domain.last.name}"
- a.sum.should == -BigDecimal.new('10.0')
- a.activity_type = AccountActivity::CREATE
- a.log_pricelist_id.should == @pricelist_reg_1_year.id
- end
-
- it 'does not create a domain with invalid period' do
- old_balance = @registrar1.balance
- old_activities = @registrar1.cash_account.account_activities.count
- xml = domain_create_xml({
- period: { value: '367', attrs: { unit: 'd' } }
- })
-
- response = epp_plain_request(xml)
- response[:results][0][:result_code].should == '2306'
- response[:results][0][:msg].should == 'Period must add up to 1, 2 or 3 years [period]'
- response[:results][0][:value].should == '367'
- @registrar1.balance.should == old_balance
- @registrar1.cash_account.account_activities.count.should == old_activities
- end
-
- it 'does not create a domain with invalid period unit' do
- xml = domain_create_xml({
- period: { value: '1', attrs: { unit: '' } }
- })
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should ==
- "Element '{https://epp.tld.ee/schema/domain-eis-1.0.xsd}period', attribute 'unit': "\
- "[facet 'enumeration'] The value '' is not an element of the set {'y', 'm', 'd'}."
- response[:results][0][:result_code].should == '2001'
-
- xml = domain_create_xml({
- period: { value: '1', attrs: { unit: 'bla' } }
- })
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should ==
- "Element '{https://epp.tld.ee/schema/domain-eis-1.0.xsd}period', attribute 'unit': "\
- "[facet 'enumeration'] The value 'bla' is not an element of the set {'y', 'm', 'd'}."
- response[:results][0][:result_code].should == '2001'
- end
-
- it 'creates a domain with multiple dnskeys' do
- xml = domain_create_xml({}, {
- _anonymus: [
- { keyData: {
- flags: { value: '257' },
- protocol: { value: '3' },
- alg: { value: '3' },
- pubKey: { value: 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8' }
- }
- },
- {
- keyData: {
- flags: { value: '0' },
- protocol: { value: '3' },
- alg: { value: '5' },
- pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
- }
- },
- {
- keyData: {
- flags: { value: '256' },
- protocol: { value: '3' },
- alg: { value: '254' },
- pubKey: { value: '841936717ae427ace63c28d04918569a841936717ae427ace63c28d0' }
- }
- }
- ]
- })
-
- epp_plain_request(xml)
- d = Domain.last
-
- d.dnskeys.count.should == 3
-
- ksk = d.dnskeys.find_by(flags: 257)
- ksk.ds_key_tag.should_not be_blank
- ksk.ds_alg.should == 3
- ksk.ds_digest_type.should == Setting.ds_algorithm
-
- zsk = d.dnskeys.find_by(flags: 256)
- zsk.ds_key_tag.should be_blank
-
- zero = d.dnskeys.find_by(flags: 0)
- zero.ds_key_tag.should be_blank
-
- d.dnskeys.pluck(:flags).should match_array([257, 0, 256])
- d.dnskeys.pluck(:protocol).should match_array([3, 3, 3])
- d.dnskeys.pluck(:alg).should match_array([3, 5, 254])
- d.dnskeys.pluck(:public_key).should match_array(%w(
- AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8
- 700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f
- 841936717ae427ace63c28d04918569a841936717ae427ace63c28d0
- ))
- end
-
- it 'does not create a domain when dnskeys are invalid' do
- xml = domain_create_xml({}, {
- _anonymus: [
- { keyData: {
- flags: { value: '250' },
- protocol: { value: '4' },
- alg: { value: '9' },
- pubKey: { value: 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8' }
- }
- },
- {
- keyData: {
- flags: { value: '1' },
- protocol: { value: '3' },
- alg: { value: '10' },
- pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
- }
- },
- {
- keyData: {
- flags: { value: '256' },
- protocol: { value: '5' },
- alg: { value: '254' },
- pubKey: { value: '' }
- }
- }
- ]
- })
-
- response = epp_plain_request(xml)
-
- response[:results][0][:msg].should ==
- "Element '{urn:ietf:params:xml:ns:secDNS-1.1}pubKey': [facet 'minLength'] The value has a "\
- "length of '0'; this underruns the allowed minimum length of '1'."
- response[:results][1][:msg].should ==
- "Element '{urn:ietf:params:xml:ns:secDNS-1.1}pubKey': '' is not a valid value of the atomic "\
- "type '{urn:ietf:params:xml:ns:secDNS-1.1}keyType'."
-
- xml = domain_create_xml({}, {
- _anonymus: [
- { keyData: {
- flags: { value: '250' },
- protocol: { value: '4' },
- alg: { value: '9' },
- pubKey: { value: 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8' }
- }
- },
- {
- keyData: {
- flags: { value: '1' },
- protocol: { value: '3' },
- alg: { value: '10' },
- pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
- }
- },
- {
- keyData: {
- flags: { value: '256' },
- protocol: { value: '5' },
- alg: { value: '254' },
- pubKey: { value: 'AwEAAbuFiHS4jZL7ZQKvEPBmsbceNHTVYpEVMdxz2A6YCjlZTEoAH3qK' }
- }
- }
- ]
- })
-
- response = epp_plain_request(xml)
-
- response[:results][0][:msg].should ==
- 'Valid algorithms are: 3, 5, 6, 7, 8, 252, 253, 254, 255 [alg]'
- response[:results][0][:value].should == '9'
-
- response[:results][1][:msg].should == 'Valid protocols are: 3 [protocol]'
- response[:results][1][:value].should == '4'
-
- response[:results][2][:msg].should == 'Valid flags are: 0, 256, 257 [flags]'
- response[:results][2][:value].should == '250'
-
- response[:results][3][:msg].should == 'Valid algorithms are: 3, 5, 6, 7, 8, 252, 253, 254, 255 [alg]'
- response[:results][3][:value].should == '10'
-
- response[:results][4][:msg].should == 'Valid flags are: 0, 256, 257 [flags]'
- response[:results][4][:value].should == '1'
-
- response[:results][5][:msg].should == 'Valid protocols are: 3 [protocol]'
- response[:results][5][:value].should == '5'
- end
-
- it 'does not create a domain with two identical dnskeys' do
- xml = domain_create_xml({}, {
- _anonymus: [
- { keyData: {
- flags: { value: '257' },
- protocol: { value: '3' },
- alg: { value: '3' },
- pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
- }
- },
- {
- keyData: {
- flags: { value: '0' },
- protocol: { value: '3' },
- alg: { value: '5' },
- pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
- }
- }]
- })
-
- response = epp_plain_request(xml)
-
- response[:result_code].should == '2302'
- response[:msg].should == 'Public key already exists [public_key]'
- response[:results][0][:value].should == '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
- end
-
- it 'validated dnskeys count' do
- Setting.dnskeys_max_count = 1
-
- xml = domain_create_xml({}, {
- _anonymus: [
- { keyData: {
- flags: { value: '257' },
- protocol: { value: '3' },
- alg: { value: '3' },
- pubKey: { value: 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8' }
- }
- },
- {
- keyData: {
- flags: { value: '0' },
- protocol: { value: '3' },
- alg: { value: '5' },
- pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
- }
- }]
- })
-
- response = epp_plain_request(xml)
-
- response[:result_code].should == '2004'
- response[:msg].should == 'DNS keys count must be between 0-1 [dnskeys]'
-
- create_settings
- end
-
- it 'creates domain with ds data' do
- xml = domain_create_xml({}, {
- _anonymus: [
- { dsData: {
- keyTag: { value: '12345' },
- alg: { value: '3' },
- digestType: { value: '1' },
- digest: { value: '49FD46E6C4B45C55D4AC' }
- }
- }]
- })
-
- epp_plain_request(xml)
-
- d = Domain.last
- ds = d.dnskeys.first
- ds.ds_key_tag.should == '12345'
- ds.ds_alg.should == 3
- ds.ds_digest_type.should == 1
- ds.ds_digest.should == '49FD46E6C4B45C55D4AC'
- ds.flags.should be_nil
- ds.protocol.should be_nil
- ds.alg.should be_nil
- ds.public_key.should be_nil
- end
-
- it 'creates domain with ds data with key' do
- xml = domain_create_xml({}, {
- _anonymus: [
- { dsData: {
- keyTag: { value: '12345' },
- alg: { value: '3' },
- digestType: { value: '1' },
- digest: { value: '49FD46E6C4B45C55D4AC' },
- keyData: {
- flags: { value: '0' },
- protocol: { value: '3' },
- alg: { value: '5' },
- pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
- }
- }
- }]
- })
-
- epp_plain_request(xml)
-
- d = Domain.last
- ds = d.dnskeys.first
- ds.ds_key_tag.should == '12345'
- ds.ds_alg.should == 3
- ds.ds_digest_type.should == 1
- ds.ds_digest.should == '49FD46E6C4B45C55D4AC'
- ds.flags.should == 0
- ds.protocol.should == 3
- ds.alg.should == 5
- ds.public_key.should == '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
- end
-
- # it 'prohibits dsData with key' do
- # Setting.ds_data_with_key_allowed = false
-
- # xml = domain_create_xml({}, {
- # _anonymus: [
- # { dsData: {
- # keyTag: { value: '12345' },
- # alg: { value: '3' },
- # digestType: { value: '1' },
- # digest: { value: '49FD46E6C4B45C55D4AC' },
- # keyData: {
- # flags: { value: '0' },
- # protocol: { value: '3' },
- # alg: { value: '5' },
- # pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
- # }
- # }
- # }]
- # })
-
- # response = epp_plain_request(xml)
- # response[:result_code].should == '2306'
- # response[:msg].should == 'dsData object with key data is not allowed'
-
- # create_settings
- # end
-
- it 'prohibits dsData' do
- Setting.ds_data_allowed = false
-
- xml = domain_create_xml({}, {
- _anonymus: [
- { dsData: {
- keyTag: { value: '12345' },
- alg: { value: '3' },
- digestType: { value: '1' },
- digest: { value: '49FD46E6C4B45C55D4AC' },
- keyData: {
- flags: { value: '0' },
- protocol: { value: '3' },
- alg: { value: '5' },
- pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
- }
- }
- }]
- })
-
- response = epp_plain_request(xml)
- response[:result_code].should == '2306'
- response[:msg].should == 'dsData object is not allowed'
-
- create_settings
- end
-
- it 'prohibits keyData' do
- Setting.key_data_allowed = false
-
- xml = domain_create_xml({}, {
- _anonymus: [
- keyData: {
- flags: { value: '0' },
- protocol: { value: '3' },
- alg: { value: '5' },
- pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
- }]
- })
-
- response = epp_plain_request(xml)
- response[:result_code].should == '2306'
- response[:msg].should == 'keyData object is not allowed'
-
- create_settings
- end
-
- it 'prohibits dsData and keyData when they exists together' do
- xml = domain_create_xml({}, {
- _anonymus: [
- {
- dsData: {
- keyTag: { value: '12345' },
- alg: { value: '3' },
- digestType: { value: '1' },
- digest: { value: '49FD46E6C4B45C55D4AC' }
- }
- },
- {
- keyData: {
- flags: { value: '0' },
- protocol: { value: '3' },
- alg: { value: '5' },
- pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
- }
- }]
- })
-
- response = epp_plain_request(xml)
- response[:msg].should == "Element '{urn:ietf:params:xml:ns:secDNS-1.1}keyData': This element "\
- "is not expected. Expected is ( {urn:ietf:params:xml:ns:secDNS-1.1}dsData )."
- response[:result_code].should == '2001'
- end
- end
-
- context 'with juridical persion as a registrant' do
- it 'creates a domain with contacts' do
- xml = domain_create_xml({
- registrant: { value: 'FIXED:JURIDICAL_1234' },
- _anonymus: [
- { contact: { value: 'FIXED:SH8013', attrs: { type: 'admin' } } }
- ]
- })
-
- response = epp_plain_request(xml)
- response[:msg].should == 'Command completed successfully'
- response[:result_code].should == '1000'
- response[:clTRID].should == 'ABC-12345'
-
- Domain.last.tech_contacts.count.should == 1
- Domain.last.admin_contacts.count.should == 1
-
- tech_contact = Domain.last.tech_contacts.first
- tech_contact.code.should == 'FIXED:JURIDICAL_1234'
- end
-
- it 'does not create a domain without admin contact' do
- domain_count = Domain.count
- domain_contact_count = DomainContact.count
- xml = domain_create_xml({
- registrant: { value: 'FIXED:JURIDICAL_1234' },
- _anonymus: [
- { contact: { value: 'FIXED:SH8013', attrs: { type: 'tech' } } }
- ]
- })
-
- response = epp_plain_request(xml)
- response[:msg].should == 'Admin contacts count must be between 1-10 [admin_domain_contacts]'
- response[:result_code].should == '2004'
- response[:clTRID].should == 'ABC-12345'
-
- Domain.count.should == domain_count
- DomainContact.count.should == domain_contact_count
- end
-
- it 'cannot assign juridical person as admin contact' do
- xml = domain_create_xml({
- registrant: { value: 'FIXED:JURIDICAL_1234' },
- _anonymus: [
- { contact: { value: 'FIXED:JURIDICAL_1234', attrs: { type: 'admin' } } }
- ]
- })
-
- response = epp_plain_request(xml)
- response[:msg].should == 'Admin contact can be private person only'
- response[:result_code].should == '2306'
- end
- end
-
- context 'with valid domain' do
- let(:domain) { Fabricate(:domain, registrar: @registrar1, dnskeys: []) }
-
- it 'transfers a domain' do
- domain.registrar = @registrar1
- domain.save
-
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- }, 'request', {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- })
-
- old_contact_codes = domain.contacts.pluck(:code).sort.uniq
- old_registrant_code = domain.registrant.code
-
- login_as :registrar2 do
- response = epp_plain_request(xml)
- domain.reload
- dtl = domain.domain_transfers.last
-
- trn_data = response[:parsed].css('trnData')
- trn_data.css('name').text.should == domain.name
- trn_data.css('trStatus').text.should == 'serverApproved'
- trn_data.css('reID').text.should == 'REGDOMAIN2'
- trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601
- trn_data.css('acID').text.should == 'REGDOMAIN1'
- trn_data.css('acDate').text.should == dtl.transferred_at.in_time_zone.utc.utc.iso8601
- trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601
-
- domain.registrar.should == @registrar2
- end
-
- response = epp_plain_request(@epp_xml.session.poll)
-
- response[:msg].should == 'Command completed successfully; ack to dequeue'
- msg_q = response[:parsed].css('msgQ')
- msg_q.css('qDate').text.should_not be_blank
-
- msg_q.css('msg').text.should == "Domain transfer was approved, associated contacts were: " \
- "#{old_contact_codes} and registrant was #{old_registrant_code}"
- msg_q.first['id'].should_not be_blank
- msg_q.first['count'].should == '1'
-
- xml = @epp_xml.session.poll(poll: {
- value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
- })
-
- response = epp_plain_request(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'
- end
-
- ### TRANSFER ###
- # Do not place this test to epp-examples (epp: false)
- it 'transfers a domain with wait time > 0', epp: false do
- domain.registrar = @registrar1
- domain.save
-
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- }, 'request', {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- })
-
- old_contact_codes = domain.contacts.pluck(:code).sort.uniq
- old_registrant_code = domain.registrant.code
-
- response = login_as :registrar2 do
- epp_plain_request(xml)
- end
-
- domain.reload
- dtl = domain.domain_transfers.last
-
- trn_data = response[:parsed].css('trnData')
- trn_data.css('name').text.should == domain.name
- trn_data.css('trStatus').text.should == 'serverApproved'
- trn_data.css('reID').text.should == 'REGDOMAIN2'
- trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601
- trn_data.css('acID').text.should == 'REGDOMAIN1'
- trn_data.css('acDate').text.should == dtl.transferred_at.in_time_zone.utc.utc.iso8601
- trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601
-
- domain.registrar.should == @registrar2
-
- response = epp_plain_request(@epp_xml.session.poll)
-
- response[:msg].should == 'Command completed successfully; ack to dequeue'
- msg_q = response[:parsed].css('msgQ')
- msg_q.css('qDate').text.should_not be_blank
-
- msg_q.css('msg').text.should == "Domain transfer was approved, associated contacts were: " \
- "#{old_contact_codes} and registrant was #{old_registrant_code}"
- msg_q.first['id'].should_not be_blank
- msg_q.first['count'].should == '1'
-
- Setting.transfer_wait_time = 1
-
- domain.reload
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- }, 'request', {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- }) # request with new password
-
- response = epp_plain_request(xml)
- trn_data = response[:parsed].css('trnData')
-
- domain.reload
- dtl = domain.domain_transfers.last
-
- domain.domain_transfers.count.should == 2
-
- trn_data.css('name').text.should == domain.name
- trn_data.css('trStatus').text.should == 'pending'
- trn_data.css('reID').text.should == 'REGDOMAIN1'
- trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601
- trn_data.css('acDate').text.should == dtl.wait_until.in_time_zone.utc.utc.iso8601
- trn_data.css('acID').text.should == 'REGDOMAIN2'
- trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601
-
- domain.registrar.should == @registrar2
-
- # should return same data if pending already
- response = epp_plain_request(xml)
- trn_data = response[:parsed].css('trnData')
-
- domain.domain_transfers.count.should == 2
- trn_data.css('name').text.should == domain.name
- trn_data.css('trStatus').text.should == 'pending'
- trn_data.css('reID').text.should == 'REGDOMAIN1'
- trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601
- trn_data.css('acDate').text.should == dtl.wait_until.in_time_zone.utc.utc.iso8601
- trn_data.css('acID').text.should == 'REGDOMAIN2'
- trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601
-
- domain.registrar.should == @registrar2
-
- # should show up in other registrar's poll
-
- login_as :registrar2 do
- response = epp_plain_request(@epp_xml.session.poll)
- response[:msg].should == 'Command completed successfully; ack to dequeue'
- msg_q = response[:parsed].css('msgQ')
- msg_q.css('qDate').text.should_not be_blank
- msg_q.css('msg').text.should == 'Transfer requested.'
- msg_q.first['id'].should_not be_blank
- msg_q.first['count'].should == '1'
-
- xml = @epp_xml.session.poll(poll: {
- value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
- })
-
- response = epp_plain_request(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'
- end
-
- create_settings
- end
-
- it 'creates a domain transfer with legal document' do
- domain.legal_documents.count.should == 0
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- }, 'request', {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- })
-
- login_as :registrar2 do
- response = epp_plain_request(xml)
- response[:result_code].should == '1000'
- domain.legal_documents.count.should == 1
-
- log = ApiLog::EppLog.last
-
- log.request_command.should == 'transfer'
- log.request_object.should == 'domain'
- log.request_successful.should == true
- log.api_user_name.should == 'registrar2'
- log.api_user_registrar.should == 'registrar2'
- log.request.should_not be_blank
- log.response.should_not be_blank
- end
-
- login_as :registrar2 do
- epp_plain_request(xml)
- end
- end
-
- it 'creates transfer successfully without legal document' do
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- })
-
- login_as :registrar2 do
- response = epp_plain_request(xml)
- response[:msg].should == 'Command completed successfully'
- response[:result_code].should == '1000'
- end
- end
-
- it 'transfers domain with contacts' do
- original_oc_id = domain.registrant.id
- original_oc_code = domain.registrant.code
-
- original_contact_codes = domain.contacts.pluck(:code)
-
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- })
-
- login_as :registrar2 do
- response = epp_plain_request(xml)
- response[:msg].should == 'Command completed successfully'
- response[:result_code].should == '1000'
- end
-
- # all domain contacts should be under registrar2 now
- domain.reload
- domain.registrant.reload
- domain.registrant.registrar_id.should == @registrar2.id
- domain.registrant.id.should_not == original_oc_id
-
- # must generate new code
- domain.registrant.code.should_not == original_oc_code
-
- domain.contacts.each do |c|
- c.registrar_id.should == @registrar2.id
- original_contact_codes.include?(c.code).should_not == true
- end
- end
-
- it 'transfers domain when registrant has more domains' do
- Fabricate(:domain, registrant: domain.registrant)
- original_oc_id = domain.registrant.id
- original_oc_code = domain.registrant.code
-
- original_contact_codes = domain.contacts.pluck(:code)
-
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- })
-
- login_as :registrar2 do
- response = epp_plain_request(xml)
- response[:msg].should == 'Command completed successfully'
- response[:result_code].should == '1000'
- end
-
- # all domain contacts should be under registrar2 now
- domain.reload
- domain.registrant.registrar_id.should == @registrar2.id
- # registrant should be a new record
- domain.registrant.id.should_not == original_oc_id
- # must generate new code
- domain.registrant.code.should_not == original_oc_code
-
- domain.contacts.each do |c|
- c.registrar_id.should == @registrar2.id
- original_contact_codes.include?(c.code).should_not == true
- end
- end
-
- it 'transfers domain when registrant is admin or tech contact on some other domain' do
- d = Fabricate(:domain)
- d.tech_contacts << domain.registrant
-
- original_oc_id = domain.registrant.id
- original_oc_code = domain.registrant.code
-
- original_contact_codes = domain.contacts.pluck(:code)
-
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- })
-
- login_as :registrar2 do
- response = epp_plain_request(xml)
- response[:msg].should == 'Command completed successfully'
- response[:result_code].should == '1000'
- end
-
- # all domain contacts should be under registrar2 now
- domain.reload
- domain.registrant.registrar_id.should == @registrar2.id
- # registrant should be a new record
- domain.registrant.id.should_not == original_oc_id
- # must generate new code
- domain.registrant.code.should_not == original_oc_code
-
- domain.contacts.each do |c|
- c.registrar_id.should == @registrar2.id
- original_contact_codes.include?(c.code).should_not == true
- end
- end
-
- it 'transfers domain when domain contacts are some other domain contacts' do
- old_contact = Fabricate(:contact, registrar: @registrar1, name: 'old name')
- domain.tech_contacts << old_contact
- domain.admin_contacts << old_contact
-
- d = Fabricate(:domain)
- d.tech_contacts << old_contact
- d.admin_contacts << old_contact
-
- original_oc_id = domain.registrant.id
- original_contact_count = Contact.count
- original_domain_contact_count = DomainContact.count
-
- login_as :registrar2 do
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- })
- response = epp_plain_request(xml)
- response[:msg].should == 'Command completed successfully'
- response[:result_code].should == '1000'
- end
-
- # all domain contacts should be under registrar2 now
- domain.reload
- domain.registrant.registrar_id.should == @registrar2.id
- domain.registrant.id.should_not == original_oc_id
-
- # old contact must not change
- old_contact.registrar_id.should == @registrar1.id
-
- domain.contacts.each do |x|
- x.registrar_id.should == @registrar2.id
- end
-
- new_contact = Contact.last(4).detect { |c| c.name == 'old name' } # database order
- new_contact.name.should == 'old name'
-
- # there should be 2 references to the new contact
- domain.domain_contacts.where(contact_id: new_contact.id).count.should == 2
-
- # there should be four new contact object
- (original_contact_count + 4).should == Contact.count
-
- # and no new references
- original_domain_contact_count.should == DomainContact.count
- end
-
- it 'transfers domain when multiple domain contacts are some other domain contacts' do
- old_contact = Fabricate(:contact, registrar: @registrar1, name: 'first')
- old_contact_2 = Fabricate(:contact, registrar: @registrar1, name: 'second')
-
- domain.tech_contacts << old_contact
- domain.admin_contacts << old_contact
- domain.tech_contacts << old_contact_2
-
- d = Fabricate(:domain)
- d.tech_contacts << old_contact
- d.admin_contacts << old_contact_2
-
- original_oc_id = domain.registrant.id
- original_contact_count = Contact.count
- original_domain_contact_count = DomainContact.count
-
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- })
-
- login_as :registrar2 do
- response = epp_plain_request(xml)
- response[:msg].should == 'Command completed successfully'
- response[:result_code].should == '1000'
- end
-
- # all domain contacts should be under registrar2 now
- domain.reload
- domain.registrant.registrar_id.should == @registrar2.id
- # registrant should not be a new record
- domain.registrant.id.should_not == original_oc_id
-
- # old contact must not change
- old_contact.registrar_id.should == @registrar1.id
-
- domain.contacts.each do |x|
- x.registrar_id.should == @registrar2.id
- end
-
- new_contact = Contact.last(5).detect { |c| c.name == 'first' }
- new_contact_2 = Contact.last(5).detect { |c| c.name == 'second' }
-
- new_contact.name.should == 'first'
- new_contact_2.name.should == 'second'
-
- # there should be 2 references to the new contact (admin + tech)
- domain.domain_contacts.where(contact_id: new_contact.id).count.should == 2
-
- # there should be 1 reference to the new contact 2 (tech)
- domain.domain_contacts.where(contact_id: new_contact_2.id).count.should == 1
-
- # there should be four new contact objects
- (original_contact_count + 5).should == Contact.count
-
- # and no new references
- original_domain_contact_count.should == DomainContact.count
- end
-
- it 'transfers domain and references exsisting registrant to domain contacts' do
- d = Fabricate(:domain)
- d.tech_contacts << domain.registrant
-
- domain.tech_contacts << domain.registrant
- original_registrant_id = domain.registrant_id
-
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- })
-
- login_as :registrar2 do
- response = epp_plain_request(xml)
- response[:msg].should == 'Command completed successfully'
- response[:result_code].should == '1000'
- end
-
- domain.reload
- # registrant must be an new record
- domain.registrant_id.should_not == original_registrant_id
-
- # new registrant must be a tech contact
- domain.domain_contacts.where(contact_id: domain.registrant_id).count.should == 1
- end
-
- it 'does not transfer contacts if they are already under new registrar' do
- domain.contacts.each do |c|
- c.registrar_id = @registrar2.id
- c.save
- end
-
- domain.registrant.registrar_id = @registrar2.id
- domain.registrant.save
-
- original_oc_id = domain.registrant_id
- original_oc_code = domain.registrant.code
- original_contacts_codes = domain.contacts.pluck(:code)
-
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- })
-
- login_as :registrar2 do
- response = epp_plain_request(xml)
- response[:msg].should == 'Command completed successfully'
- response[:result_code].should == '1000'
- end
-
- domain.reload
-
- domain.registrant.id.should == original_oc_id
- domain.registrant.code.should == original_oc_code
- domain.registrant.registrar_id.should == @registrar2.id
-
- original_contacts_codes.sort.should == domain.contacts.pluck(:code).sort
- end
-
- it 'transfers domain contact should populate copy_from_id' do
- d = Fabricate(:domain)
- d.tech_contacts << domain.registrant
-
- original_oc_id = domain.registrant.id
- original_oc_code = domain.registrant.code
- domain.registrant.copy_from_id.should == nil
-
- original_contact_codes = domain.contacts.pluck(:code)
-
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- })
-
- login_as :registrar2 do
- response = epp_plain_request(xml)
- response[:msg].should == 'Command completed successfully'
- response[:result_code].should == '1000'
- end
-
- # all domain contacts should be under registrar2 now
- domain.reload
- domain.registrant.registrar_id.should == @registrar2.id
- # registrant should be a new record
- domain.registrant.id.should_not == original_oc_id
- domain.registrant.copy_from_id.should == original_oc_id
- # must generate new code
- domain.registrant.code.should_not == original_oc_code
-
- domain.contacts.each do |c|
- c.registrar_id.should == @registrar2.id
- original_contact_codes.include?(c.code).should_not == true
- end
- end
-
- it 'should not creates transfer without password' do
- xml = domain_transfer_xml({
- name: { value: domain.name }
- })
-
- login_as :registrar2 do
- response = epp_plain_request(xml)
- response[:msg].should == 'Authorization error'
- response[:result_code].should == '2201'
- end
- end
-
- it 'approves the transfer request' do
- domain.domain_transfers.create({
- status: DomainTransfer::PENDING,
- transfer_requested_at: Time.zone.now,
- transfer_to: @registrar2,
- transfer_from: @registrar1
- })
-
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: domain.auth_info } }
- }, 'approve', {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- })
-
- response = epp_plain_request(xml)
-
- domain.reload
- dtl = domain.domain_transfers.last
-
- trn_data = response[:parsed].css('trnData')
-
- trn_data.css('name').text.should == domain.name
- trn_data.css('trStatus').text.should == 'clientApproved'
- trn_data.css('reID').text.should == 'REGDOMAIN2'
- trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601
- trn_data.css('acID').text.should == 'REGDOMAIN1'
- trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601
- end
-
- it 'rejects a domain transfer' do
- domain.domain_transfers.create({
- status: DomainTransfer::PENDING,
- transfer_requested_at: Time.zone.now,
- transfer_to: @registrar2,
- transfer_from: @registrar1
- })
-
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- }, 'reject', {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- })
-
- response = login_as :registrar2 do
- epp_plain_request(xml)
- end
-
- response[:msg].should == 'Transfer can be rejected only by current registrar'
- response[:result_code].should == '2304'
- domain.legal_documents.count.should == 0
-
- response = epp_plain_request(xml)
- response[:result_code].should == '1000'
- domain.pending_transfer.should be_nil
- domain.legal_documents.count.should == 1
- end
-
- it 'prohibits wrong registrar from approving transfer' do
- domain.domain_transfers.create({
- status: DomainTransfer::PENDING,
- transfer_requested_at: Time.zone.now,
- transfer_to: @registrar2,
- transfer_from: @registrar1
- })
-
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: domain.auth_info } }
- }, 'approve', {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- })
-
- response = login_as :registrar2 do
- epp_plain_request(xml)
- end
-
- response[:result_code].should == '2304'
- response[:msg].should == 'Transfer can be approved only by current domain registrar'
- end
-
- it 'does not transfer with invalid pw' do
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: 'test' } }
- }, 'request', {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- })
-
- response = epp_plain_request(xml)
- response[:result_code].should == '2201'
- response[:msg].should == 'Authorization error'
- end
-
- it 'ignores transfer when domain already belongs to registrar' do
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- }, 'request', {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- })
-
- response = epp_plain_request(xml)
-
- response[:result_code].should == '2002'
- response[:msg].should == 'Domain already belongs to the querying registrar'
- end
-
- it 'returns an error for incorrect op attribute' do
- response = epp_plain_request(domain_transfer_xml({}, 'bla'))
- response[:msg].should ==
- "Element '{urn:ietf:params:xml:ns:epp-1.0}transfer', attribute 'op': [facet 'enumeration'] "\
- "The value 'bla' is not an element of the set {'approve', 'cancel', 'query', 'reject', 'request'}."
- response[:result_code].should == '2001'
- end
-
- it 'creates new pw after successful transfer' do
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- }, 'request', {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- })
-
- login_as :registrar2 do
- epp_plain_request(xml) # transfer domain
- response = epp_plain_request(xml) # attempt second transfer
- response[:msg].should == 'Authorization error'
- response[:result_code].should == '2201'
- end
- end
-
- it 'should get an error when there is no pending transfer' do
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- }, 'approve', {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- })
-
- response = epp_plain_request(xml)
- response[:msg].should == 'No transfers found'
- response[:result_code].should == '2303'
- end
-
- it 'should not return transfers when there are none' do
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: domain.auth_info } }
- }, 'query')
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'No transfers found'
- response[:results][0][:result_code].should == '2303'
- end
-
- it 'should not cancel transfer when there are none' do
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: domain.auth_info } }
- }, 'cancel')
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'No transfers found'
- response[:results][0][:result_code].should == '2303'
- end
-
- it 'should allow querying domain transfer', epp: false do
- Setting.transfer_wait_time = 1
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- }, 'request', {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- })
-
- login_as :registrar2 do
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Command completed successfully'
- response[:results][0][:result_code].should == '1000'
-
- trn_data = response[:parsed].css('trnData')
-
- dtl = domain.domain_transfers.last
-
- trn_data.css('name').text.should == domain.name
- trn_data.css('trStatus').text.should == 'pending'
- trn_data.css('reID').text.should == 'REGDOMAIN2'
- trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601
- trn_data.css('acDate').text.should == dtl.wait_until.in_time_zone.utc.utc.iso8601
- trn_data.css('acID').text.should == 'REGDOMAIN1'
- trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601
-
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- }, 'query')
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Command completed successfully'
- response[:results][0][:result_code].should == '1000'
-
- trn_data = response[:parsed].css('trnData')
-
- dtl = domain.domain_transfers.last
- trn_data.css('name').text.should == domain.name
- trn_data.css('trStatus').text.should == 'pending'
- trn_data.css('reID').text.should == 'REGDOMAIN2'
- trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601
- trn_data.css('acDate').text.should == dtl.wait_until.in_time_zone.utc.utc.iso8601
- trn_data.css('acID').text.should == 'REGDOMAIN1'
- trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601
- end
-
- # approves pending transfer
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- }, 'approve', {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- })
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Command completed successfully'
- response[:results][0][:result_code].should == '1000'
-
- # query should return last completed transfer
- domain.reload
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- }, 'query')
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Command completed successfully'
- response[:results][0][:result_code].should == '1000'
-
- trn_data = response[:parsed].css('trnData')
-
- dtl = domain.domain_transfers.last
-
- trn_data.css('name').text.should == domain.name
- trn_data.css('trStatus').text.should == 'clientApproved'
- trn_data.css('reID').text.should == 'REGDOMAIN2'
- trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601
- trn_data.css('acDate').text.should == dtl.transferred_at.in_time_zone.utc.utc.iso8601
- trn_data.css('acID').text.should == 'REGDOMAIN1'
- trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601
-
- Setting.transfer_wait_time = 0
- end
-
- it 'should not transfer when period element is present' do
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- period: { value: '1', attrs: { unit: 'y' } },
- authInfo: { pw: { value: pw } }
- })
-
- login_as :registrar2 do
- response = epp_plain_request(xml)
- response[:msg].should == 'Unimplemented object service'
- response[:result_code].should == '2307'
- response[:parsed].css('value > period').any?.should == true
- end
- end
-
- it 'should not transfer when in prohibited status' do
- domain.statuses = [DomainStatus::SERVER_TRANSFER_PROHIBITED]
- domain.save
-
- pw = domain.auth_info
- xml = domain_transfer_xml({
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- })
-
- login_as :registrar2 do
- response = epp_plain_request(xml)
- response[:msg].should == 'Object status prohibits operation'
- response[:result_code].should == '2304'
- end
- end
-
- ### UPDATE ###
- it 'should update right away without update pending status' do
- existing_pw = domain.auth_info
-
- xml_params = {
- name: { value: domain.name },
- chg: [
- registrant: { value: 'FIXED:CITIZEN_1234', attrs: { verified: 'yes' } }
- ]
- }
-
- response = epp_plain_request(domain_update_xml(xml_params, {}, {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- }))
-
- response[:results][0][:msg].should == 'Command completed successfully'
- response[:results][0][:result_code].should == '1000'
-
- d = Domain.last
-
- d.registrant_code.should == 'FIXED:CITIZEN_1234'
- d.auth_info.should == existing_pw
- d.pending_update?.should == false
- end
-
- it 'updates a domain' do
- existing_pw = domain.auth_info
-
- xml_params = {
- name: { value: domain.name },
- chg: [
- registrant: { value: 'FIXED:CITIZEN_1234' }
- ]
- }
-
- response = epp_plain_request(domain_update_xml(xml_params, {}, {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- }))
-
- response[:results][0][:msg].should == 'Command completed successfully; action pending'
- response[:results][0][:result_code].should == '1001'
-
- d = Domain.last
-
- d.registrant_code.should_not == 'FIXED:CITIZEN_1234' # should not update
- d.auth_info.should == existing_pw
- d.pending_update?.should == true
- end
-
- it 'updates a domain and changes auth info' do
- response = epp_plain_request(domain_update_xml({
- name: { value: domain.name },
- chg: [
- authInfo: { pw: { value: 'newpw' } }
- ]
- }))
-
- response[:results][0][:msg].should == 'Command completed successfully'
- response[:results][0][:result_code].should == '1000'
-
- d = Domain.last
-
- d.auth_info.should == 'newpw'
- end
-
- it 'should not return action pending when changes are invalid' do
- existing_pw = domain.auth_info
-
- hostnames = domain.nameservers.pluck(:hostname)
-
- xml_params = {
- name: { value: domain.name },
- rem: [
- {
- ns:
- hostnames.map do |x|
- {
- hostAttr: [
- { hostName: { value: x } }
- ]
- }
- end
- }
- ],
- chg: [
- registrant: { value: 'FIXED:CITIZEN_1234' }
- ]
- }
-
- response = epp_plain_request(domain_update_xml(xml_params, {}, {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- }), :xml)
-
- response[:results][0][:msg].should == 'Nameservers count must be between 2-11 [nameservers]'
- response[:results][0][:result_code].should == '2004'
-
- d = Domain.last
-
- d.registrant_code.should_not == 'FIXED:CITIZEN_1234' # should not update
- d.auth_info.should == existing_pw
- d.nameservers.size == 3
- d.pending_update?.should == false
- end
-
- it 'should not return action pending when domain itself is already invaid' do
- domain_id = domain.id
- domain.nameservers.delete_all
- domain.save(validate: false)
- domain.reload.nameservers.size.should == 0
-
- existing_pw = domain.auth_info
-
- xml_params = {
- name: { value: domain.name },
- chg: [
- registrant: { value: 'FIXED:CITIZEN_1234' }
- ]
- }
-
- response = epp_plain_request(domain_update_xml(xml_params, {}, {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- }), :xml)
-
- response[:results][0][:msg].should == 'Nameservers count must be between 2-11 [nameservers]'
- response[:results][0][:result_code].should == '2004'
-
- d = Domain.find(domain_id)
-
- d.registrant_code.should_not == 'FIXED:CITIZEN_1234' # should not update
- d.auth_info.should == existing_pw
- d.nameservers.size.should == 0
- d.pending_update?.should == false
- end
-
- it 'should not allow any update when status pending update' do
- domain.statuses << DomainStatus::PENDING_UPDATE
- domain.save
-
- existing_pw = domain.auth_info
-
- xml_params = {
- name: { value: domain.name },
- chg: [
- registrant: { value: 'FIXED:CITIZEN_1234' }
- ]
- }
-
- response = epp_plain_request(domain_update_xml(xml_params, {}, {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- }))
-
- response[:results][0][:msg].should == 'Object status prohibits operation'
- response[:results][0][:result_code].should == '2304'
-
- d = Domain.last
-
- d.registrant_code.should_not == 'FIXED:CITIZEN_1234'
- d.auth_info.should == existing_pw
- d.pending_update?.should == true
- end
-
- it 'should not allow any update when status force delete' do
- domain.set_force_delete
-
- xml_params = {
- name: { value: domain.name },
- chg: [
- registrant: { value: 'FIXED:CITIZEN_1234' }
- ]
- }
-
- response = epp_plain_request(domain_update_xml(xml_params, {}, {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- }))
-
- response[:results][0][:msg].should == 'Object status prohibits operation'
- response[:results][0][:result_code].should == '2304'
- end
-
- it 'updates domain and adds objects' do
- xml = domain_update_xml({
- name: { value: domain.name },
- add: [
- {
- ns: [
- {
- hostAttr: [
- { hostName: { value: 'ns1.example.com' } }
- ]
- },
- {
- hostAttr: [
- { hostName: { value: 'ns2.example.com' } }
- ]
- }
- ]
- },
- _anonymus: [
- { contact: { value: 'FIXED:MAK21', attrs: { type: 'tech' } } },
- { status: { value: 'Payment overdue.', attrs: { s: 'clientHold', lang: 'en' } } },
- { status: { value: '', attrs: { s: 'clientRenewProhibited' } } }
- ]
- ]
- }, {
- add: [
- { keyData: {
- flags: { value: '0' },
- protocol: { value: '3' },
- alg: { value: '5' },
- pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
- }
- },
- {
- keyData: {
- flags: { value: '256' },
- protocol: { value: '3' },
- alg: { value: '254' },
- pubKey: { value: '841936717ae427ace63c28d04918569a841936717ae427ace63c28d0' }
- }
- }
- ]
- })
-
- response = epp_plain_request(xml)
- response[:results][0][:result_code].should == '2303'
- response[:results][0][:msg].should == 'Contact was not found'
-
- Fabricate(:contact, code: 'FIXED:MAK21')
-
- response = epp_plain_request(xml)
-
- response[:results][0][:result_code].should == '1000'
-
- d = Domain.last
-
- new_ns_count = d.nameservers.where(hostname: ['ns1.example.com', 'ns2.example.com']).count
- new_ns_count.should == 2
-
- new_contact = d.tech_contacts.find_by(code: 'FIXED:MAK21')
- new_contact.should be_truthy
-
- d.statuses.count.should == 2
- d.statuses.include?('clientHold').should == true
- d.statuses.include?('clientRenewProhibited').should == true
-
- d.dnskeys.count.should == 2
-
- response = epp_plain_request(xml)
-
- response[:results][0][:result_code].should == '2302'
- response[:results][0][:msg].should == 'Nameserver already exists on this domain [hostname]'
- if response[:results][0][:value] == 'ns1.example.com'
- response[:results][0][:value].should == 'ns1.example.com'
- else
- response[:results][0][:value].should == 'ns2.example.com'
- end
-
- response[:results][1][:result_code].should == '2302'
- response[:results][1][:msg].should == 'Nameserver already exists on this domain [hostname]'
- if response[:results][1][:value] == 'ns1.example.com'
- response[:results][1][:value].should == 'ns1.example.com'
- else
- response[:results][1][:value].should == 'ns2.example.com'
- end
-
- response[:results][2][:result_code].should == '2302'
- response[:results][2][:msg].should == 'Contact already exists on this domain [contact_code_cache]'
- response[:results][2][:value].should == 'FIXED:MAK21'
-
- # response[:results][3][:msg].should == 'Status already exists on this domain [value]'
- # if response[:results][3][:value] == 'clientHold'
- # response[:results][3][:value].should == 'clientHold'
- # else
- # response[:results][3][:value].should == 'clientUpdateProhibited'
- # end
-
- # response[:results][4][:msg].should == 'Status already exists on this domain [value]'
- # if response[:results][4][:value] == 'clientHold'
- # response[:results][4][:value].should == 'clientHold'
- # else
- # response[:results][4][:value].should == 'clientUpdateProhibited'
- # end
-
- response[:results][3][:msg].should == 'Public key already exists [public_key]'
- if response[:results][3][:value] == '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
- response[:results][3][:value].should ==
- '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
- else
- response[:results][3][:value].should ==
- '841936717ae427ace63c28d04918569a841936717ae427ace63c28d0'
- end
-
- response[:results][4][:msg].should == 'Public key already exists [public_key]'
- if response[:results][4][:value] == '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
- response[:results][4][:value].should ==
- '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
- else
- response[:results][4][:value].should ==
- '841936717ae427ace63c28d04918569a841936717ae427ace63c28d0'
- end
-
- d.statuses.count.should == 2
- end
-
- it 'updates domain with registrant change what triggers action pending' do
- xml = domain_update_xml({
- name: { value: domain.name },
- add: [
- {
- ns: [
- {
- hostAttr: [
- { hostName: { value: 'ns1.example.com' } }
- ]
- },
- {
- hostAttr: [
- { hostName: { value: 'ns2.example.com' } }
- ]
- }
- ]
- },
- _anonymus: [
- { contact: { value: 'FIXED:PENDINGMAK21', attrs: { type: 'tech' } } },
- { status: { value: 'Payment overdue.', attrs: { s: 'clientHold', lang: 'en' } } },
- { status: { value: '', attrs: { s: 'clientUpdateProhibited' } } }
- ]
- ],
- chg: [
- registrant: { value: 'FIXED:CITIZEN_1234' }
- ]
- }, {
- add: [
- { keyData: {
- flags: { value: '0' },
- protocol: { value: '3' },
- alg: { value: '5' },
- pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
- }
- },
- {
- keyData: {
- flags: { value: '256' },
- protocol: { value: '3' },
- alg: { value: '254' },
- pubKey: { value: '841936717ae427ace63c28d04918569a841936717ae427ace63c28d0' }
- }
- }
- ]
- },
- {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- })
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Contact was not found'
- response[:results][0][:result_code].should == '2303'
-
- Fabricate(:contact, code: 'FIXED:PENDINGMAK21')
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Command completed successfully; action pending'
- response[:results][0][:result_code].should == '1001'
-
- d = Domain.last
-
- new_ns_count = d.nameservers.where(hostname: ['ns1.example.com', 'ns2.example.com']).count
- new_ns_count.should == 0 # aka old value
-
- new_contact = d.tech_contacts.find_by(code: 'FIXED:PENDINGMAK21')
- new_contact.should_not be_truthy # aka should not add new contact
-
- d.statuses.count.should == 1
- d.statuses.first.should == 'pendingUpdate'
-
- d.dnskeys.count.should == 0
- end
-
- it 'does not allow to edit statuses if policy forbids it' do
- Setting.client_status_editing_enabled = false
-
- xml = domain_update_xml({
- name: { value: domain.name },
- add: [{
- _anonymus: [
- { status: { value: 'Payment overdue.', attrs: { s: 'clientHold', lang: 'en' } } },
- { status: { value: '', attrs: { s: 'clientUpdateProhibited' } } }
- ]
- }]
- })
-
- response = epp_plain_request(xml)
- response[:results][0][:result_code].should == '2306'
- response[:results][0][:msg].should == "Parameter value policy error. Client-side object status "\
- "management not supported: status [status]"
-
- Setting.client_status_editing_enabled = true
- end
-
- it 'updates a domain and removes objects' do
- xml = domain_update_xml({
- name: { value: domain.name },
- add: [
- {
- ns: [
- {
- hostAttr: [
- { hostName: { value: 'ns1.example.com' } }
- ]
- },
- {
- hostAttr: [
- { hostName: { value: 'ns2.example.com' } }
- ]
- }
- ]
- },
- _anonymus: [
- { contact: { value: 'FIXED:CITIZEN_1234', attrs: { type: 'tech' } } },
- { status: { value: 'Payment overdue.', attrs: { s: 'clientHold', lang: 'en' } } },
- { status: { value: '', attrs: { s: 'clientRenewProhibited' } } }
- ]
- ]
- }, {
- add: [
- { keyData: {
- flags: { value: '0' },
- protocol: { value: '3' },
- alg: { value: '5' },
- pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
- }
- },
- {
- keyData: {
- flags: { value: '256' },
- protocol: { value: '3' },
- alg: { value: '254' },
- pubKey: { value: '841936717ae427ace63c28d04918569a841936717ae427ace63c28d0' }
- }
- }
- ]
- })
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Command completed successfully'
- response[:results][0][:result_code].should == '1000'
-
- d = Domain.last
- d.dnskeys.count.should == 2
-
- xml = domain_update_xml({
- name: { value: domain.name },
- rem: [
- {
- ns: [
- {
- hostAttr: [
- { hostName: { value: 'ns1.example.com' } }
- ]
- }
- ]
- },
- _anonymus: [
- { contact: { value: 'FIXED:CITIZEN_1234', attrs: { type: 'tech' } } },
- { status: { value: '', attrs: { s: 'clientHold' } } }
- ]
- ]
- }, {
- rem: [
- { keyData: {
- flags: { value: '256' },
- protocol: { value: '3' },
- alg: { value: '254' },
- pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
- }
- }
- ]
- })
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Command completed successfully'
- response[:results][0][:result_code].should == '1000'
-
- d.reload
- d.dnskeys.count.should == 1
-
- d.statuses.count.should == 1
- d.statuses.first.should == 'clientRenewProhibited'
-
- rem_ns = d.nameservers.find_by(hostname: 'ns1.example.com')
- rem_ns.should be_falsey
-
- rem_cnt = d.tech_contacts.find_by(code: 'FIXED:CITIZEN_1234')
- rem_cnt.should be_falsey
-
- response = epp_plain_request(xml)
-
- response[:results][0][:result_code].should == '2303'
- response[:results][0][:msg].should == 'Nameserver was not found'
- response[:results][0][:value].should == 'ns1.example.com'
-
- response[:results][1][:result_code].should == '2303'
- response[:results][1][:msg].should == 'Contact was not found'
- response[:results][1][:value].should == 'FIXED:CITIZEN_1234'
-
- response[:results][2][:result_code].should == '2303'
- response[:results][2][:msg].should == 'DS was not found'
- response[:results][2][:value].should == '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
-
- response[:results][3][:result_code].should == '2303'
- response[:results][3][:msg].should == 'Status was not found'
- response[:results][3][:value].should == 'clientHold'
- end
-
- it 'does not remove server statuses' do
- domain.statuses << DomainStatus::SERVER_HOLD
- domain.save
-
- xml = domain_update_xml({
- name: { value: domain.name },
- rem: [
- _anonymus: [
- { status: { value: '', attrs: { s: 'serverHold' } } }
- ]
- ]
- })
-
- response = epp_plain_request(xml)
-
- response[:results][0][:result_code].should == '2303'
- response[:results][0][:msg].should == 'Status was not found'
- response[:results][0][:value].should == 'serverHold'
- end
-
- it 'does not add duplicate objects to domain' do
- d = Domain.last
- c = d.admin_contacts.first
- n = d.nameservers.first
-
- xml = domain_update_xml({
- name: { value: domain.name },
- add: {
- ns: [
- {
- hostAttr: [
- { hostName: { value: n.hostname } }
- ]
- }
- ],
- _anonymus: [
- { contact: { value: c.code, attrs: { type: 'admin' } } }
- ]
- }
- })
-
- epp_plain_request(xml)
- response = epp_plain_request(xml)
-
- response[:results][0][:result_code].should == '2302'
- response[:results][0][:msg].should == 'Nameserver already exists on this domain [hostname]'
- response[:results][0][:value].should == n.hostname
-
- response[:results][1][:result_code].should == '2302'
- response[:results][1][:msg].should == 'Contact already exists on this domain [contact_code_cache]'
- response[:results][1][:value].should == c.code
- end
-
- it 'cannot change registrant without legal document' do
- xml_params = {
- name: { value: domain.name },
- chg: [
- registrant: { value: 'FIXED:CITIZEN_1234' }
- ]
- }
-
- response = epp_plain_request(domain_update_xml(xml_params))
- response[:results][0][:msg].should ==
- 'Required parameter missing: extension > extdata > legalDocument [legal_document]'
- response[:results][0][:result_code].should == '2003'
- end
-
- it 'does not assign invalid status to domain' do
- xml = domain_update_xml({
- name: { value: domain.name },
- add: [
- status: { value: '', attrs: { s: 'invalidStatus' } }
- ]
- })
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should start_with(
- "Element '{https://epp.tld.ee/schema/domain-eis-1.0.xsd}status', attribute 's': "\
- "[facet 'enumeration'] The value 'invalidStatus' is not an element of the set ")
- response[:results][0][:result_code].should == '2001'
- end
-
- ### RENEW ###
- it 'renews a domain' do
- Setting.days_to_renew_domain_before_expire = 0
- old_balance = @registrar1.balance
- old_activities = @registrar1.cash_account.account_activities.count
-
- exp_date = domain.valid_to
- xml = @epp_xml.domain.renew(
- name: { value: domain.name },
- curExpDate: { value: exp_date.to_date.to_s },
- period: { value: '1', attrs: { unit: 'y' } }
- )
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Command completed successfully'
- response[:results][0][:result_code].should == '1000'
-
- ex_date = response[:parsed].css('renData exDate').text
- name = response[:parsed].css('renData name').text
- ex_date.should == "#{(exp_date + 1.year).to_s(:iso8601)}"
- name.should == domain.name
-
- domain.reload
- domain.valid_to.should be_within(1).of(exp_date + 1.year)
- domain.outzone_at.should be_nil
- domain.delete_at.should be_nil
-
- @registrar1.balance.should == old_balance - 15.0
- @registrar1.cash_account.account_activities.count.should == old_activities + 1
- a = @registrar1.cash_account.account_activities.last
- a.description.should == "Renew #{Domain.last.name}"
- a.sum.should == -BigDecimal.new('15.0')
- a.activity_type = AccountActivity::RENEW
- a.log_pricelist_id.should == @pricelist_renew_1_year.id
- Setting.days_to_renew_domain_before_expire = 90
- end
-
- it 'renews a domain when outzone_at or delete_at is nil for some reason' do
- Setting.days_to_renew_domain_before_expire = 0
-
- domain.outzone_at = nil
- domain.delete_at = nil
- domain.save
-
- exp_date = domain.valid_to
- xml = @epp_xml.domain.renew(
- name: { value: domain.name },
- curExpDate: { value: exp_date.to_date.to_s },
- period: { value: '1', attrs: { unit: 'y' } }
- )
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Command completed successfully'
- response[:results][0][:result_code].should == '1000'
-
- Setting.days_to_renew_domain_before_expire = 90
- end
-
- it 'renews a domain with no period specified' do
- Setting.days_to_renew_domain_before_expire = 0
- old_balance = @registrar1.balance
- old_activities = @registrar1.cash_account.account_activities.count
-
- exp_date = domain.valid_to
- xml = @epp_xml.domain.renew(
- name: { value: domain.name },
- curExpDate: { value: exp_date.to_date.to_s },
- period: nil
- )
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Command completed successfully'
- response[:results][0][:result_code].should == '1000'
-
- ex_date = response[:parsed].css('renData exDate').text
- name = response[:parsed].css('renData name').text
- ex_date.should == "#{(exp_date + 1.year).to_s(:iso8601)}"
- name.should == domain.name
-
- domain.reload
- domain.valid_to.should be_within(1).of(exp_date + 1.year)
- domain.outzone_at.should be_nil
- domain.delete_at.should be_nil
-
- @registrar1.balance.should == old_balance - 15.0
- @registrar1.cash_account.account_activities.count.should == old_activities + 1
- a = @registrar1.cash_account.account_activities.last
- a.description.should == "Renew #{Domain.last.name}"
- a.sum.should == -BigDecimal.new('15.0')
- a.activity_type = AccountActivity::RENEW
- a.log_pricelist_id.should == @pricelist_renew_1_year.id
- Setting.days_to_renew_domain_before_expire = 90
- end
-
- it 'does not renew domain with invalid period' do
- Setting.days_to_renew_domain_before_expire = 0
-
- exp_date = domain.valid_to
- xml = @epp_xml.domain.renew(
- name: { value: domain.name },
- curExpDate: { value: exp_date.to_date.to_s },
- period: { value: '1', attrs: { unit: '' } }
- )
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == "Element '{https://epp.tld.ee/schema/domain-eis-1.0.xsd}period', "\
- "attribute 'unit': [facet 'enumeration'] The value '' is not an element of the set {'y', 'm', 'd'}."
- response[:results][0][:result_code].should == '2001'
-
- xml = @epp_xml.domain.renew(
- name: { value: domain.name },
- curExpDate: { value: exp_date.to_date.to_s },
- period: { value: '1', attrs: { unit: 'bla' } }
- )
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == "Element '{https://epp.tld.ee/schema/domain-eis-1.0.xsd}period', "\
- "attribute 'unit': [facet 'enumeration'] The value 'bla' is not an element of the set {'y', 'm', 'd'}."
- response[:results][0][:result_code].should == '2001'
-
- Setting.days_to_renew_domain_before_expire = 90
- end
-
- it 'renews a domain with 2 year period' do
- old_balance = @registrar1.balance
- old_activities = @registrar1.cash_account.account_activities.count
-
- domain.valid_to = Time.zone.now.to_date + 10.days
- domain.save
-
- exp_date = domain.valid_to.to_date
- xml = @epp_xml.domain.renew(
- name: { value: domain.name },
- curExpDate: { value: exp_date.to_s },
- period: { value: '730', attrs: { unit: 'd' } }
- )
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Command completed successfully'
- response[:results][0][:result_code].should == '1000'
-
- ex_date = response[:parsed].css('renData exDate').text
- name = response[:parsed].css('renData name').text
- ex_date.should == "#{(exp_date + 2.year)}T00:00:00Z"
- name.should == domain.name
-
- @registrar1.balance.should == old_balance - 35.0
- @registrar1.cash_account.account_activities.count.should == old_activities + 1
- a = @registrar1.cash_account.account_activities.last
- a.description.should == "Renew #{Domain.last.name}"
- a.sum.should == -BigDecimal.new('35.0')
- a.activity_type = AccountActivity::CREATE
- end
-
- it 'renews a domain with 3 year period' do
- old_balance = @registrar1.balance
- old_activities = @registrar1.cash_account.account_activities.count
-
- domain.valid_to = Time.zone.now.to_date + 10.days
- domain.save
-
- exp_date = domain.valid_to.to_date
- xml = @epp_xml.domain.renew(
- name: { value: domain.name },
- curExpDate: { value: exp_date.to_s },
- period: { value: '36', attrs: { unit: 'm' } }
- )
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Command completed successfully'
- response[:results][0][:result_code].should == '1000'
-
- ex_date = response[:parsed].css('renData exDate').text
- name = response[:parsed].css('renData name').text
- ex_date.should == "#{(exp_date + 3.year)}T00:00:00Z"
- name.should == domain.name
-
- @registrar1.balance.should == old_balance - 62.0
- @registrar1.cash_account.account_activities.count.should == old_activities + 1
- a = @registrar1.cash_account.account_activities.last
- a.description.should == "Renew #{Domain.last.name}"
- a.sum.should == -BigDecimal.new('62.0')
- a.activity_type = AccountActivity::CREATE
- end
-
- it 'does not renew a domain if credit balance low' do
- f = Fabricate(:pricelist, {
- valid_to: Time.zone.now + 1.day,
- operation_category: 'renew',
- duration: '1year',
- price: 100000
- })
-
- old_balance = @registrar1.balance
- old_activities = @registrar1.cash_account.account_activities.count
-
- domain.valid_to = Time.zone.now.to_date + 10.days
- domain.save
-
- exp_date = domain.valid_to.to_date
- xml = @epp_xml.domain.renew(
- name: { value: domain.name },
- curExpDate: { value: exp_date.to_s },
- period: { value: '1', attrs: { unit: 'y' } }
- )
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Billing failure - credit balance low'
- response[:results][0][:result_code].should == '2104'
-
- domain.reload
- domain.valid_to.should == exp_date # ensure domain was not renewed
-
- @registrar1.balance.should == old_balance
- @registrar1.cash_account.account_activities.count.should == old_activities
- f.delete
- end
-
- it 'returns an error when given and current exp dates do not match' do
- xml = @epp_xml.domain.renew(
- name: { value: domain.name },
- curExpDate: { value: '2200-08-07' },
- period: { value: '1', attrs: { unit: 'y' } }
- )
-
- response = epp_plain_request(xml)
- response[:results][0][:result_code].should == '2306'
- response[:results][0][:msg].should == 'Given and current expire dates do not match'
- end
-
- it 'returns an error when period is invalid' do
- domain.valid_to = Time.zone.now.to_date + 10.days
- domain.save
- exp_date = domain.valid_to.to_date
-
- xml = @epp_xml.domain.renew(
- name: { value: domain.name },
- curExpDate: { value: exp_date.to_s },
- period: { value: '4', attrs: { unit: 'y' } }
- )
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Period must add up to 1, 2 or 3 years [period]'
- response[:results][0][:result_code].should == '2306'
- response[:results][0][:value].should == '4'
- end
-
- it 'does not renew a domain unless less than 90 days till expiration' do
- # both days are inclusive
- domain.valid_to = Time.zone.now.to_date + 90.days
- domain.save
- exp_date = domain.valid_to.to_date
-
- xml = @epp_xml.domain.renew(
- name: { value: domain.name },
- curExpDate: { value: exp_date.to_s },
- period: { value: '1', attrs: { unit: 'y' } }
- )
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Object is not eligible for renewal'
- response[:results][0][:result_code].should == '2105'
-
- domain.valid_to = Time.zone.now.to_date + 89.days
- domain.save
- exp_date = domain.valid_to.to_date
-
- xml = @epp_xml.domain.renew(
- name: { value: domain.name },
- curExpDate: { value: exp_date.to_s },
- period: { value: '1', attrs: { unit: 'y' } }
- )
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Command completed successfully'
- response[:results][0][:result_code].should == '1000'
- end
-
- it 'does not renew a domain unless less than 90 days till expiration' do
- Setting.days_to_renew_domain_before_expire = 0
-
- domain.valid_to = Time.zone.now.to_date + 5.years
- domain.save
- exp_date = domain.valid_to.to_date
-
- xml = @epp_xml.domain.renew(
- name: { value: domain.name },
- curExpDate: { value: exp_date.to_s },
- period: { value: '1', attrs: { unit: 'y' } }
- )
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Command completed successfully'
- response[:results][0][:result_code].should == '1000'
- Setting.days_to_renew_domain_before_expire = 90
- end
-
- it 'does not renew a domain if it is a delete candidate' do
- domain.valid_to = Time.zone.now + 10.days
- domain.delete_at = Time.zone.now
- domain.save
-
- Domain.start_delete_period
-
- exp_date = domain.valid_to.to_date
-
- xml = @epp_xml.domain.renew(
- name: { value: domain.name },
- curExpDate: { value: exp_date.to_s },
- period: { value: '1', attrs: { unit: 'y' } }
- )
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Object is not eligible for renewal'
- response[:results][0][:result_code].should == '2105'
- end
-
- it 'should renew a expired domain' do
- old_valid_to = Time.zone.now - 90.days
- old_outzone_at = Time.zone.now - 60.days
- old_delete_at = Time.zone.now - 30.days
- domain.valid_to = old_valid_to
- domain.outzone_at = old_outzone_at
- domain.delete_at = old_delete_at
- domain.save
-
- Domain.start_expire_period
- domain.reload
- domain.valid_to = old_valid_to
- domain.outzone_at = old_outzone_at
- domain.delete_at = old_delete_at
- domain.save
- Domain.start_redemption_grace_period
-
- domain.reload
- domain.statuses.include?(DomainStatus::EXPIRED).should == true
- domain.statuses.include?(DomainStatus::SERVER_HOLD).should == true
- domain.statuses.include?(DomainStatus::OK).should == false
-
- exp_date = domain.valid_to.to_date
-
- xml = @epp_xml.domain.renew(
- name: { value: domain.name },
- curExpDate: { value: exp_date.to_s },
- period: { value: '1', attrs: { unit: 'y' } }
- )
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Command completed successfully'
- response[:results][0][:result_code].should == '1000'
-
- domain.reload
- domain.statuses.include?(DomainStatus::EXPIRED).should == false
- domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false
- domain.statuses.include?(DomainStatus::OK).should == true
-
- domain.reload
- domain.valid_to.should be_within(5).of(old_valid_to + 1.year)
- domain.outzone_at.should be_nil
- domain.delete_at.should be_nil
- end
-
- it 'does not renew foreign domain' do
- login_as :registrar2 do
- exp_date = 1.year.since.to_date
- xml = @epp_xml.domain.renew(
- name: { value: domain.name },
- curExpDate: { value: exp_date.to_s },
- period: { value: '1', attrs: { unit: 'y' } }
- )
-
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Authorization error'
- response[:results][0][:result_code].should == '2201'
- end
- end
-
- ### INFO ###
- it 'returns domain info' do
- domain.statuses << DomainStatus::CLIENT_HOLD
- domain.nameservers.build(hostname: 'ns1.example.com', ipv4: '192.168.1.1', ipv6: '1080:0:0:0:8:800:200C:417A')
-
- domain.dnskeys.build(
- ds_key_tag: '123',
- ds_alg: 3,
- ds_digest_type: 1,
- ds_digest: '0D85A305D22FCB355BBE29AE9809363D697B64782B9CC73AE349350F8C2AE4BB',
- flags: 257,
- protocol: 3,
- alg: 3,
- public_key: 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8'
- )
-
- domain.dnskeys.build(
- ds_key_tag: '123',
- ds_alg: 3,
- ds_digest_type: 1,
- ds_digest: '0D85A305D22FCB355BBE29AE9809363D697B64782B9CC73AE349350F8C2AE4BB',
- flags: 0,
- protocol: 3,
- alg: 5,
- public_key: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
- )
-
- domain.save
-
- xml = domain_info_xml(name: { value: domain.name })
- response = epp_plain_request(xml)
- response[:results][0][:msg].should == 'Command completed successfully'
- response[:results][0][:result_code].should == '1000'
- response[:clTRID].should be_nil
-
- inf_data = response[:parsed].css('resData infData')
- inf_data.css('name').text.should == domain.name
- inf_data.css('status').first[:s].should == 'clientHold'
- inf_data.css('registrant').text.should == domain.registrant_code
- inf_data.css('roid').text.should == domain.roid
-
- admin_contacts_from_request = inf_data.css('contact[type="admin"]').map(&:text)
- admin_contacts_existing = domain.admin_contacts.pluck(:code)
-
- admin_contacts_from_request.should == admin_contacts_existing
-
- hosts_from_request = inf_data.css('hostName').map(&:text)
- hosts_existing = domain.nameservers.pluck(:hostname).sort
-
- hosts_from_request.sort.should == hosts_existing
-
- ns1 = inf_data.css('hostAttr').last
-
- ns1.css('hostName').last.text.should == 'ns1.example.com'
- ns1.css('hostAddr').first.text.should == '192.168.1.1'
- ns1.css('hostAddr').last.text.should == '1080:0:0:0:8:800:200C:417A'
- inf_data.css('crDate').text.should == domain.created_at.in_time_zone.utc.utc.iso8601
- inf_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601
- inf_data.css('pw').text.should == domain.auth_info
-
- ds_data_1 = response[:parsed].css('dsData')[0]
-
- ds_data_1.css('keyTag').first.text.should == '123'
- ds_data_1.css('alg').first.text.should == '3'
- ds_data_1.css('digestType').first.text.should == '1'
- ds_data_1.css('digest').first.text.should == '0D85A305D22FCB355BBE29AE9809363D697B64782B9CC73AE349350F8C2AE4BB'
-
- dnskey_1 = ds_data_1.css('keyData')[0]
- dnskey_1.css('flags').first.text.should == '257'
- dnskey_1.css('protocol').first.text.should == '3'
- dnskey_1.css('alg').first.text.should == '3'
- dnskey_1.css('pubKey').first.text.should == 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8'
-
- ds_data_2 = response[:parsed].css('dsData')[1]
-
- dnskey_2 = ds_data_2.css('keyData')[0]
- dnskey_2.css('flags').first.text.should == '0'
- dnskey_2.css('protocol').first.text.should == '3'
- dnskey_2.css('alg').first.text.should == '5'
- dnskey_2.css('pubKey').first.text.should == '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
-
- domain.touch
-
- response = epp_plain_request(domain_info_xml(name: { value: domain.name }))
- inf_data = response[:parsed].css('resData infData')
-
- inf_data.css('upDate').text.should == domain.updated_at.in_time_zone.utc.utc.iso8601
- end
-
- it 'returns domain info with different nameservers' do
- domain.nameservers = []
- domain.save
-
- domain.nameservers.build(hostname: "ns1.#{domain.name}", ipv4: '192.168.1.1', ipv6: '1080:0:0:0:8:800:200C:417A')
- domain.nameservers.build(hostname: "ns2.#{domain.name}", ipv4: '192.168.1.1', ipv6: '1080:0:0:0:8:800:200C:417A')
- domain.nameservers.build(hostname: "ns3.test.ee", ipv4: '192.168.1.1', ipv6: '1080:0:0:0:8:800:200C:417A')
- domain.save
-
- xml = domain_info_xml(name: { value: domain.name, attrs: { hosts: 'invalid' } })
- response = epp_plain_request(xml)
- response[:msg].should == "Element '{https://epp.tld.ee/schema/domain-eis-1.0.xsd}name', "\
- "attribute 'hosts': [facet 'enumeration'] The value 'invalid' is not an element of the "\
- "set {'all', 'del', 'none', 'sub'}."
- response[:result_code].should == '2001'
-
- xml = domain_info_xml(name: { value: domain.name, attrs: { hosts: 'sub' } })
- response = epp_plain_request(xml)
-
- inf_data = response[:parsed].css('resData infData')
- inf_data.css('hostAttr').count.should == 2
- inf_data.css('hostName').first.text.should == "ns1.#{domain.name}"
- inf_data.css('hostName').last.text.should == "ns2.#{domain.name}"
-
- xml = domain_info_xml(name: { value: domain.name, attrs: { hosts: 'del' } })
- response = epp_plain_request(xml)
-
- inf_data = response[:parsed].css('resData infData')
- inf_data.css('hostAttr').count.should == 1
- inf_data.css('hostName').first.text.should == "ns3.test.ee"
-
- xml = domain_info_xml(name: { value: domain.name, attrs: { hosts: 'none' } })
- response = epp_plain_request(xml)
-
- inf_data = response[:parsed].css('resData infData')
- inf_data.css('ns').count.should == 0
- inf_data.css('hostAttr').count.should == 0
-
- xml = domain_info_xml(name: { value: domain.name, attrs: { hosts: 'all' } })
- response = epp_plain_request(xml)
-
- inf_data = response[:parsed].css('resData infData')
- inf_data.css('hostAttr').count.should == 3
- end
-
- it 'returns error when domain can not be found' do
- response = epp_plain_request(domain_info_xml(name: { value: 'test.ee' }))
- response[:results][0][:result_code].should == '2303'
- response[:results][0][:msg].should == 'Domain not found'
- end
-
- it 'sets ok status by default' do
- response = epp_plain_request(domain_info_xml(name: { value: domain.name }))
- inf_data = response[:parsed].css('resData infData')
- inf_data.css('status').first[:s].should == 'ok'
- end
-
- it 'can not see other registrar domains with invalid password' do
- login_as :registrar2 do
- response = epp_plain_request(domain_info_xml(name: { value: domain.name }))
- response[:result_code].should == '2201'
- response[:msg].should == 'Authorization error'
- end
- end
-
- it 'can see other registrar domains without password' do
- login_as :registrar2 do
- response = epp_plain_request(domain_info_xml(
- name: { value: domain.name },
- authInfo: nil
- ))
-
- response[:result_code].should == '1000'
- response[:parsed].css('authInfo pw').first.should == nil
- end
- end
-
- it 'can see other registrar domains with correct password' do
- login_as :registrar2 do
- pw = domain.auth_info
- response = epp_plain_request(domain_info_xml(
- name: { value: domain.name },
- authInfo: { pw: { value: pw } }
- ))
-
- response[:result_code].should == '1000'
- response[:parsed].css('authInfo pw').text.should == pw
- end
- end
-
- ### DELETE ###
- it 'deletes domain' do
- response = epp_plain_request(@epp_xml.domain.delete({
- name: { value: domain.name }
- }, {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- }))
-
- response[:msg].should == 'Command completed successfully; action pending'
- response[:result_code].should == '1001'
-
- Domain.find_by(name: domain.name).should_not == nil
- end
-
- it 'does not delete domain with specific status' do
- domain.statuses << DomainStatus::CLIENT_DELETE_PROHIBITED
- domain.save
-
- response = epp_plain_request(@epp_xml.domain.delete({
- name: { value: domain.name }
- }, {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- }))
-
- response[:result_code].should == '2304'
- response[:msg].should == 'Domain status prohibits operation'
- end
-
- it 'does not delete domain with pending delete' do
- domain.statuses << DomainStatus::PENDING_DELETE
- domain.save
-
- response = epp_plain_request(@epp_xml.domain.delete({
- name: { value: domain.name }
- }, {
- _anonymus: [
- legalDocument: {
- value: 'dGVzdCBmYWlsCg==',
- attrs: { type: 'pdf' }
- }
- ]
- }))
-
- response[:msg].should == 'Object status prohibits operation'
- response[:result_code].should == '2304'
- end
-
- it 'does not delete domain without legal document' do
- response = epp_plain_request(@epp_xml.domain.delete(name: { value: 'example.ee' }))
- response[:result_code].should == '2003'
- response[:msg].should ==
- 'Required parameter missing: extension > extdata > legalDocument [legal_document]'
- end
-
- ### CHECK ###
- it 'checks a domain' do
- response = epp_plain_request(domain_check_xml({
- _anonymus: [
- { name: { value: 'one.ee' } }
- ]
- }))
-
- response[:result_code].should == '1000'
- response[:msg].should == 'Command completed successfully'
-
- res_data = response[:parsed].css('resData chkData cd name').first
- res_data.text.should == 'one.ee'
- res_data[:avail].should == '1'
-
- response = epp_plain_request(domain_check_xml({
- _anonymus: [
- { name: { value: domain.name } }
- ]
- }))
- res_data = response[:parsed].css('resData chkData cd').first
- name = res_data.css('name').first
- reason = res_data.css('reason').first
-
- name.text.should == domain.name
- name[:avail].should == '0'
- reason.text.should == 'in use'
- end
-
- it 'checks multiple domains' do
- xml = domain_check_xml({
- _anonymus: [
- { name: { value: 'one.ee' } },
- { name: { value: 'two.ee' } },
- { name: { value: 'three.ee' } }
- ]
- })
-
- response = epp_plain_request(xml)
- response[:result_code].should == '1000'
- response[:msg].should == 'Command completed successfully'
-
- res_data = response[:parsed].css('resData chkData cd name').first
- res_data.text.should == 'one.ee'
- res_data[:avail].should == '1'
-
- res_data = response[:parsed].css('resData chkData cd name').last
- res_data.text.should == 'three.ee'
- res_data[:avail].should == '1'
- end
-
- it 'checks invalid format domain' do
- xml = domain_check_xml({
- _anonymus: [
- { name: { value: 'one.ee' } },
- { name: { value: 'notcorrectdomain' } }
- ]
- })
-
- response = epp_plain_request(xml)
- response[:result_code].should == '1000'
- response[:msg].should == 'Command completed successfully'
-
- res_data = response[:parsed].css('resData chkData cd name').first
- res_data.text.should == 'one.ee'
- res_data[:avail].should == '1'
-
- res_data = response[:parsed].css('resData chkData cd').last
- name = res_data.css('name').first
- reason = res_data.css('reason').first
-
- name.text.should == 'notcorrectdomain'
- name[:avail].should == '0'
- reason.text.should == 'invalid format'
- end
-
- ### POLL ###
- it 'should show force delete in poll' do
- domain.set_force_delete
- response = epp_plain_request(@epp_xml.session.poll)
- msg_q = response[:parsed].css('msgQ')
- msg_q.css('msg').text.should == "Force delete set on domain #{domain.name}"
- end
- end
-end
diff --git a/spec/epp/epp_helper_spec.rb b/spec/epp/epp_helper_spec.rb
deleted file mode 100644
index ff8050386..000000000
--- a/spec/epp/epp_helper_spec.rb
+++ /dev/null
@@ -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('
-
-
-
-
- ' + dn + '
-
-
- ABC-12345
-
-
- ').to_s.squish
-
- generated = Nokogiri::XML(domain_transfer_xml(name: { value: dn })).to_s.squish
- generated.should == expected
-
- expected = Nokogiri::XML('
-
-
-
-
- one.ee
-
- test
-
-
-
- ABC-12345
-
-
- ').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
diff --git a/spec/epp/keyrelay_spec.rb b/spec/epp/keyrelay_spec.rb
deleted file mode 100644
index d42d96f4b..000000000
--- a/spec/epp/keyrelay_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/epp/poll_spec.rb b/spec/epp/poll_spec.rb
deleted file mode 100644
index 53f82221a..000000000
--- a/spec/epp/poll_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/epp/requests/contacts/create_with_two_addresses.xml b/spec/epp/requests/contacts/create_with_two_addresses.xml
deleted file mode 100644
index 640febf34..000000000
--- a/spec/epp/requests/contacts/create_with_two_addresses.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
- loc_int
-
- John Doe Int
- Example Int Inc.
-
- International street 1
- Dulles
- VA
- 20166-6503
- EE
-
-
-
- John Doe Loc
- Example Loc Inc.
-
- Local street 1
- Vancouver
- BC
- 27123
- CA
-
-
- +123.7035555555
- +1.7035555556
- jdoe@example.com
- 37605030299
-
- 2fooBAR
-
-
-
-
-
-
-
- ABC-12345
-
-
diff --git a/spec/epp/requests/contacts/delete.xml b/spec/epp/requests/contacts/delete.xml
deleted file mode 100644
index 004090aa2..000000000
--- a/spec/epp/requests/contacts/delete.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
- dwa1234
-
-
- ABC-12345
-
-
diff --git a/spec/epp/requests/contacts/delete_missing_attr.xml b/spec/epp/requests/contacts/delete_missing_attr.xml
deleted file mode 100644
index b3502252b..000000000
--- a/spec/epp/requests/contacts/delete_missing_attr.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
- ABC-12345
-
-
diff --git a/spec/epp/requests/contacts/info.xml b/spec/epp/requests/contacts/info.xml
deleted file mode 100644
index 58fb2efee..000000000
--- a/spec/epp/requests/contacts/info.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
- info-4444
-
- 2fooBAR
-
-
-
- ABC-12345
-
-
diff --git a/spec/epp/requests/contacts/info_missing_attr.xml b/spec/epp/requests/contacts/info_missing_attr.xml
deleted file mode 100644
index 1b42c56f2..000000000
--- a/spec/epp/requests/contacts/info_missing_attr.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
- ABC-12345
-
-
diff --git a/spec/epp/requests/contacts/update.xml b/spec/epp/requests/contacts/update.xml
deleted file mode 100644
index 3dcf17374..000000000
--- a/spec/epp/requests/contacts/update.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
- sh8013
-
-
- John Doe
-
- 123 Example Dr.
- Suite 100
- Dulles
- VA
- 20166-6503
- EE
-
-
- +123.7035555555
- +1.7035555556
- jdoe@example.com
- J836954
-
- 2fooBAR
-
-
-
-
-
-
-
-
- ABC-12345
-
-
diff --git a/spec/epp/requests/contacts/update_missing_attr.xml b/spec/epp/requests/contacts/update_missing_attr.xml
deleted file mode 100644
index 74590aa25..000000000
--- a/spec/epp/requests/contacts/update_missing_attr.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
- ABC-12345
-
-
diff --git a/spec/epp/requests/contacts/update_with_errors.xml b/spec/epp/requests/contacts/update_with_errors.xml
deleted file mode 100644
index ac6426a21..000000000
--- a/spec/epp/requests/contacts/update_with_errors.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
- sh8013
-
- 123456798
- faulty
-
- 2fooBAR
-
-
-
-
- ABC-12345
-
-
diff --git a/spec/epp/session_spec.rb b/spec/epp/session_spec.rb
deleted file mode 100644
index d36e8f694..000000000
--- a/spec/epp/session_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/admin/account_activity_spec.rb b/spec/features/admin/account_activity_spec.rb
deleted file mode 100644
index 0101337b6..000000000
--- a/spec/features/admin/account_activity_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/admin/admin_user_spec.rb b/spec/features/admin/admin_user_spec.rb
deleted file mode 100644
index 427e6523f..000000000
--- a/spec/features/admin/admin_user_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/admin/api_user_spec.rb b/spec/features/admin/api_user_spec.rb
deleted file mode 100644
index ee53888d7..000000000
--- a/spec/features/admin/api_user_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/admin/bank_statement_spec.rb b/spec/features/admin/bank_statement_spec.rb
deleted file mode 100644
index b6ac8dcd2..000000000
--- a/spec/features/admin/bank_statement_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/admin/blocked_domain_spec.rb b/spec/features/admin/blocked_domain_spec.rb
deleted file mode 100644
index 432556d64..000000000
--- a/spec/features/admin/blocked_domain_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/admin/contact_spec.rb b/spec/features/admin/contact_spec.rb
deleted file mode 100644
index 6edaaf2d1..000000000
--- a/spec/features/admin/contact_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/admin/domain_spec.rb b/spec/features/admin/domain_spec.rb
deleted file mode 100644
index 755a30c6f..000000000
--- a/spec/features/admin/domain_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/admin/epp_log_spec.rb b/spec/features/admin/epp_log_spec.rb
deleted file mode 100644
index 1bec69fe9..000000000
--- a/spec/features/admin/epp_log_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/admin/invoice_spec.rb b/spec/features/admin/invoice_spec.rb
deleted file mode 100644
index 1e10f066b..000000000
--- a/spec/features/admin/invoice_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/admin/mail_templates_spec.rb b/spec/features/admin/mail_templates_spec.rb
deleted file mode 100644
index c6dfdaaf6..000000000
--- a/spec/features/admin/mail_templates_spec.rb
+++ /dev/null
@@ -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
Test
'
- 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
diff --git a/spec/features/admin/repp_log_spec.rb b/spec/features/admin/repp_log_spec.rb
deleted file mode 100644
index 2b3058c2d..000000000
--- a/spec/features/admin/repp_log_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/admin/reserved_domain_spec.rb b/spec/features/admin/reserved_domain_spec.rb
deleted file mode 100644
index 276907c6b..000000000
--- a/spec/features/admin/reserved_domain_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/admin/white_ip_spec.rb b/spec/features/admin/white_ip_spec.rb
deleted file mode 100644
index d077e687f..000000000
--- a/spec/features/admin/white_ip_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/admin/zonefile_setting_spec.rb b/spec/features/admin/zonefile_setting_spec.rb
deleted file mode 100644
index 71cf1e6f2..000000000
--- a/spec/features/admin/zonefile_setting_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/registrant/domain_delete_confirm_spec.rb b/spec/features/registrant/domain_delete_confirm_spec.rb
deleted file mode 100644
index db5b0237d..000000000
--- a/spec/features/registrant/domain_delete_confirm_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/registrant/domain_update_confirm_spec.rb b/spec/features/registrant/domain_update_confirm_spec.rb
deleted file mode 100644
index b9703165e..000000000
--- a/spec/features/registrant/domain_update_confirm_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/registrant/root_spec.rb b/spec/features/registrant/root_spec.rb
deleted file mode 100644
index b2b77d651..000000000
--- a/spec/features/registrant/root_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/registrar/account_activity_spec.rb b/spec/features/registrar/account_activity_spec.rb
deleted file mode 100644
index 3d97be16a..000000000
--- a/spec/features/registrar/account_activity_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/registrar/contact_spec.rb b/spec/features/registrar/contact_spec.rb
deleted file mode 100644
index 6e3b1dfba..000000000
--- a/spec/features/registrar/contact_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/registrar/domain_spec.rb b/spec/features/registrar/domain_spec.rb
deleted file mode 100644
index 956ddef4d..000000000
--- a/spec/features/registrar/domain_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/registrar/invoices_spec.rb b/spec/features/registrar/invoices_spec.rb
deleted file mode 100644
index fee6e8fb6..000000000
--- a/spec/features/registrar/invoices_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/registrar/root_spec.rb b/spec/features/registrar/root_spec.rb
deleted file mode 100644
index a00b80b3c..000000000
--- a/spec/features/registrar/root_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/registrar/sessions_spec.rb b/spec/features/registrar/sessions_spec.rb
deleted file mode 100644
index f6f10ceb8..000000000
--- a/spec/features/registrar/sessions_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/sessions_spec.rb b/spec/features/sessions_spec.rb
deleted file mode 100644
index 8eba74afc..000000000
--- a/spec/features/sessions_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/features/setting_management_spec.rb b/spec/features/setting_management_spec.rb
deleted file mode 100644
index 60ccdc7b2..000000000
--- a/spec/features/setting_management_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/mailers/contact_mailer_spec.rb b/spec/mailers/contact_mailer_spec.rb
deleted file mode 100644
index 2cb8fe344..000000000
--- a/spec/mailers/contact_mailer_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/mailers/domain_mailer_spec.rb b/spec/mailers/domain_mailer_spec.rb
deleted file mode 100644
index 9963fdd38..000000000
--- a/spec/mailers/domain_mailer_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/models/certificate_spec.rb b/spec/models/certificate_spec.rb
deleted file mode 100644
index 74d0b460e..000000000
--- a/spec/models/certificate_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/models/dnskey_spec.rb b/spec/models/dnskey_spec.rb
index 13ad884b6..ef0f52475 100644
--- a/spec/models/dnskey_spec.rb
+++ b/spec/models/dnskey_spec.rb
@@ -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
diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb
index 9e1a83b05..9d9c6439e 100644
--- a/spec/models/domain_spec.rb
+++ b/spec/models/domain_spec.rb
@@ -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,
diff --git a/spec/models/domain_transfer_spec.rb b/spec/models/domain_transfer_spec.rb
index 105db1d48..e46b46aca 100644
--- a/spec/models/domain_transfer_spec.rb
+++ b/spec/models/domain_transfer_spec.rb
@@ -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
diff --git a/spec/models/keyrelay_spec.rb b/spec/models/keyrelay_spec.rb
index 9dada32c2..5243cbf6c 100644
--- a/spec/models/keyrelay_spec.rb
+++ b/spec/models/keyrelay_spec.rb
@@ -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
diff --git a/spec/models/nameserver_spec.rb b/spec/models/nameserver_spec.rb
index 5971cae23..586f83390 100644
--- a/spec/models/nameserver_spec.rb
+++ b/spec/models/nameserver_spec.rb
@@ -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'),
diff --git a/spec/models/registrant_verification_spec.rb b/spec/models/registrant_verification_spec.rb
index c9278cd4a..fc9b8ab82 100644
--- a/spec/models/registrant_verification_spec.rb
+++ b/spec/models/registrant_verification_spec.rb
@@ -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
diff --git a/spec/models/registrar_spec.rb b/spec/models/registrar_spec.rb
index ffe71c49a..1230899bc 100644
--- a/spec/models/registrar_spec.rb
+++ b/spec/models/registrar_spec.rb
@@ -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
diff --git a/spec/models/whois_record_spec.rb b/spec/models/whois_record_spec.rb
deleted file mode 100644
index 95c4c2082..000000000
--- a/spec/models/whois_record_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/models/zonefile_setting_spec.rb b/spec/models/zonefile_setting_spec.rb
index 9405aa063..9b58f89dc 100644
--- a/spec/models/zonefile_setting_spec.rb
+++ b/spec/models/zonefile_setting_spec.rb
@@ -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
diff --git a/spec/requests/repp_doc_template.md.erb b/spec/requests/repp_doc_template.md.erb
deleted file mode 100644
index 100e95081..000000000
--- a/spec/requests/repp_doc_template.md.erb
+++ /dev/null
@@ -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 %>
-```
diff --git a/spec/requests/v1/account_spec.rb b/spec/requests/v1/account_spec.rb
deleted file mode 100644
index e99a460a5..000000000
--- a/spec/requests/v1/account_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/requests/v1/contact_spec.rb b/spec/requests/v1/contact_spec.rb
deleted file mode 100644
index 6db06c28d..000000000
--- a/spec/requests/v1/contact_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/requests/v1/domain_spec.rb b/spec/requests/v1/domain_spec.rb
deleted file mode 100644
index e79f2e71b..000000000
--- a/spec/requests/v1/domain_spec.rb
+++ /dev/null
@@ -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