CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/spec/lib/rex/proto/dns/upstream_resolver_spec.rb
Views: 1904
1
# -*- coding:binary -*-
2
require 'spec_helper'
3
4
5
RSpec.describe Rex::Proto::DNS::UpstreamResolver do
6
context 'when type is black-hole' do
7
let(:type) { Rex::Proto::DNS::UpstreamResolver::Type::BLACK_HOLE }
8
let(:resolver) { described_class.create_black_hole }
9
10
describe '.new_black_hole' do
11
it 'is expected to set the type correctly' do
12
expect(resolver.type).to eq type
13
end
14
15
it 'is expected to set the destination correctly' do
16
expect(resolver.destination).to be_nil
17
end
18
end
19
20
describe '#to_s' do
21
it 'is expected to return the type as a string' do
22
expect(resolver.to_s).to eq type.to_s
23
end
24
end
25
end
26
27
context 'when type is dns-server' do
28
let(:type) { Rex::Proto::DNS::UpstreamResolver::Type::DNS_SERVER }
29
let(:destination) { '192.0.2.10' }
30
let(:resolver) { described_class.create_dns_server(destination) }
31
32
describe '.new_dns_server' do
33
it 'is expected to set the type correctly' do
34
expect(resolver.type).to eq type
35
end
36
37
it 'is expected to set the destination correctly' do
38
expect(resolver.destination).to eq destination
39
end
40
end
41
42
describe '#to_s' do
43
it 'is expected to return the nameserver IP address as a string' do
44
expect(resolver.to_s).to eq destination
45
end
46
end
47
end
48
49
context 'when type is static' do
50
let(:type) { Rex::Proto::DNS::UpstreamResolver::Type::STATIC }
51
let(:resolver) { described_class.create_static }
52
53
describe '.new_static' do
54
it 'is expected to set the type correctly' do
55
expect(resolver.type).to eq type
56
end
57
58
it 'is expected to set the destination correctly' do
59
expect(resolver.destination).to be_nil
60
end
61
end
62
63
describe '#to_s' do
64
it 'is expected to return the type as a string' do
65
expect(resolver.to_s).to eq type.to_s
66
end
67
end
68
end
69
70
context 'when type is system' do
71
let(:type) { Rex::Proto::DNS::UpstreamResolver::Type::SYSTEM }
72
let(:resolver) { described_class.create_system }
73
74
describe '.new_system' do
75
it 'is expected to set the type correctly' do
76
expect(resolver.type).to eq type
77
end
78
79
it 'is expected to set the destination correctly' do
80
expect(resolver.destination).to be_nil
81
end
82
end
83
84
describe '#to_s' do
85
it 'is expected to return the type as a string' do
86
expect(resolver.to_s).to eq type.to_s
87
end
88
end
89
end
90
end
91
92