fleet/server/datastore/datastore_test.go

82 lines
1.7 KiB
Go
Raw Normal View History

package datastore
import (
"reflect"
"runtime"
"strings"
"testing"
2017-02-01 17:20:50 +00:00
"github.com/kolide/kolide/server/kolide"
)
func functionName(f func(*testing.T, kolide.Datastore)) string {
fullName := runtime.FuncForPC(reflect.ValueOf(f).Pointer()).Name()
elements := strings.Split(fullName, ".")
return elements[len(elements)-1]
}
var testFunctions = [...]func(*testing.T, kolide.Datastore){
testOrgInfo,
testCreateInvite,
testInviteByEmail,
testInviteByToken,
testListInvites,
testDeleteInvite,
testSaveInvite,
testDeleteQuery,
testDeleteQueries,
testSaveQuery,
testListQuery,
testDeletePack,
testEnrollHost,
testAuthenticateHost,
testLabels,
testManagingLabelsOnPacks,
testPasswordResetRequests,
testCreateUser,
testSaveUser,
testUserByID,
testPasswordResetRequests,
2016-11-02 14:59:53 +00:00
testSearchHosts,
testSearchHostsLimit,
testSearchLabels,
testSearchLabelsLimit,
testListHostsInLabel,
testListUniqueHostsInLabels,
testDistributedQueriesForHost,
testSaveHosts,
testDeleteHost,
testListHost,
testGetHostsInPack,
testDistributedQueryCampaign,
testCleanupDistributedQueryCampaigns,
2016-11-25 18:08:22 +00:00
testBuiltInLabels,
testLoadPacksForQueries,
testScheduledQuery,
testDeleteScheduledQuery,
testListScheduledQueriesInPack,
testSaveScheduledQuery,
2016-12-29 18:32:28 +00:00
testOptions,
testNewScheduledQuery,
testOptionsToConfig,
testGetPackByName,
testGetQueryByName,
testDecorators,
testFileIntegrityMonitoring,
testYARAStore,
Add host_ids and label_ids fields to the packs API (#737) This PR adds the `host_ids` and `label_ids` field to the packs HTTP API so that one can operate on the hosts/labels which a pack is scheduled to be executed on. This replaces (and deletes) the `/api/v1/kolide/packs/123/labels/456` API in favor of `PATCH /api/v1/packs/123` and specifying the `label_ids` field. This also allows for bulk operations. Consider the following API examples: ## Creating a pack with a known set of hosts and labels The key addition is the `host_ids` and `label_ids` field in both the request and the response. ### Request ``` POST /api/v1/kolide/packs ``` ```json { "name": "My new pack", "description": "The newest of the packs", "host_ids": [1, 2, 3], "label_ids": [1, 3, 5] } ``` ### Response ```json { "pack": { "id": 123, "name": "My new pack", "description": "The newest of the packs", "platform": "", "created_by": 1, "disabled": false, "query_count": 0, "total_hosts_count": 5, "host_ids": [1, 2, 3], "label_ids": [1, 3, 5] } } ``` ## Modifying the hosts and/or labels that a pack is scheduled to execute on ### Request ``` PATCH /api/v1/kolide/packs/123 ``` ```json { "host_ids": [1, 2, 3, 4, 5], "label_ids": [1, 3, 5, 7] } ``` ### Response ```json { "pack": { "id": 123, "name": "My new pack", "description": "The newest of the packs", "platform": "", "created_by": 1, "disabled": false, "query_count": 0, "total_hosts_count": 5, "host_ids": [1, 2, 3, 4, 5], "label_ids": [1, 3, 5, 7] } } ``` close #633
2017-01-03 17:32:06 +00:00
testAddLabelToPackTwice,
testGenerateHostStatusStatistics,
testMarkHostSeen,
testDuplicateNewQuery,
2017-01-20 17:22:33 +00:00
testIdempotentDeleteHost,
testChangeEmail,
2017-02-02 20:30:59 +00:00
testLicense,
2017-02-12 04:27:43 +00:00
testSaveLabel,
testFlappingNetworkInterfaces,
testReplaceDeletedLabel,
testMigrationStatus,
testUnicode,
testCountHostsInTargets,
testResetOptions,
}