From 4b79b6ba0464cfc28418a7a0b0f84d4b17832666 Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Tue, 20 Nov 2012 11:28:14 +0000 Subject: [PATCH] [Brightbox] Fixes Account#reset_ftp_password Tests that Account#reset_ftp_password is working (had an issue previously) and now merges the results in making the password value available on the model whilst it exists. --- lib/fog/brightbox/models/compute/account.rb | 12 +++++++++--- tests/brightbox/models/compute/account_tests.rb | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 tests/brightbox/models/compute/account_tests.rb diff --git a/lib/fog/brightbox/models/compute/account.rb b/lib/fog/brightbox/models/compute/account.rb index c37f6fec5..0850cff51 100644 --- a/lib/fog/brightbox/models/compute/account.rb +++ b/lib/fog/brightbox/models/compute/account.rb @@ -32,7 +32,7 @@ module Fog attribute :load_balancers_used attribute :library_ftp_host attribute :library_ftp_user - # This is always returned as null/nil unless performing a reset_ftp_password request + # This is always returned as nil unless after a call to reset_ftp_password attribute :library_ftp_password # Boolean flags @@ -51,13 +51,19 @@ module Fog attribute :users attribute :zones + # Resets the account's image library FTP password returning the new value + # + # @return [String] Newly issue FTP password + # def reset_ftp_password requires :identity - connection.reset_ftp_password_account["library_ftp_password"] + data = connection.reset_ftp_password_account(identity) + merge_attributes(data) + library_ftp_password end end end end -end \ No newline at end of file +end diff --git a/tests/brightbox/models/compute/account_tests.rb b/tests/brightbox/models/compute/account_tests.rb new file mode 100644 index 000000000..572d6aff3 --- /dev/null +++ b/tests/brightbox/models/compute/account_tests.rb @@ -0,0 +1,15 @@ +Shindo.tests("Fog::Compute[:brightbox] | Account model", ["brightbox"]) do + + @account = Fog::Compute[:brightbox].account + + tests("success") do + + tests("#reset_ftp_password") do + pending if Fog.mocking? + test("original ftp password is blanked") { @account.library_ftp_password.nil? } + @new_password = @account.reset_ftp_password + test("new ftp password was not nil") { !@new_password.nil? } + test("new ftp password is set") { @account.library_ftp_password == @new_password } + end + end +end