Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obscure ec2 creds #44

Merged
merged 6 commits into from
Nov 29, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/common_functions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@

CLOUDY_CREDS = ["ec2_access_key", "ec2_secret_key",
"aws_access_key_id", "aws_secret_access_key",
"SIMPLEDB_ACCESS_KEY", "SIMPLEDB_SECRET_KEY"]
"SIMPLEDB_ACCESS_KEY", "SIMPLEDB_SECRET_KEY",
"CLOUD1_EC2_ACCESS_KEY", "CLOUD1_EC2_SECRET_KEY"]


VER_NUM = "1.6.4"
Expand Down
24 changes: 24 additions & 0 deletions test/tc_common_functions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,28 @@ def test_get_java_app_has_threadsafe
CommonFunctions.ensure_app_has_threadsafe(dir, web_xml_false_threadsafe)
}
end

def test_obscure_creds
creds = {
'ec2_access_key' => 'ABCDEFG',
'ec2_secret_key' => 'HIJKLMN',
'CLOUD1_EC2_ACCESS_KEY' => 'OPQRSTU',
'CLOUD1_EC2_SECRET_KEY' => 'VWXYZAB'
}

expected = {
'ec2_access_key' => '***DEFG',
'ec2_secret_key' => '***KLMN',
'CLOUD1_EC2_ACCESS_KEY' => '***RSTU',
'CLOUD1_EC2_SECRET_KEY' => '***YZAB'
}

actual = CommonFunctions.obscure_creds(creds)
assert_equal(expected['ec2_access_key'], actual['ec2_access_key'])
assert_equal(expected['ec2_secret_key'], actual['ec2_secret_key'])
assert_equal(expected['CLOUD1_EC2_ACCESS_KEY'],
actual['CLOUD1_EC2_ACCESS_KEY'])
assert_equal(expected['CLOUD1_EC2_SECRET_KEY'],
actual['CLOUD1_EC2_SECRET_KEY'])
end
end
27 changes: 16 additions & 11 deletions test/tc_parse_args.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ def test_table_flags
}

# Specifying a table that is accepted should return that in the result
args_2 = ['--table', 'voldemort']
args_2 = ['--table', 'cassandra']
all_flags_2 = ['table']
expected_2 = Hash[*args_2]
actual_2 = ParseArgs.get_vals_from_args(args_2, all_flags_2, @usage)
assert_equal('voldemort', actual_2['table'])
assert_equal('cassandra', actual_2['table'])

# Failing to specify a table should default to a predefined table
args_3 = []
Expand Down Expand Up @@ -136,15 +136,20 @@ def test_table_flags
assert_equal(2, actual_9['replication'])

# Specifying a positive integer for r or w with Voldemort should be ok
args_10 = ['--table', 'voldemort', '-r', '3']
all_flags_10 = ['table', 'r', 'w']
actual_10 = ParseArgs.get_vals_from_args(args_10, all_flags_10, @usage)
assert_equal(3, actual_10['voldemort_r'])

args_11 = ['--table', 'voldemort', '-w', '3']
all_flags_11 = ['table', 'r', 'w']
actual_11 = ParseArgs.get_vals_from_args(args_11, all_flags_11, @usage)
assert_equal(3, actual_11['voldemort_w'])
# These tests are disabled right now since Voldemort is no longer a
# supported datastore.
# TODO(cgb): Remove these if we decide we're not going to support
# Voldemort in the future, or remove this TODO if we do support
# Voldemort again.
#args_10 = ['--table', 'voldemort', '-r', '3']
#all_flags_10 = ['table', 'r', 'w']
#actual_10 = ParseArgs.get_vals_from_args(args_10, all_flags_10, @usage)
#assert_equal(3, actual_10['voldemort_r'])

#args_11 = ['--table', 'voldemort', '-w', '3']
#all_flags_11 = ['table', 'r', 'w']
#actual_11 = ParseArgs.get_vals_from_args(args_11, all_flags_11, @usage)
#assert_equal(3, actual_11['voldemort_w'])
end

def test_developer_flags
Expand Down