Project

General

Profile

Bug #8358

No validation of domain in host

Added by Shlomi Zadok over 7 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
API
Target version:
Difficulty:
Triaged:
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

When updating a host, there is no validation whether the domain exists [if it does not exist, it is ignored - instead of throwing domain does not exist]
Steps to reproduce:

Via Hammer:

hammer -d host update --name <<server.fqdn>> --domain-id 1935

hammer -d host update --name <<server.fqdn>> --domain-id shlomizadok

both return Host updated.

Via Api:

Started PUT "/api/v2/hosts/smartproxy.local.lan" for 127.0.0.1 at 2014-11-12 09:25:35 +0200
Processing by Api::V2::HostsController#update as JSON
  Parameters: {"host"=>{"domain_id"=>"shlomi"}, "apiv"=>"v2", "id"=>"smartproxy.local.lan"}
...
Completed 200 OK in 368.9ms

Expected result:
Return an error "Could not update host"
Example:

hammer -d host update --name smartproxy.local.lan --medium-id 232134

Returns:

DETAIL:  Key (medium_id)=(232134) is not present in table "media".

Could not update the host:
  ERROR:  insert or update on table "hosts" violates foreign key constraint "hosts_medium_id_fk" 
  DETAIL:  Key (medium_id)=(232134) is not present in table "media".

Associated revisions

Revision cbe1391f (diff)
Added by Shlomi Zadok over 7 years ago

fixes #8358 - validate domain on host update

Revision 8f6c56cc (diff)
Added by Shlomi Zadok over 7 years ago

fixes #8358 - validate domain on host update

(cherry picked from commit cbe1391f48f37d4bf9a53091c668b6a91bc6ef83)

History

#1 Updated by Dominic Cleal over 7 years ago

  • Category set to API

#2 Updated by The Foreman Bot over 7 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2084 added
  • Pull request deleted ()

#3 Updated by Marek Hulán over 7 years ago

  • Legacy Backlogs Release (now unused) set to 28

I guess as a bug this goes 1.8

#4 Updated by Shlomi Zadok over 7 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF