Project

General

Profile

Bug #2550

Puppetclass search_by_host doesn't return all classes for an unknown host

Added by Daniel Lobato Garcia almost 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Category:
Search
Target version:
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

Puppetclass.search_for shows up in puppetclasses_controller and its respective method of the API. It uses scoped_search to look for all puppetclasses that a host contains. Unfortunately, in the event of a lookup of a host that either belongs to no hostgroup or a host that doesn't exist, this will return all puppetclasses.

This fix checks for this conditions and avoids returning all puppetclasses.

curl -v -k -H d"Content-Type:application/json" https://foreman/api/hosts/nonexistenthost/puppetclasses returns
Puppetclass.all without this fix,
after this fix it returns {} (no puppet classes, which is correct)

Associated revisions

Revision 7507fbce (diff)
Added by Daniel Lobato Garcia almost 6 years ago

fixes #2550 Puppetclass search_by_host doesn't return all classes for an unknown host

Tests for puppetclass API searches on nonexistent hosts

Puppetclass search_by_host does not fail if Host does not belong to any Hostgroup

Puppetclass search_by_host query looks for distinct puppetclasses instead of pruning them afterwards

Puppetclass pluck uses DISTINCT instead of .uniq on the result

Revision ce897ade (diff)
Added by Daniel Lobato Garcia almost 6 years ago

fixes #2550 Puppetclass search_by_host doesn't return all classes for an unknown host

Tests for puppetclass API searches on nonexistent hosts

Puppetclass search_by_host does not fail if Host does not belong to any Hostgroup

Puppetclass search_by_host query looks for distinct puppetclasses instead of pruning them afterwards

Puppetclass pluck uses DISTINCT instead of .uniq on the result
(cherry picked from commit 7507fbcede129c219ca1d85e757d2bdd17d5ffb9)

History

#1 Updated by Ohad Levy almost 6 years ago

  • Category set to Search
  • Target version set to 1.2.0

#2 Updated by Daniel Lobato Garcia almost 6 years ago

  • Status changed from New to Closed

Also available in: Atom PDF