diff options
author | Michael Kozono <mkozono@gmail.com> | 2017-10-05 03:27:07 -0700 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2017-10-07 10:28:13 -0700 |
commit | 1d1ad7e0b68039100029f20a84fd867fe92cbb32 (patch) | |
tree | 406448ceb1d4ca70806f9eb477c8a5aee9c794c3 /spec/lib | |
parent | 1c945de93849b43d2bec9407bd0a7c4afd759796 (diff) | |
download | gitlab-ce-1d1ad7e0b68039100029f20a84fd867fe92cbb32.tar.gz |
Refactor DN error classes
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/ldap/dn_spec.rb | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/spec/lib/gitlab/ldap/dn_spec.rb b/spec/lib/gitlab/ldap/dn_spec.rb index 709eadd7e38..c300f7160fe 100644 --- a/spec/lib/gitlab/ldap/dn_spec.rb +++ b/spec/lib/gitlab/ldap/dn_spec.rb @@ -12,64 +12,64 @@ describe Gitlab::LDAP::DN do context 'when ending with a comma' do let(:given) { 'John Smith,' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, 'DN string ended unexpectedly') + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, 'DN string ended unexpectedly') end end context 'when given a BER encoded attribute value with a space in it' do let(:given) { '#aa aa' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, "Expected the end of an attribute value, but got \"a\"") + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, "Expected the end of an attribute value, but got \"a\"") end end context 'when given a BER encoded attribute value with a non-hex character in it' do let(:given) { '#aaXaaa' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, "Expected the first character of a hex pair, but got \"X\"") + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, "Expected the first character of a hex pair, but got \"X\"") end end context 'when given a BER encoded attribute value with a non-hex character in it' do let(:given) { '#aaaYaa' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, "Expected the second character of a hex pair, but got \"Y\"") + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, "Expected the second character of a hex pair, but got \"Y\"") end end context 'when given a hex pair with a non-hex character in it, inside double quotes' do let(:given) { '"Sebasti\\cX\\a1n"' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, "Expected the second character of a hex pair inside a double quoted value, but got \"X\"") + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, "Expected the second character of a hex pair inside a double quoted value, but got \"X\"") end end context 'with an open (as opposed to closed) double quote' do let(:given) { '"James' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, 'DN string ended unexpectedly') + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, 'DN string ended unexpectedly') end end context 'with an invalid escaped hex code' do let(:given) { 'J\ames' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, 'Invalid escaped hex code "\am"') + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, 'Invalid escaped hex code "\am"') end end context 'with a value ending with the escape character' do let(:given) { 'foo\\' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, 'DN string ended unexpectedly') + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, 'DN string ended unexpectedly') end end end @@ -119,8 +119,8 @@ describe Gitlab::LDAP::DN do context 'without extraneous whitespace' do let(:given) { 'uid=john smith+telephonenumber=+1 555-555-5555,ou=people,dc=example,dc=com' } - it 'raises UnsupportedDnFormatError' do - expect { subject }.to raise_error(Gitlab::LDAP::UnsupportedDnFormatError) + it 'raises UnsupportedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::UnsupportedError) end end @@ -128,16 +128,16 @@ describe Gitlab::LDAP::DN do context 'around the phone number plus sign' do let(:given) { 'uid = John Smith + telephoneNumber = + 1 555-555-5555 , ou = People,dc=example,dc=com' } - it 'raises UnsupportedDnFormatError' do - expect { subject }.to raise_error(Gitlab::LDAP::UnsupportedDnFormatError) + it 'raises UnsupportedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::UnsupportedError) end end context 'not around the phone number plus sign' do let(:given) { 'uid = John Smith + telephoneNumber = +1 555-555-5555 , ou = People,dc=example,dc=com' } - it 'raises UnsupportedDnFormatError' do - expect { subject }.to raise_error(Gitlab::LDAP::UnsupportedDnFormatError) + it 'raises UnsupportedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::UnsupportedError) end end end @@ -148,104 +148,104 @@ describe Gitlab::LDAP::DN do context 'when ending with a comma' do let(:given) { 'uid=John Smith,' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, 'DN string ended unexpectedly') + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, 'DN string ended unexpectedly') end end context 'when given a BER encoded attribute value with a space in it' do let(:given) { '0.9.2342.19200300.100.1.25=#aa aa' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, "Expected the end of an attribute value, but got \"a\"") + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, "Expected the end of an attribute value, but got \"a\"") end end context 'when given a BER encoded attribute value with a non-hex character in it' do let(:given) { '0.9.2342.19200300.100.1.25=#aaXaaa' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, "Expected the first character of a hex pair, but got \"X\"") + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, "Expected the first character of a hex pair, but got \"X\"") end end context 'when given a BER encoded attribute value with a non-hex character in it' do let(:given) { '0.9.2342.19200300.100.1.25=#aaaYaa' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, "Expected the second character of a hex pair, but got \"Y\"") + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, "Expected the second character of a hex pair, but got \"Y\"") end end context 'when given a hex pair with a non-hex character in it, inside double quotes' do let(:given) { 'uid="Sebasti\\cX\\a1n"' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, "Expected the second character of a hex pair inside a double quoted value, but got \"X\"") + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, "Expected the second character of a hex pair inside a double quoted value, but got \"X\"") end end context 'without a name value pair' do let(:given) { 'John' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, 'DN string ended unexpectedly') + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, 'DN string ended unexpectedly') end end context 'with an open (as opposed to closed) double quote' do let(:given) { 'cn="James' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, 'DN string ended unexpectedly') + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, 'DN string ended unexpectedly') end end context 'with an invalid escaped hex code' do let(:given) { 'cn=J\ames' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, 'Invalid escaped hex code "\am"') + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, 'Invalid escaped hex code "\am"') end end context 'with a value ending with the escape character' do let(:given) { 'cn=\\' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, 'DN string ended unexpectedly') + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, 'DN string ended unexpectedly') end end context 'with an invalid OID attribute type name' do let(:given) { '1.2.d=Value' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, 'Unrecognized RDN OID attribute type name character "d"') + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, 'Unrecognized RDN OID attribute type name character "d"') end end context 'with a period in a non-OID attribute type name' do let(:given) { 'd1.2=Value' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, 'Unrecognized RDN attribute type name character "."') + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, 'Unrecognized RDN attribute type name character "."') end end context 'when starting with non-space, non-alphanumeric character' do let(:given) { ' -uid=John Smith' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, 'Unrecognized first character of an RDN attribute type name "-"') + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, 'Unrecognized first character of an RDN attribute type name "-"') end end context 'when given a UID with an escaped equal sign' do let(:given) { 'uid\\=john' } - it 'raises MalformedDnError' do - expect { subject }.to raise_error(Gitlab::LDAP::MalformedDnError, 'Unrecognized RDN attribute type name character "\\"') + it 'raises MalformedError' do + expect { subject }.to raise_error(Gitlab::LDAP::DN::MalformedError, 'Unrecognized RDN attribute type name character "\\"') end end end |