Added Test button in Provider Properties tab.
---
.../admin/provider_accounts_controller.rb | 19 ++------
src/app/controllers/admin/providers_controller.rb | 43 +++++++++++---------
src/app/views/admin/provider_accounts/_ec2.haml | 4 --
src/app/views/admin/provider_accounts/_gogrid.haml | 4 --
src/app/views/admin/provider_accounts/_mock.haml | 6 +--
.../views/admin/provider_accounts/_opennebula.haml | 4 --
.../views/admin/provider_accounts/_rackspace.haml | 4 --
src/app/views/admin/providers/_form.haml | 4 --
src/app/views/admin/providers/_properties.haml | 1 +
src/features/provider.feature | 20 +++------
src/features/provider_account.feature | 23 ++++-------
.../provider_accounts_controller_spec.rb | 8 ----
12 files changed, 46 insertions(+), 94 deletions(-)
diff --git a/src/app/controllers/admin/provider_accounts_controller.rb
b/src/app/controllers/admin/provider_accounts_controller.rb
index ceffe17..276bbf9 100644
--- a/src/app/controllers/admin/provider_accounts_controller.rb
+++ b/src/app/controllers/admin/provider_accounts_controller.rb
@@ -57,18 +57,14 @@ class Admin::ProviderAccountsController < ApplicationController
@provider_account.provider = @provider
@provider_account.quota = @quota = Quota.new
- if params.delete :test_account
- test_account(@provider_account)
- render :action => 'new' and return
- end
-
limit = params[:quota][:maximum_running_instances] if params[:quota]
@provider_account.quota.set_maximum_running_instances(limit)
- if @provider_account.invalid?
- if not @provider_account.valid_credentials?
- flash.now[:error] = "The entered credential information is incorrect"
- elsif @provider_account.errors.on(:username)
+ if not @provider_account.valid_credentials?
+ flash.now[:error] = "The entered credential information is incorrect"
+ render :action => 'new' and return
+ elsif @provider_account.invalid?
+ if @provider_account.errors.on(:username)
flash.now[:error] = "The access key
'#{params[:provider_account][:username]}' has already been taken."
else
flash.now[:error] = "You must fill in all the required fields"
@@ -102,11 +98,6 @@ class Admin::ProviderAccountsController < ApplicationController
@quota = @provider_account.quota
@providers = Provider.find(:all)
- if params.delete :test_account
- test_account(@provider_account)
- render :action => 'edit' and return
- end
-
limit = params[:quota][:maximum_running_instances] if params[:quota]
@provider_account.quota.set_maximum_running_instances(limit)
if @provider_account.update_attributes(params[:provider_account])
diff --git a/src/app/controllers/admin/providers_controller.rb
b/src/app/controllers/admin/providers_controller.rb
index 435e8a9..dc4cb5b 100644
--- a/src/app/controllers/admin/providers_controller.rb
+++ b/src/app/controllers/admin/providers_controller.rb
@@ -37,6 +37,11 @@ class Admin::ProvidersController < ApplicationController
require_privilege(Privilege::VIEW, @provider)
@tab_captions = ['Properties', 'HW Profiles', 'Realms',
'Provider Accounts', 'Services','History','Permissions']
@details_tab = params[:details_tab].blank? ? 'properties' :
params[:details_tab]
+
+ if params.delete :test_provider
+ test_connection(@provider)
+ end
+
respond_to do |format|
format.js do
if @url_params.delete :details_pane
@@ -51,9 +56,9 @@ class Admin::ProvidersController < ApplicationController
def create
require_privilege(Privilege::CREATE, Provider)
@provider = Provider.new(params[:provider])
- if params[:test_connection]
- test_connection(@provider)
- render :action => 'new'
+ if !(a)provider.connect
+ flash[:notice] = "Failed to connect to Provider"
+ render :action => "new"
else
if @provider.save && @provider.populate_hardware_profiles
@provider.assign_owner_roles(current_user)
@@ -68,22 +73,22 @@ class Admin::ProvidersController < ApplicationController
end
def update
- @provider = Provider.find_by_id(params[:id])
- require_privilege(Privilege::MODIFY, @provider)
- @provider.update_attributes(params[:provider])
- if params[:test_connection]
- test_connection(@provider)
- render :action => 'edit'
- else
- if @provider.errors.empty? and @provider.save
- flash[:notice] = "Provider updated."
- redirect_to admin_providers_path
- else
- flash[:notice] = "Cannot update the provider."
- render :action => 'edit'
- end
- kick_condor
- end
+ @provider = Provider.find_by_id(params[:id])
+ require_privilege(Privilege::MODIFY, @provider)
+ @provider.update_attributes(params[:provider])
+ if !(a)provider.connect
+ flash[:notice] = "Failed to connect to Provider"
+ render :action => "edit"
+ else
+ if @provider.errors.empty? and @provider.save
+ flash[:notice] = "Provider updated."
+ redirect_to admin_providers_path
+ else
+ flash[:notice] = "Cannot update the provider."
+ render :action => 'edit'
+ end
+ end
+ kick_condor
end
def multi_destroy
diff --git a/src/app/views/admin/provider_accounts/_ec2.haml
b/src/app/views/admin/provider_accounts/_ec2.haml
index 43c4078..a5beafd 100644
--- a/src/app/views/admin/provider_accounts/_ec2.haml
+++ b/src/app/views/admin/provider_accounts/_ec2.haml
@@ -28,10 +28,6 @@
%span.required *
= file_field :provider_account, :x509_cert_pub_file, :title =>
t('provider_accounts.form.account_public_cert')
.grid_3.omega
- (
- %button.linkbutton.nospace{ :type => 'submit', :value =>
t('provider_accounts.form.test_account'), :name => 'test_account', :id
=> 'test_account' }<>
- = t('provider_accounts.form.test_account')
- )
:javascript
function set_unlimited_quota(elem_id) {
diff --git a/src/app/views/admin/provider_accounts/_gogrid.haml
b/src/app/views/admin/provider_accounts/_gogrid.haml
index 421768e..225f972 100644
--- a/src/app/views/admin/provider_accounts/_gogrid.haml
+++ b/src/app/views/admin/provider_accounts/_gogrid.haml
@@ -10,7 +10,3 @@
= label_tag "Quota"
= text_field :quota, :maximum_running_instances, :title =>
t('provider_accounts.form.quota_instances'), :value =>
@quota.maximum_running_instances || "unlimited", :id =>
"quota_instances", :class => "grid_3 omega"
.grid_3.omega
- (
- %button.linkbutton.nospace{ :type => 'submit', :value =>
t('provider_accounts.form.test_account'), :name => 'test_account', :id
=> 'test_account' }<>
- = t('provider_accounts.form.test_account')
- )
diff --git a/src/app/views/admin/provider_accounts/_mock.haml
b/src/app/views/admin/provider_accounts/_mock.haml
index 421768e..30fcd38 100644
--- a/src/app/views/admin/provider_accounts/_mock.haml
+++ b/src/app/views/admin/provider_accounts/_mock.haml
@@ -9,8 +9,4 @@
= password_field :provider_account,:password
= label_tag "Quota"
= text_field :quota, :maximum_running_instances, :title =>
t('provider_accounts.form.quota_instances'), :value =>
@quota.maximum_running_instances || "unlimited", :id =>
"quota_instances", :class => "grid_3 omega"
-.grid_3.omega
- (
- %button.linkbutton.nospace{ :type => 'submit', :value =>
t('provider_accounts.form.test_account'), :name => 'test_account', :id
=> 'test_account' }<>
- = t('provider_accounts.form.test_account')
- )
+.grid_3.omega
\ No newline at end of file
diff --git a/src/app/views/admin/provider_accounts/_opennebula.haml
b/src/app/views/admin/provider_accounts/_opennebula.haml
index abcf8a2..29d35bc 100644
--- a/src/app/views/admin/provider_accounts/_opennebula.haml
+++ b/src/app/views/admin/provider_accounts/_opennebula.haml
@@ -10,7 +10,3 @@
= label_tag "Quota"
= text_field :quota, :maximum_running_instances, :title =>
t('provider_accounts.form.quota_instances'), :value =>
@quota.maximum_running_instances || "unlimited", :id =>
"quota_instances", :class => "grid_3 omega"
.grid_3.omega
- (
- %button.linkbutton.nospace{ :type => 'submit', :value =>
t('provider_accounts.form.test_account'), :name => 'test_account', :id
=> 'test_account' }<>
- = t('provider_accounts.form.test_account')
- )
diff --git a/src/app/views/admin/provider_accounts/_rackspace.haml
b/src/app/views/admin/provider_accounts/_rackspace.haml
index bc99d32..d6dbec9 100644
--- a/src/app/views/admin/provider_accounts/_rackspace.haml
+++ b/src/app/views/admin/provider_accounts/_rackspace.haml
@@ -10,7 +10,3 @@
= label_tag "Quota"
= text_field :quota, :maximum_running_instances, :title =>
t('provider_accounts.form.quota_instances'), :value =>
@quota.maximum_running_instances || "unlimited", :id =>
"quota_instances", :class => "grid_3 omega"
.grid_3.omega
- (
- %button.linkbutton.nospace{ :type => 'submit', :value =>
t('provider_accounts.form.test_account'), :name => 'test_account', :id
=> 'test_account' }<>
- = t('provider_accounts.form.test_account')
- )
diff --git a/src/app/views/admin/providers/_form.haml
b/src/app/views/admin/providers/_form.haml
index df888dc..b400d00 100644
--- a/src/app/views/admin/providers/_form.haml
+++ b/src/app/views/admin/providers/_form.haml
@@ -7,10 +7,6 @@
%fieldset.clear
= form.label :url, 'Provider URL :'
= form.text_field :url, :title => 'provider_url', :value =>
@provider.url, :class => "grid_5"
- (
- %button.linkbutton.nospace{ :type => 'submit', :value =>
t('.test_connection'), :name => 'test_connection', :id =>
'test_connection' }
- Test connection
- )
%fieldset.clear
= form.label :provider_type
= form.select(:provider_type_id, ProviderType.all.collect {|provider_type|
[provider_type.name,provider_type.id] }, :prompt => "Select type of
provider")
diff --git a/src/app/views/admin/providers/_properties.haml
b/src/app/views/admin/providers/_properties.haml
index 163401e..044895a 100644
--- a/src/app/views/admin/providers/_properties.haml
+++ b/src/app/views/admin/providers/_properties.haml
@@ -2,3 +2,4 @@
Properties for
= @provider.name
= link_to "Edit", edit_admin_provider_path(@provider), {:class =>
'button'}
+= link_to "Test", admin_provider_path(@provider, {:test_provider => true}),
{ :class => 'button' }
diff --git a/src/features/provider.feature b/src/features/provider.feature
index 4b6c50c..34ab613 100644
--- a/src/features/provider.feature
+++ b/src/features/provider.feature
@@ -40,23 +40,17 @@ Feature: Manage Providers
And I should see "Provider added"
And I should have a provider named "testprovider"
- Scenario: Test Provider Connection Successful
+ Scenario: Create a new Provider failure when using wrong url
Given I am on the admin providers page
+ And there is not a provider named "testprovider"
When I follow "Create"
Then I should be on the new admin provider page
When I fill in "provider[name]" with "testprovider"
- And I fill in "provider[url]" with "http://localhost:3001/api"
- And I press "test_connection"
- Then I should see "Successfuly Connected to Provider"
-
- Scenario: Test Provider Connection Failure
- Given I am on the admin providers page
- When I follow "Create"
- Then I should be on the new admin provider page
- When I fill in "provider[name]" with "incorrect_provider"
- And I fill in "provider[url]" with
"http://incorrecthost:3001/api"
- And I press "test_connection"
- Then I should see "Failed to Connect to Provider"
+ And I fill in "provider[url]" with "http://localhost:3010/api"
+ And I select "Amazon EC2" from "provider_provider_type_id"
+ And I press "Save"
+ Then I should be on the admin providers page
+ And I should see "Failed to connect to Provider"
Scenario: Delete a provider
Given I am on the homepage
diff --git a/src/features/provider_account.feature
b/src/features/provider_account.feature
index e59dab9..14c3574 100644
--- a/src/features/provider_account.feature
+++ b/src/features/provider_account.feature
@@ -33,27 +33,20 @@ Feature: Manage Provider Accounts
And I should see "Properties for testaccount"
And I should see "Running instances quota: 13"
- Scenario: Test Provider Account Connection Successful
+ Scenario: Create a new Provider Account using wrong credentials
Given there is a provider named "testprovider"
And there are no provider accounts
And I am on the admin provider accounts page
When I follow "New Account"
Then I should be on the new admin provider account page
- When I fill in "provider_account[username]" with "mockuser"
- And I fill in "provider_account[password]" with "mockpassword"
- And I press "Test Account"
- Then I should see "Test Connection Success"
-
- Scenario: Test Provider Account Connection Failure
- Given there is a provider named "testprovider"
- And there are no provider accounts
- And I am on the admin provider accounts page
- When I follow "New Account"
- Then I should be on the new admin provider account page
- When I fill in "provider_account[username]" with "mockuser"
+ And I should see "New Account"
+ When I select "testprovider" from "provider_account_provider_id"
+ And I fill in "provider_account[label]" with "testaccount"
+ And I fill in "provider_account[username]" with "mockuser"
And I fill in "provider_account[password]" with "wrong password"
- And I press "Test Account"
- Then I should see "Test Connection Failed"
+ And I fill in "quota[maximum_running_instances]" with "13"
+ And I press "Add"
+ Then I should see "credential information is incorrect"
Scenario: Delete a provider account
Given there is a provider named "testprovider"
diff --git a/src/spec/controllers/provider_accounts_controller_spec.rb
b/src/spec/controllers/provider_accounts_controller_spec.rb
index 567538b..a6d6806 100644
--- a/src/spec/controllers/provider_accounts_controller_spec.rb
+++ b/src/spec/controllers/provider_accounts_controller_spec.rb
@@ -21,14 +21,6 @@ describe Admin::ProviderAccountsController do
response.should render_template("index")
end
- it "allows test account validity on create when passing test_account param"
do
- UserSession.create(@admin)
- post :create, :provider_account => {:provider_id => @provider.id},
:test_account => true
- response.should be_success
- response.should render_template("new")
- response.flash[:error].should == "Test Connection Failed: Invalid Account
Details"
- end
-
it "doesn't allow to save provider's account if not valid
credentials" do
UserSession.create(@admin)
post :create, :provider_account => {:provider_id => @provider.id}
--
1.7.4