Sort cases and add specs
This commit is contained in:
parent
0440e19cc1
commit
cd5699dc39
|
@ -381,13 +381,16 @@ class Registry
|
|||
# type (like REG_SZ).
|
||||
#
|
||||
def self.type2str(type)
|
||||
return REG_SZ if (type == 'REG_SZ')
|
||||
return REG_MULTI_SZ if (type == 'REG_MULTI_SZ')
|
||||
return REG_DWORD if (type == 'REG_DWORD')
|
||||
return REG_BINARY if (type == 'REG_BINARY')
|
||||
return REG_EXPAND_SZ if (type == 'REG_EXPAND_SZ')
|
||||
return REG_NONE if (type == 'REG_NONE')
|
||||
return nil
|
||||
case type
|
||||
when 'REG_BINARY' then REG_BINARY
|
||||
when 'REG_DWORD' then REG_DWORD
|
||||
when 'REG_EXPAND_SZ' then REG_EXPAND_SZ
|
||||
when 'REG_MULTI_SZ' then REG_MULTI_SZ
|
||||
when 'REG_NONE' then REG_NONE
|
||||
when 'REG_SZ' then REG_SZ
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
require 'rex/post/meterpreter/extensions/stdapi/sys/registry'
|
||||
|
||||
RSpec.describe Rex::Post::Meterpreter::Extensions::Stdapi::Sys::Registry do
|
||||
|
||||
describe '.type2str' do
|
||||
subject { described_class.type2str(type) }
|
||||
|
||||
context "with 'REG_BINARY'" do
|
||||
let(:type) { 'REG_BINARY' }
|
||||
it { should eq(3) }
|
||||
end
|
||||
context "with 'REG_DWORD'" do
|
||||
let(:type) { 'REG_DWORD' }
|
||||
it { should eq(4) }
|
||||
end
|
||||
context "with 'REG_EXPAND_SZ'" do
|
||||
let(:type) { 'REG_EXPAND_SZ' }
|
||||
it { should eq(2) }
|
||||
end
|
||||
context "with 'REG_MULTI_SZ'" do
|
||||
let(:type) { 'REG_MULTI_SZ' }
|
||||
it { should eq(7) }
|
||||
end
|
||||
context "with 'REG_NONE'" do
|
||||
let(:type) { 'REG_NONE' }
|
||||
it { should eq(0) }
|
||||
end
|
||||
context "with 'REG_SZ'" do
|
||||
let(:type) { 'REG_SZ' }
|
||||
it { should eq(1) }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue