context'when given a BER encoded attribute value with a space in it'do
context'when given a BER encoded attribute value with a space in it'do
let(:given){'#aa aa'}
let(:given){'#aa aa'}
it'raises MalformedDnError'do
it'raises MalformedError'do
expect{subject}.toraise_error(Gitlab::LDAP::MalformedDnError,"Expected the end of an attribute value, but got \"a\"")
expect{subject}.toraise_error(Gitlab::LDAP::DN::MalformedError,"Expected the end of an attribute value, but got \"a\"")
end
end
end
end
context'when given a BER encoded attribute value with a non-hex character in it'do
context'when given a BER encoded attribute value with a non-hex character in it'do
let(:given){'#aaXaaa'}
let(:given){'#aaXaaa'}
it'raises MalformedDnError'do
it'raises MalformedError'do
expect{subject}.toraise_error(Gitlab::LDAP::MalformedDnError,"Expected the first character of a hex pair, but got \"X\"")
expect{subject}.toraise_error(Gitlab::LDAP::DN::MalformedError,"Expected the first character of a hex pair, but got \"X\"")
end
end
end
end
context'when given a BER encoded attribute value with a non-hex character in it'do
context'when given a BER encoded attribute value with a non-hex character in it'do
let(:given){'#aaaYaa'}
let(:given){'#aaaYaa'}
it'raises MalformedDnError'do
it'raises MalformedError'do
expect{subject}.toraise_error(Gitlab::LDAP::MalformedDnError,"Expected the second character of a hex pair, but got \"Y\"")
expect{subject}.toraise_error(Gitlab::LDAP::DN::MalformedError,"Expected the second character of a hex pair, but got \"Y\"")
end
end
end
end
context'when given a hex pair with a non-hex character in it, inside double quotes'do
context'when given a hex pair with a non-hex character in it, inside double quotes'do
let(:given){'"Sebasti\\cX\\a1n"'}
let(:given){'"Sebasti\\cX\\a1n"'}
it'raises MalformedDnError'do
it'raises MalformedError'do
expect{subject}.toraise_error(Gitlab::LDAP::MalformedDnError,"Expected the second character of a hex pair inside a double quoted value, but got \"X\"")
expect{subject}.toraise_error(Gitlab::LDAP::DN::MalformedError,"Expected the second character of a hex pair inside a double quoted value, but got \"X\"")
end
end
end
end
context'with an open (as opposed to closed) double quote'do
context'with an open (as opposed to closed) double quote'do
context'when given a BER encoded attribute value with a space in it'do
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'}
let(:given){'0.9.2342.19200300.100.1.25=#aa aa'}
it'raises MalformedDnError'do
it'raises MalformedError'do
expect{subject}.toraise_error(Gitlab::LDAP::MalformedDnError,"Expected the end of an attribute value, but got \"a\"")
expect{subject}.toraise_error(Gitlab::LDAP::DN::MalformedError,"Expected the end of an attribute value, but got \"a\"")
end
end
end
end
context'when given a BER encoded attribute value with a non-hex character in it'do
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'}
let(:given){'0.9.2342.19200300.100.1.25=#aaXaaa'}
it'raises MalformedDnError'do
it'raises MalformedError'do
expect{subject}.toraise_error(Gitlab::LDAP::MalformedDnError,"Expected the first character of a hex pair, but got \"X\"")
expect{subject}.toraise_error(Gitlab::LDAP::DN::MalformedError,"Expected the first character of a hex pair, but got \"X\"")
end
end
end
end
context'when given a BER encoded attribute value with a non-hex character in it'do
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'}
let(:given){'0.9.2342.19200300.100.1.25=#aaaYaa'}
it'raises MalformedDnError'do
it'raises MalformedError'do
expect{subject}.toraise_error(Gitlab::LDAP::MalformedDnError,"Expected the second character of a hex pair, but got \"Y\"")
expect{subject}.toraise_error(Gitlab::LDAP::DN::MalformedError,"Expected the second character of a hex pair, but got \"Y\"")
end
end
end
end
context'when given a hex pair with a non-hex character in it, inside double quotes'do
context'when given a hex pair with a non-hex character in it, inside double quotes'do
let(:given){'uid="Sebasti\\cX\\a1n"'}
let(:given){'uid="Sebasti\\cX\\a1n"'}
it'raises MalformedDnError'do
it'raises MalformedError'do
expect{subject}.toraise_error(Gitlab::LDAP::MalformedDnError,"Expected the second character of a hex pair inside a double quoted value, but got \"X\"")
expect{subject}.toraise_error(Gitlab::LDAP::DN::MalformedError,"Expected the second character of a hex pair inside a double quoted value, but got \"X\"")