Skip to content

Commit

Permalink
Bare minimal encrypt-file spec
Browse files Browse the repository at this point in the history
FakeAPI is stubbed to satisfy a very small number of calls that
`encrypt-file` command requires.
  • Loading branch information
BanzaiMan committed Mar 4, 2020
1 parent 5ad7aed commit bb3eddd
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/cli/encrypt_file_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'spec_helper'
require 'fileutils'
require 'digest'

describe Travis::CLI::EncryptFile do
CMD_TARGET = 'README.md'

before :each do
Digest.stub(:hexencode).and_return "randomhex" # to avoid relying on Dir.pwd value for hex
end

after :each do
FileUtils.rm_f "#{CMD_TARGET}.enc"
end

example "travis encrypt-file #{CMD_TARGET}" do
run_cli('encrypt-file', CMD_TARGET).should be_success
File.exists?("#{CMD_TARGET}.enc").should be true
end
end
50 changes: 50 additions & 0 deletions spec/support/fake_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,56 @@ def authorized?
}]}.to_json
end

#### for encrypt_file spec
get '/settings/env_vars/' do
# p params
$params = params
{
"env_vars":[
{
"id": "8aa1c74d-dcc4-4e41-9087-1326b7c68abd",
"name": "encrypted_randomhex_key",
"value": "super_secret_key",
"public": false,
"repository_id": 891
},
{
"id": "b2ed30b9-622d-4bd7-928b-ba5aad7ba6a1",
"name": "encrypted_randomhex_iv",
"value": "super_secret_iv",
"public": false,
"repository_id": 891
}
]
}.to_json
end

patch '/settings/env_vars/8aa1c74d-dcc4-4e41-9087-1326b7c68abd' do
$params = params
{
"env_var": {
"id": "8aa1c74d-dcc4-4e41-9087-1326b7c68abd",
"name": "encrypted_randomhex_key",
"value": "new_super_secret_key",
"public": false,
"repository_id": 891
}
}.to_json
end

patch '/settings/env_vars/b2ed30b9-622d-4bd7-928b-ba5aad7ba6a1' do
$params = params
{
"env_var": {
"id": "b2ed30b9-622d-4bd7-928b-ba5aad7ba6a1",
"name": "encrypted_randomhex_iv",
"value": "new_super_secret_iv",
"public": false,
"repository_id": 891
}
}.to_json
end

post '/requests' do
$params = params
"{}"
Expand Down

0 comments on commit bb3eddd

Please sign in to comment.