Skip to content

Commit

Permalink
Triageing issue #640
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandro-fazzi committed Feb 12, 2022
1 parent f273f94 commit 1339e8a
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
- name: Install dependencies
run : bundle install
- name: Run tests
run: bundle exec rake
run: bundle exec rspec /Users/fuzzy/dev/wordmove/spec/actions/run_remote_command_spec.rb:95
41 changes: 40 additions & 1 deletion spec/actions/run_remote_command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
let(:bad_command) { 'exit 1' }

before do
silence_logger!
allow(context[:photocopier])
.to receive(:exec!).with(good_command)
.and_return([nil, nil, 0])
Expand All @@ -18,6 +17,8 @@
end

it 'works like it should' do
silence_logger!

result = described_class.execute(
photocopier: context.fetch(:photocopier),
cli_options: context.fetch(:cli_options),
Expand All @@ -30,6 +31,8 @@

context 'when it fails' do
it 'sets the expected error message into result' do
silence_logger!

result = described_class.execute(
photocopier: context.fetch(:photocopier),
cli_options: context.fetch(:cli_options),
Expand All @@ -44,6 +47,8 @@

context 'when `--simulate`' do
it 'does not execute the command and result is successful' do
silence_logger!

context[:cli_options][:simulate] = true

result = described_class.execute(
Expand All @@ -56,4 +61,38 @@
expect(result).to be_success
end
end

context 'testing @castilma\'s big report' do
let(:command) do
'mysqldump --host=remote_database_host --user=user ' \
'--password=R4ndom#+Str1nG ' \
'--result-file="/var/www/your_site/wp-content/dump.sql" database_name'
end

let(:context) do
OrganizerContextFactory.make_for(
described_class,
:push,
cli_options: {
config: movefile_path_for('with_secrets_castilma'),
environment: :remote
}
)
end

it 'censors the password on STDOUT' do
allow(context[:photocopier])
.to receive(:exec!).with(command)
.and_return([nil, nil, 0])

expect do
described_class.execute(
photocopier: context.fetch(:photocopier),
cli_options: context.fetch(:cli_options),
logger: context.fetch(:logger),
command: command
)
end.to output(/--password=\[secret\]/).to_stdout_from_any_process
end
end
end
23 changes: 23 additions & 0 deletions spec/fixtures/movefiles/with_secrets_castilma
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
global:
sql_adapter: "wpcli"
local:
wordpress_path: "~/dev/sites/your_site"
remote:
vhost: "http://secrets.example.com"
wordpress_path: "/var/www/your_site"
database:
name: "database_name"
user: "user"
password: "R4ndom#+Str1nG"
host: "remote_database_host"
ssh:
user: "user"
password: "ssh_password"
host: "ssh_host"
port: 30000
ftp:
user: "user"
password: "ftp_password"
host: "ftp_host"
foo:
vhost: "https://foo.bar"

0 comments on commit 1339e8a

Please sign in to comment.