CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/spec/lib/rex/proto/crypto_asn1_spec.rb
Views: 11784
1
# -*- coding:binary -*-
2
require 'spec_helper'
3
4
RSpec.describe Rex::Proto::CryptoAsn1::NtdsCaSecurityExt do
5
let(:encoded) do
6
"\x30\x40\xa0\x3e\x06\x0a\x2b\x06\x01\x04\x01\x82\x37\x19\x02\x01\xa0\x30" +
7
"\x04\x2e\x53\x2d\x31\x2d\x35\x2d\x32\x31\x2d\x33\x34\x30\x32\x35\x38" +
8
"\x37\x32\x38\x39\x2d\x31\x34\x38\x38\x37\x39\x38\x35\x33\x32\x2d\x33" +
9
"\x36\x31\x38\x32\x39\x36\x39\x39\x33\x2d\x31\x31\x30\x35"
10
end
11
12
describe '.parse' do
13
let(:decoded) { described_class.parse(encoded) }
14
15
it 'decodes OtherName correctly' do
16
expect(decoded[:OtherName]).to be_a RASN1::Model
17
end
18
19
it 'decodes type_id correctly' do
20
type_id = decoded[:OtherName][:type_id]
21
expect(type_id).to be_a RASN1::Types::ObjectId
22
expect(type_id.value).to eq '1.3.6.1.4.1.311.25.2.1'
23
end
24
25
it 'decodes value correctly' do
26
value = decoded[:OtherName][:value]
27
expect(value).to be_a RASN1::Types::OctetString
28
expect(value.value).to eq 'S-1-5-21-3402587289-1488798532-3618296993-1105'
29
end
30
end
31
32
describe '#to_der' do
33
it 'encodes correctly' do
34
instance = described_class.new(OtherName: {
35
type_id: '1.3.6.1.4.1.311.25.2.1',
36
value: 'S-1-5-21-3402587289-1488798532-3618296993-1105'
37
})
38
expect(instance.to_der).to eq encoded
39
end
40
end
41
end
42
43