Do not return deleted packs with query (#1497)

Closes #1476
This commit is contained in:
Zachary Wasserman
2017-04-18 12:41:51 -07:00
committed by GitHub
parent 22fbb65db3
commit 49e4bad88d
5 changed files with 35 additions and 3 deletions
+4 -2
View File
@@ -1,4 +1,4 @@
* Improve online status detection.
* Improved online status detection.
The Kolide server now tracks the `distributed_interval` and `config_tls_refresh` values for each individual host (these can be different if they are set via flagfile and not through Kolide), to ensure that online status is represented as accurately as possible.
@@ -6,7 +6,9 @@
If no JWT key is provided by the user, the server will print a new suggested random JWT key for use.
* Fix rounding error when showing % of online hosts
* Fixed bug in which deleted packs were still displayed on the query sidebar.
* Fixed rounding error when showing % of online hosts.
## Kolide 1.0.3 (April 3, 2017)
+1 -1
View File
@@ -39,11 +39,11 @@ func testGetQueryByName(t *testing.T, ds kolide.Datastore) {
require.Nil(t, err)
assert.True(t, ok)
assert.Equal(t, "q1", actual.Name)
assert.Equal(t, "select * from time", actual.Query)
actual, ok, err = ds.QueryByName("xxx")
assert.Nil(t, err)
assert.False(t, ok)
}
func testDeleteQueries(t *testing.T, ds kolide.Datastore) {
@@ -91,3 +91,31 @@ func testSaveScheduledQuery(t *testing.T, ds kolide.Datastore) {
require.Nil(t, err)
assert.Equal(t, uint(120), queryVerify.Interval)
}
func testScheduledQueryWithDeletedPack(t *testing.T, ds kolide.Datastore) {
// When a pack is soft-deleted, it should not appear in the list of
// packs associated with a query.
if ds.Name() == "inmem" {
t.Skip("inmem is being deprecated, test skipped")
}
user := test.NewUser(t, ds, "Zach", "zwass", "zwass@kolide.co", true)
query := test.NewQuery(t, ds, "q1", "select 1", user.ID, true)
pack := test.NewPack(t, ds, "foobar_pack")
test.NewScheduledQuery(t, ds, pack.ID, query.ID, 60, false, false)
actual, err := ds.Query(query.ID)
require.Nil(t, err)
assert.Equal(t, "q1", actual.Name)
assert.Equal(t, "select 1", actual.Query)
assert.Equal(t, []kolide.Pack{*pack}, actual.Packs)
require.Nil(t, ds.DeletePack(pack.ID))
actual, err = ds.Query(query.ID)
require.Nil(t, err)
assert.Equal(t, "q1", actual.Name)
assert.Equal(t, "select 1", actual.Query)
assert.Empty(t, actual.Packs)
}
+1
View File
@@ -61,6 +61,7 @@ var testFunctions = [...]func(*testing.T, kolide.Datastore){
testOptionsToConfig,
testGetPackByName,
testGetQueryByName,
testScheduledQueryWithDeletedPack,
testDecorators,
testFileIntegrityMonitoring,
testYARAStore,
+1
View File
@@ -188,6 +188,7 @@ func (d *Datastore) loadPacksForQueries(queries []*kolide.Query) error {
JOIN scheduled_queries sq
ON p.id = sq.pack_id
WHERE query_id IN (?)
AND NOT p.deleted
`
// Used to map the results