1
+ RSpec . describe Rex ::Proto ::MsDtyp ::MsDtypAccessMask do
2
+ subject ( :instance ) { described_class . from_sddl_text ( sddl_text ) }
3
+
4
+ describe '.from_sddl_text' do
5
+ context 'when the text is FA' do
6
+ let ( :sddl_text ) { 'FA' }
7
+ subject ( :instance ) { described_class . from_sddl_text ( sddl_text ) }
8
+
9
+ it 'sets the protocol to 0x1ff' do
10
+ expect ( instance . protocol ) . to eq 0x1ff
11
+ end
12
+
13
+ it 'sets the de flag' do
14
+ expect ( instance . de ) . to eq 1
15
+ end
16
+
17
+ it 'sets the rc flag' do
18
+ expect ( instance . rc ) . to eq 1
19
+ end
20
+
21
+ it 'sets the wd flag' do
22
+ expect ( instance . wd ) . to eq 1
23
+ end
24
+
25
+ it 'sets the wo flag' do
26
+ expect ( instance . wo ) . to eq 1
27
+ end
28
+
29
+ it 'sets the sy flag' do
30
+ expect ( instance . sy ) . to eq 1
31
+ end
32
+
33
+ it 'does not set the ma flag' do
34
+ expect ( instance . ma ) . to eq 0
35
+ end
36
+
37
+ it 'does not set the as flag' do
38
+ expect ( instance . as ) . to eq 0
39
+ end
40
+ end
41
+
42
+ context 'when the text is KA' do
43
+ let ( :sddl_text ) { 'KA' }
44
+
45
+ it 'sets the protocol to 0x3f' do
46
+ expect ( instance . protocol ) . to eq 0x3f
47
+ end
48
+
49
+ it 'sets the de flag' do
50
+ expect ( instance . de ) . to eq 1
51
+ end
52
+
53
+ it 'sets the rc flag' do
54
+ expect ( instance . rc ) . to eq 1
55
+ end
56
+
57
+ it 'sets the wd flag' do
58
+ expect ( instance . wd ) . to eq 1
59
+ end
60
+
61
+ it 'sets the wo flag' do
62
+ expect ( instance . wo ) . to eq 1
63
+ end
64
+
65
+ it 'does not set the sy flag' do
66
+ expect ( instance . sy ) . to eq 0
67
+ end
68
+
69
+ it 'does not set the ma flag' do
70
+ expect ( instance . ma ) . to eq 0
71
+ end
72
+
73
+ it 'does not set the as flag' do
74
+ expect ( instance . as ) . to eq 0
75
+ end
76
+ end
77
+
78
+ context 'when the text is 0x00001234' do
79
+ let ( :sddl_text ) { '0x00001234' }
80
+
81
+ it 'sets the protocol to 0x1234' do
82
+ expect ( instance . protocol ) . to eq 0x1234
83
+ end
84
+ end
85
+ end
86
+
87
+ describe '#to_sddl_text' do
88
+ context 'when high protocol bits are set' do
89
+ subject ( :instance ) { described_class . new ( protocol : 0x1234 ) }
90
+ it 'dumps the value in hex' do
91
+ expect ( instance . to_sddl_text ) . to eq "0x00001234"
92
+ end
93
+ end
94
+ end
95
+ end
0 commit comments