Fix contact tests #2752

This commit is contained in:
Martin Lensment 2015-07-23 18:56:47 +03:00
parent 9379563683
commit 4294bf564c

View file

@ -59,33 +59,9 @@ describe 'EPP Contact', epp: true do
it 'fails if request xml is missing' do it 'fails if request xml is missing' do
response = epp_plain_request(@epp_xml.create, validate_input: false) response = epp_plain_request(@epp_xml.create, validate_input: false)
response[:results][0][:msg].should ==
'Required parameter missing: create > create > postalInfo > name [name]'
response[:results][1][:msg].should ==
'Required parameter missing: create > create > postalInfo > addr > street [street]'
response[:results][2][:msg].should ==
'Required parameter missing: create > create > postalInfo > addr > city [city]'
response[:results][3][:msg].should ==
'Required parameter missing: create > create > postalInfo > addr > pc [pc]'
response[:results][4][:msg].should ==
'Required parameter missing: create > create > postalInfo > addr > cc [cc]'
response[:results][5][:msg].should ==
'Required parameter missing: create > create > voice [voice]'
response[:results][6][:msg].should ==
'Required parameter missing: create > create > email [email]'
response[:results][7][:msg].should ==
'Required parameter missing: extension > extdata > ident [ident]'
response[:results][0][:result_code].should == '2003' response[:results][0][:msg].should == "Element '{https://raw.githubusercontent.com/internetee/registry/alpha/doc/schemas/contact-eis-1.0.xsd}create': Missing child element(s). Expected is one of ( {https://raw.githubusercontent.com/internetee/registry/alpha/doc/schemas/contact-eis-1.0.xsd}id, {https://raw.githubusercontent.com/internetee/registry/alpha/doc/schemas/contact-eis-1.0.xsd}postalInfo )."
response[:results][1][:result_code].should == '2003' response[:results][0][:result_code].should == '2001'
response[:results][2][:result_code].should == '2003'
response[:results][3][:result_code].should == '2003'
response[:results][4][:result_code].should == '2003'
response[:results][5][:result_code].should == '2003'
response[:results][6][:result_code].should == '2003'
response[:results][7][:result_code].should == '2003'
response[:results].count.should == 8
end end
it 'successfully creates a contact' do it 'successfully creates a contact' do
@ -197,9 +173,8 @@ describe 'EPP Contact', epp: true do
} }
} }
response = create_request({}, extension, validate_input: false) response = create_request({}, extension, validate_input: false)
response[:msg].should == response[:msg].should == "Element '{https://raw.githubusercontent.com/internetee/registry/alpha/doc/schemas/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'."
'Ident country code is not valid, should be in ISO_3166-1 alpha 2 format [ident]' response[:result_code].should == '2001'
response[:result_code].should == '2005'
end end
it 'should return country missing' do it 'should return country missing' do
@ -210,9 +185,8 @@ describe 'EPP Contact', epp: true do
} }
} }
response = create_request({}, extension, validate_input: false) response = create_request({}, extension, validate_input: false)
response[:msg].should == response[:msg].should == "Element '{https://raw.githubusercontent.com/internetee/registry/alpha/doc/schemas/eis-1.0.xsd}ident': The attribute 'cc' is required but missing."
'Required ident attribute missing: cc' response[:result_code].should == '2001'
response[:result_code].should == '2003'
end end
it 'should return country missing' do it 'should return country missing' do
@ -222,9 +196,8 @@ describe 'EPP Contact', epp: true do
} }
} }
response = create_request({}, extension, validate_input: false) response = create_request({}, extension, validate_input: false)
response[:msg].should == response[:msg].should == "Element '{https://raw.githubusercontent.com/internetee/registry/alpha/doc/schemas/eis-1.0.xsd}ident': The attribute 'type' is required but missing."
'Required ident attribute missing: type' response[:result_code].should == '2001'
response[:result_code].should == '2003'
end end
it 'should add registrar prefix for code when legacy prefix present' do it 'should add registrar prefix for code when legacy prefix present' do
@ -336,14 +309,7 @@ describe 'EPP Contact', epp: true do
it 'fails if request is invalid' do it 'fails if request is invalid' do
response = epp_plain_request(@epp_xml.update, validate_input: false) response = epp_plain_request(@epp_xml.update, validate_input: false)
response[:results][0][:msg].should == "Element '{https://raw.githubusercontent.com/internetee/registry/alpha/doc/schemas/contact-eis-1.0.xsd}update': Missing child element(s). Expected is ( {https://raw.githubusercontent.com/internetee/registry/alpha/doc/schemas/contact-eis-1.0.xsd}id )."
response[:results][0][:msg].should ==
'Required parameter missing: add, rem or chg'
response[:results][0][:result_code].should == '2003'
response[:results][1][:msg].should ==
'Required parameter missing: update > update > id [id]'
response[:results][1][:result_code].should == '2003'
response[:results].count.should == 2
end end
it 'returns error if obj doesnt exist' do it 'returns error if obj doesnt exist' do
@ -432,8 +398,8 @@ describe 'EPP Contact', epp: true do
}, {}, { validate_input: false } }, {}, { validate_input: false }
) )
response[:msg].should == 'Object does not exist' response[:msg].should == "Element '{https://raw.githubusercontent.com/internetee/registry/alpha/doc/schemas/contact-eis-1.0.xsd}id': This element is not expected."
response[:result_code].should == '2303' response[:result_code].should == '2001'
@contact.reload.code.should == 'FIRST0:SH8013' @contact.reload.code.should == 'FIRST0:SH8013'
end end
@ -492,16 +458,16 @@ describe 'EPP Contact', epp: true do
id: { value: 'FIRST0:SH8013' }, id: { value: 'FIRST0:SH8013' },
add: [{ add: [{
_anonymus: [ _anonymus: [
{ status: { value: 'Payment overdue.', attrs: { s: 'clientHold', lang: 'en' } } }, { status: { value: 'Payment overdue.', attrs: { s: 'clientDeleteProhibited', lang: 'en' } } },
{ status: { value: '', attrs: { s: 'clientUpdateProhibited' } } } { status: { value: '', attrs: { s: 'clientUpdateProhibited' } } }
] ]
}] }]
}) })
response = epp_plain_request(xml, validate_input: false) response = epp_plain_request(xml, validate_input: false)
response[:results][0][:result_code].should == '2306'
response[:results][0][:msg].should == "Parameter value policy error. Client-side object status "\ response[:results][0][:msg].should == "Parameter value policy error. Client-side object status "\
"management not supported: status [status]" "management not supported: status [status]"
response[:results][0][:result_code].should == '2306'
Setting.client_status_editing_enabled = true Setting.client_status_editing_enabled = true
end end
@ -543,6 +509,7 @@ describe 'EPP Contact', epp: true do
end end
it 'should honor chg value over add value when both changes same attribute' do it 'should honor chg value over add value when both changes same attribute' do
pending 'It should not be possible to add voice (in add)'
xml = @epp_xml.update({ xml = @epp_xml.update({
id: { value: 'FIRST0:SH8013' }, id: { value: 'FIRST0:SH8013' },
add: { add: {
@ -585,8 +552,10 @@ describe 'EPP Contact', epp: true do
# TODO: Update request rem block must be analyzed # TODO: Update request rem block must be analyzed
it 'should not allow to remove required attribute' do it 'should not allow to remove required attribute' do
pending 'It should not be possible to remove or add voice (in add and rem)'
contact = Contact.find_by(code: 'FIRST0:SH8013') contact = Contact.find_by(code: 'FIRST0:SH8013')
phone = contact.phone phone = contact.phone
# TODO: Refactor authInfo under chg block
xml = @epp_xml.update({ xml = @epp_xml.update({
id: { value: 'FIRST0:SH8013' }, id: { value: 'FIRST0:SH8013' },
authInfo: { pw: { value: 'password' } }, authInfo: { pw: { value: 'password' } },
@ -604,6 +573,8 @@ describe 'EPP Contact', epp: true do
end end
it 'should honor add over rem' do it 'should honor add over rem' do
pending 'It should not be possible to remove or add voice (in add and rem)'
# TODO: Refactor authInfo under chg block
xml = @epp_xml.update({ xml = @epp_xml.update({
id: { value: 'FIRST0:SH8013' }, id: { value: 'FIRST0:SH8013' },
authInfo: { pw: { value: 'password' } }, authInfo: { pw: { value: 'password' } },
@ -626,6 +597,8 @@ describe 'EPP Contact', epp: true do
end end
it 'should honor chg over rem' do it 'should honor chg over rem' do
pending 'It should not be possible to remove or add voice (in add and rem)'
# TODO: Refactor authInfo under chg block
xml = @epp_xml.update({ xml = @epp_xml.update({
id: { value: 'FIRST0:SH8013' }, id: { value: 'FIRST0:SH8013' },
authInfo: { pw: { value: 'password' } }, authInfo: { pw: { value: 'password' } },
@ -648,6 +621,8 @@ describe 'EPP Contact', epp: true do
end end
it 'should honor chg over rem and add' do it 'should honor chg over rem and add' do
pending 'It should not be possible to remove or add voice (in add and rem)'
# TODO: Refactor authInfo under chg block
xml = @epp_xml.update({ xml = @epp_xml.update({
id: { value: 'FIRST0:SH8013' }, id: { value: 'FIRST0:SH8013' },
authInfo: { pw: { value: 'password' } }, authInfo: { pw: { value: 'password' } },
@ -673,6 +648,7 @@ describe 'EPP Contact', epp: true do
end end
it 'should not remove password' do it 'should not remove password' do
pending 'There should be no possibility to remove pw'
xml = @epp_xml.update({ xml = @epp_xml.update({
id: { value: 'FIRST0:SH8013' }, id: { value: 'FIRST0:SH8013' },
authInfo: { pw: { value: 'password' } }, authInfo: { pw: { value: 'password' } },
@ -690,11 +666,14 @@ describe 'EPP Contact', epp: true do
end end
it 'should return general policy error when removing org' do it 'should return general policy error when removing org' do
pending 'Test says it should throw error when removing org, it does not do it when removing it with chg block'
xml = @epp_xml.update({ xml = @epp_xml.update({
id: { value: 'FIRST0:SH8013' }, id: { value: 'FIRST0:SH8013' },
authInfo: { pw: { value: 'password' } }, chg: {
rem: { postalInfo: {
postalInfo: { org: { value: 'not important' } } org: { value: '' }
},
authInfo: { pw: { value: 'password' } }
} }
}) })
@ -705,6 +684,8 @@ describe 'EPP Contact', epp: true do
end end
it 'should return error when removing street' do it 'should return error when removing street' do
pending 'Test says it tests removing street, but actually street is not removed'
# TODO: Refactor authInfo under chg block
xml = @epp_xml.update({ xml = @epp_xml.update({
id: { value: 'FIRST0:SH8013' }, id: { value: 'FIRST0:SH8013' },
authInfo: { pw: { value: 'password' } }, authInfo: { pw: { value: 'password' } },
@ -738,9 +719,8 @@ describe 'EPP Contact', epp: true do
it 'fails if request is invalid' do it 'fails if request is invalid' do
response = epp_plain_request(@epp_xml.delete, validate_input: false) response = epp_plain_request(@epp_xml.delete, validate_input: false)
response[:results][0][:msg].should == response[:results][0][:msg].should == "Element '{https://raw.githubusercontent.com/internetee/registry/alpha/doc/schemas/contact-eis-1.0.xsd}delete': Missing child element(s). Expected is ( {https://raw.githubusercontent.com/internetee/registry/alpha/doc/schemas/contact-eis-1.0.xsd}id )."
'Required parameter missing: delete > delete > id [id]' response[:results][0][:result_code].should == '2001'
response[:results][0][:result_code].should == '2003'
response[:results].count.should == 1 response[:results].count.should == 1
end end
@ -834,8 +814,8 @@ describe 'EPP Contact', epp: true do
it 'fails if request is invalid' do it 'fails if request is invalid' do
response = epp_plain_request(@epp_xml.check, validate_input: false) response = epp_plain_request(@epp_xml.check, validate_input: false)
response[:results][0][:msg].should == 'Required parameter missing: check > check > id [id]' response[:results][0][:msg].should == "Element '{https://raw.githubusercontent.com/internetee/registry/alpha/doc/schemas/contact-eis-1.0.xsd}check': Missing child element(s). Expected is ( {https://raw.githubusercontent.com/internetee/registry/alpha/doc/schemas/contact-eis-1.0.xsd}id )."
response[:results][0][:result_code].should == '2003' response[:results][0][:result_code].should == '2001'
response[:results].count.should == 1 response[:results].count.should == 1
end end
@ -888,9 +868,8 @@ describe 'EPP Contact', epp: true do
it 'fails if request invalid' do it 'fails if request invalid' do
response = epp_plain_request(@epp_xml.info, validate_input: false) response = epp_plain_request(@epp_xml.info, validate_input: false)
response[:results][0][:msg].should == response[:results][0][:msg].should == "Element '{https://raw.githubusercontent.com/internetee/registry/alpha/doc/schemas/contact-eis-1.0.xsd}info': Missing child element(s). Expected is ( {https://raw.githubusercontent.com/internetee/registry/alpha/doc/schemas/contact-eis-1.0.xsd}id )."
'Required parameter missing: info > info > id [id]' response[:results][0][:result_code].should == '2001'
response[:results][0][:result_code].should == '2003'
response[:results].count.should == 1 response[:results].count.should == 1
end end