From 02d68386fbc035617eb6dcdd55ad1b96be31c670 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Tue, 5 May 2015 15:29:26 +0300 Subject: [PATCH] updated contact code spec --- spec/epp/contact_spec.rb | 94 +++++++++++++------------- spec/fabricators/contact_fabricator.rb | 2 +- 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index 597fd6292..a66dffa4c 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -147,7 +147,7 @@ describe 'EPP Contact', epp: true do response[:msg].should == 'Command completed successfully' response[:result_code].should == '1000' - Contact.last.code.should == 'FIRST0:abc12345' + Contact.last.code.should == 'FIRST0:ABC12345' end it 'should add registrar prefix for code when missing' do @@ -155,7 +155,7 @@ describe 'EPP Contact', epp: true do response[:msg].should == 'Command completed successfully' response[:result_code].should == '1000' - Contact.last.code.should == 'FIRST0:abc:ABC:12345' + Contact.last.code.should == 'FIRST0:ABC:ABC:12345' end it 'should not allow spaces in custom code' do @@ -169,7 +169,7 @@ describe 'EPP Contact', epp: true do response[:msg].should == 'Command completed successfully' response[:result_code].should == '1000' - Contact.last.code.should == 'FIRST0:abc:ABC:NEW:12345' + Contact.last.code.should == 'FIRST0:ABC:ABC:NEW:12345' end it 'should not remove suffix CID' do @@ -177,7 +177,7 @@ describe 'EPP Contact', epp: true do response[:msg].should == 'Command completed successfully' response[:result_code].should == '1000' - Contact.last.code.should == 'FIRST0:abc:CID:ABC:NEW:12345' + Contact.last.code.should == 'FIRST0:ABC:CID:ABC:NEW:12345' end it 'should not add registrar prefix for code when prefix present' do @@ -185,7 +185,7 @@ describe 'EPP Contact', epp: true do response[:msg].should == 'Command completed successfully' response[:result_code].should == '1000' - Contact.last.code.should == 'FIRST0:abc22' + Contact.last.code.should == 'FIRST0:ABC22' end it 'should add registrar prefix for code does not match exactly to prefix' do @@ -193,7 +193,7 @@ describe 'EPP Contact', epp: true do response[:msg].should == 'Command completed successfully' response[:result_code].should == '1000' - Contact.last.code.should == 'FIRST0:cid2:first0:abc:ABC:11111' + Contact.last.code.should == 'FIRST0:CID2:FIRST0:ABC:ABC:11111' end it 'should ignore custom code when only contact prefix given' do @@ -248,7 +248,7 @@ describe 'EPP Contact', epp: true do :contact, registrar: @registrar1, email: 'not_updated@test.test', - code: 'sh8013' + code: 'SH8013' ) end @@ -296,7 +296,7 @@ describe 'EPP Contact', epp: true do end it 'is succesful' do - response = update_request({ id: { value: 'sh8013' } }) + response = update_request({ id: { value: 'SH8013' } }) response[:msg].should == 'Command completed successfully' @contact.reload @@ -306,7 +306,7 @@ describe 'EPP Contact', epp: true do it 'is succesful for own contact without password' do without_password = { - id: { value: 'sh8013' }, + id: { value: 'SH8013' }, chg: { postalInfo: { name: { value: 'John Doe Edited' } @@ -323,7 +323,7 @@ describe 'EPP Contact', epp: true do it 'should update other contact with correct password' do login_as :registrar2 do - response = update_request({ id: { value: 'sh8013' } }) + response = update_request({ id: { value: 'SH8013' } }) response[:msg].should == 'Command completed successfully' response[:result_code].should == '1000' end @@ -332,7 +332,7 @@ describe 'EPP Contact', epp: true do it 'should not update other contact without password' do login_as :registrar2 do without_password = { - id: { value: 'sh8013' }, + id: { value: 'SH8013' }, chg: { postalInfo: { name: { value: 'John Doe Edited' } @@ -350,7 +350,7 @@ describe 'EPP Contact', epp: true do it 'returns phone and email error' do response = update_request({ - id: { value: 'sh8013' }, + id: { value: 'SH8013' }, chg: { voice: { value: '123213' }, email: { value: 'wrong' } @@ -365,7 +365,7 @@ describe 'EPP Contact', epp: true do it 'should not update code with custom string' do response = update_request( - id: { value: 'sh8013' }, + id: { value: 'SH8013' }, chg: { id: { value: 'notpossibletoupdate' } } @@ -374,7 +374,7 @@ describe 'EPP Contact', epp: true do response[:msg].should == 'Object does not exist' response[:result_code].should == '2303' - @contact.reload.code.should == 'sh8013' + @contact.reload.code.should == 'SH8013' end it 'should update ident' do @@ -388,16 +388,16 @@ describe 'EPP Contact', epp: true do attrs: { type: 'birthday', cc: 'US' } } } - response = update_request({ id: { value: 'sh8013' } }, extension) + response = update_request({ id: { value: 'SH8013' } }, extension) response[:msg].should == 'Command completed successfully' response[:result_code].should == '1000' - Contact.find_by(code: 'sh8013').ident_type.should == 'birthday' + Contact.find_by(code: 'SH8013').ident_type.should == 'birthday' end it 'should return parameter value policy errror for org update' do response = update_request({ - id: { value: 'sh8013' }, + id: { value: 'SH8013' }, chg: { postalInfo: { org: { value: 'should not save' } } } @@ -406,12 +406,12 @@ describe 'EPP Contact', epp: true do 'Parameter value policy error. Org must be blank: postalInfo > org [org]' response[:result_code].should == '2306' - Contact.find_by(code: 'sh8013').org_name.should == nil + Contact.find_by(code: 'SH8013').org_name.should == nil end it 'should return parameter value policy errror for fax update' do response = update_request({ - id: { value: 'sh8013' }, + id: { value: 'SH8013' }, chg: { fax: { value: 'should not save' } } @@ -420,14 +420,14 @@ describe 'EPP Contact', epp: true do 'Parameter value policy error. Fax must be blank: fax [fax]' response[:result_code].should == '2306' - Contact.find_by(code: 'sh8013').fax.should == nil + Contact.find_by(code: '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: 'sh8013' }, + id: { value: 'SH8013' }, add: [{ _anonymus: [ { status: { value: 'Payment overdue.', attrs: { s: 'clientHold', lang: 'en' } } }, @@ -446,7 +446,7 @@ describe 'EPP Contact', epp: true do it 'should add value voice value' do xml = @epp_xml.update({ - id: { value: 'sh8013' }, + id: { value: 'SH8013' }, authInfo: { pw: { value: 'password' } }, add: { voice: { value: '+372.11111111' } @@ -457,7 +457,7 @@ describe 'EPP Contact', epp: true do response[:results][0][:msg].should == 'Command completed successfully' response[:results][0][:result_code].should == '1000' - contact = Contact.find_by(code: 'sh8013') + contact = Contact.find_by(code: 'SH8013') contact.phone.should == '+372.11111111' contact.update_attribute(:phone, '+372.7654321') # restore default value @@ -465,7 +465,7 @@ describe 'EPP Contact', epp: true do it 'should return error when add attributes phone value is empty' do xml = @epp_xml.update({ - id: { value: 'sh8013' }, + id: { value: 'SH8013' }, authInfo: { pw: { value: 'password' } }, add: { voice: { value: '' } @@ -478,12 +478,12 @@ describe 'EPP Contact', epp: true do 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: 'sh8013').phone.should == '+372.7654321' # aka not changed + Contact.find_by(code: 'SH8013').phone.should == '+372.7654321' # aka not changed end it 'should honor chg value over add value when both changes same attribute' do xml = @epp_xml.update({ - id: { value: 'sh8013' }, + id: { value: 'SH8013' }, authInfo: { pw: { value: 'password' } }, chg: { voice: { value: '+372.2222222222222' } @@ -497,7 +497,7 @@ describe 'EPP Contact', epp: true do response[:results][0][:msg].should == 'Command completed successfully' response[:results][0][:result_code].should == '1000' - contact = Contact.find_by(code: 'sh8013') + contact = Contact.find_by(code: 'SH8013') contact.phone.should == '+372.2222222222222' contact.update_attribute(:phone, '+372.7654321') # restore default value @@ -505,7 +505,7 @@ describe 'EPP Contact', epp: true do it 'should not allow to remove required voice attribute' do xml = @epp_xml.update({ - id: { value: 'sh8013' }, + id: { value: 'SH8013' }, authInfo: { pw: { value: 'password' } }, rem: { voice: { value: '+372.7654321' } @@ -516,13 +516,13 @@ describe 'EPP Contact', epp: true do response[:results][0][:msg].should == 'Required parameter missing - phone [phone]' response[:results][0][:result_code].should == '2003' - contact = Contact.find_by(code: 'sh8013') + contact = Contact.find_by(code: 'SH8013') contact.phone.should == '+372.7654321' end it 'should not allow to remove required attribute' do xml = @epp_xml.update({ - id: { value: 'sh8013' }, + id: { value: 'SH8013' }, authInfo: { pw: { value: 'password' } }, rem: { voice: { value: '+372.7654321' } @@ -533,13 +533,13 @@ describe 'EPP Contact', epp: true do response[:results][0][:msg].should == 'Required parameter missing - phone [phone]' response[:results][0][:result_code].should == '2003' - contact = Contact.find_by(code: 'sh8013') + contact = Contact.find_by(code: 'SH8013') contact.phone.should == '+372.7654321' end it 'should honor add over rem' do xml = @epp_xml.update({ - id: { value: 'sh8013' }, + id: { value: 'SH8013' }, authInfo: { pw: { value: 'password' } }, rem: { voice: { value: 'not important' } @@ -553,7 +553,7 @@ describe 'EPP Contact', epp: true do response[:results][0][:msg].should == 'Command completed successfully' response[:results][0][:result_code].should == '1000' - contact = Contact.find_by(code: 'sh8013') + contact = Contact.find_by(code: 'SH8013') contact.phone.should == '+372.3333333' contact.update_attribute(:phone, '+372.7654321') # restore default value @@ -561,7 +561,7 @@ describe 'EPP Contact', epp: true do it 'should honor chg over rem' do xml = @epp_xml.update({ - id: { value: 'sh8013' }, + id: { value: 'SH8013' }, authInfo: { pw: { value: 'password' } }, rem: { voice: { value: 'not important' } @@ -575,7 +575,7 @@ describe 'EPP Contact', epp: true do response[:results][0][:msg].should == 'Command completed successfully' response[:results][0][:result_code].should == '1000' - contact = Contact.find_by(code: 'sh8013') + contact = Contact.find_by(code: 'SH8013') contact.phone.should == '+372.44444444' contact.update_attribute(:phone, '+372.7654321') # restore default value @@ -583,7 +583,7 @@ describe 'EPP Contact', epp: true do it 'should honor chg over rem and add' do xml = @epp_xml.update({ - id: { value: 'sh8013' }, + id: { value: 'SH8013' }, authInfo: { pw: { value: 'password' } }, chg: { voice: { value: '+372.666666' } @@ -600,7 +600,7 @@ describe 'EPP Contact', epp: true do response[:results][0][:msg].should == 'Command completed successfully' response[:results][0][:result_code].should == '1000' - contact = Contact.find_by(code: 'sh8013') + contact = Contact.find_by(code: 'SH8013') contact.phone.should == '+372.666666' contact.update_attribute(:phone, '+372.7654321') # restore default value @@ -608,7 +608,7 @@ describe 'EPP Contact', epp: true do it 'should not remove password' do xml = @epp_xml.update({ - id: { value: 'sh8013' }, + id: { value: 'SH8013' }, authInfo: { pw: { value: 'password' } }, rem: { authInfo: { pw: { value: 'password' } } @@ -619,13 +619,13 @@ describe 'EPP Contact', epp: true do response[:results][0][:msg].should == 'Command completed successfully' response[:results][0][:result_code].should == '1000' - contact = Contact.find_by(code: 'sh8013') + contact = Contact.find_by(code: 'SH8013') contact.auth_info.should == 'password' end it 'should return general policy error when removing org' do xml = @epp_xml.update({ - id: { value: 'sh8013' }, + id: { value: 'SH8013' }, authInfo: { pw: { value: 'password' } }, rem: { postalInfo: { org: { value: 'not important' } } @@ -640,7 +640,7 @@ describe 'EPP Contact', epp: true do it 'should return error when removing street' do xml = @epp_xml.update({ - id: { value: 'sh8013' }, + id: { value: 'SH8013' }, authInfo: { pw: { value: 'password' } }, rem: { postalInfo: { @@ -812,13 +812,13 @@ describe 'EPP Contact', epp: true 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][0][:value].should == 'NO-CONTACT' response[:results].count.should == 1 end it 'return info about contact' do @registrar1_contact = Fabricate( - :contact, code: 'info-4444', registrar: @registrar1, name: 'Johnny Awesome') + :contact, code: 'INFO-4444', registrar: @registrar1, name: 'Johnny Awesome') response = info_request({ id: { value: @registrar1_contact.code } }) response[:msg].should == 'Command completed successfully' @@ -829,7 +829,7 @@ describe 'EPP Contact', epp: true do end it 'should return ident in extension' do - @registrar1_contact = Fabricate(:contact, code: 'info-ident', + @registrar1_contact = Fabricate(:contact, code: 'INFO-IDENT', registrar: @registrar1, name: 'Johnny Awesome') response = info_request({ id: { value: @registrar1_contact.code } }) @@ -852,10 +852,10 @@ describe 'EPP Contact', epp: true do end it 'should honor new contact code format' do - @registrar1_contact = Fabricate(:contact, code: 'REGISTRAR1:test:custom:code') - @registrar1_contact.code.should == 'REGISTRAR1:test:custom:code' + @registrar1_contact = Fabricate(:contact, code: 'REGISTRAR1:TEST:CUSTOM:CODE') + @registrar1_contact.code.should == 'REGISTRAR1:TEST:CUSTOM:CODE' - response = info_request({ id: { value: 'REGISTRAR1:test:custom:code' } }) + response = info_request({ id: { value: 'REGISTRAR1:TEST:CUSTOM:CODE' } }) response[:msg].should == 'Command completed successfully' response[:result_code].should == '1000' diff --git a/spec/fabricators/contact_fabricator.rb b/spec/fabricators/contact_fabricator.rb index 36ec99de4..68289d77c 100644 --- a/spec/fabricators/contact_fabricator.rb +++ b/spec/fabricators/contact_fabricator.rb @@ -1,6 +1,6 @@ Fabricator(:contact) do registrar { Fabricate(:registrar) } - code { sequence(:code) { |i| "sh#{Faker::Number.number(8)}#{i}" } } + code { sequence(:code) { |i| "SH#{Faker::Number.number(8)}#{i}" } } auth_info 'password' name { sequence(:name) { |i| "#{Faker::Name.name}#{i}" } } phone '+372.12345678'