Skip to content

Commit

Permalink
fixes #5178 - unify API parameters and return values. User creation s…
Browse files Browse the repository at this point in the history
…hould not require payload wrapped with 'user' root
  • Loading branch information
Joseph Magen authored and lzap committed Jul 15, 2014
1 parent f444e81 commit c980e9a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/controllers/api/v2/compute_resources_controller.rb
Expand Up @@ -2,6 +2,11 @@ module Api
module V2
class ComputeResourcesController < V2::BaseController

wrap_parameters ComputeResource, :include => (ComputeResource.attribute_names + ['tenant', 'image_id', 'managed_ip', 'provider',
'template', 'templates', 'set_console_password', 'project', 'key_path', 'email', 'zone',
'display_type', 'ovirt_quota', 'public_key', 'region', 'server', 'datacenter', 'pubkey_hash',
'nics_attributes', 'volumes_attributes', 'memory'])

include Api::Version2
include Api::TaxonomyScope

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/api/v2/hosts_controller.rb
Expand Up @@ -2,6 +2,8 @@ module Api
module V2
class HostsController < V2::BaseController

wrap_parameters Host::Base, :include => (Host::Base.attribute_names + ['image_file', 'is_owned_by', 'overwrite', 'progress_report_id'])

include Api::Version2
#TODO - should TaxonomyScope be here. It wasn't here previously
include Api::TaxonomyScope
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/api/v2/users_controller.rb
@@ -1,6 +1,9 @@
module Api
module V2
class UsersController < V2::BaseController

wrap_parameters User, :include => (User.attribute_names + ['password'])

before_filter :find_resource, :only => %w{show update destroy}
include Foreman::Controller::UsersMixin
include Api::Version2
Expand Down
5 changes: 4 additions & 1 deletion test/functional/api/v2/users_controller_test.rb
Expand Up @@ -2,7 +2,10 @@

class Api::V2::UsersControllerTest < ActionController::TestCase

valid_attrs = { :login => "johnsmith" }
valid_attrs = { :login => "johnsmith",
:mail => 'john@example.com',
:auth_source_id => AuthSourceInternal.first.id,
:password => '123456' }

def setup
setup_users
Expand Down

0 comments on commit c980e9a

Please sign in to comment.