spec/dap/proto/ldap_proto_spec.rb in dap-0.0.10 vs spec/dap/proto/ldap_proto_spec.rb in dap-0.0.11
- old
+ new
@@ -55,10 +55,12 @@
'737331160403746f70040f4f70656e4c444150726f6f7444'\
'5345300c02010765070a010004000400']
data = original.pack('H*')
+ excessive_len = ['308480010000000000000000'].pack('H*')
+
entry = ['3030020107642b040030273025040b6f626a656374436c6173'\
'7331160403746f70040f4f70656e4c444150726f6f74445345']
done = ['300c02010765070a010004000400']
@@ -88,10 +90,35 @@
let(:split_messages) { subject.split_messages('00') }
it 'returns Array as expected' do
expect(split_messages.class).to eq(::Array)
end
end
+
+ context 'testing message length greater than total data length' do
+ let(:split_messages) { subject.split_messages(excessive_len) }
+ it 'returns Array as expected' do
+ expect(split_messages.class).to eq(::Array)
+ end
+
+ it 'returns empty Array as expected' do
+ expect(split_messages).to eq([])
+ end
+ end
+
+ context 'testing empty ASN.1 Sequence' do
+ hex = ['308400000000']
+ empty_seq = hex.pack('H*')
+
+ let(:split_messages) { subject.split_messages(empty_seq) }
+ it 'returns Array as expected' do
+ expect(split_messages.class).to eq(::Array)
+ end
+
+ it 'returns empty Array as expected' do
+ expect(split_messages).to eq([])
+ end
+ end
end
describe '.parse_ldapresult' do
context 'testing valid data' do
@@ -203,9 +230,27 @@
expect(parse_message.class).to eq(::Array)
end
it 'returns UnhandledTag value as expected' do
test_val = ['UnhandledTag', { 'tagNumber' => 7 }]
+ expect(parse_message).to eq(test_val)
+ end
+ end
+
+ context 'testing empty ASN.1 Sequence' do
+
+ data = OpenSSL::ASN1::Sequence.new([])
+
+ let(:parse_message) { subject.parse_message(data) }
+ it 'returns Array as expected' do
+ expect(parse_message.class).to eq(::Array)
+ end
+
+ it 'returns error value as expected' do
+ test_val = ['Error', {
+ 'errorMessage' =>
+ 'parse_message: Invalid LDAP response (Empty Sequence)'
+ }]
expect(parse_message).to eq(test_val)
end
end
end