fleet/server/datastore/datastore_test.go

97 lines
2.1 KiB
Go
Raw Normal View History

package datastore
import (
"reflect"
"runtime"
"strings"
"testing"
2017-06-22 19:50:45 +00:00
"github.com/kolide/fleet/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,
testSaveLabel,
testManagingLabelsOnPacks,
testPasswordResetRequests,
testCreateUser,
testSaveUser,
testUserByID,
testPasswordResetRequests,
2016-11-02 14:59:53 +00:00
testSearchHosts,
testSearchHostsLimit,
testSearchLabels,
testSearchLabelsLimit,
testListHostsInLabel,
testListUniqueHostsInLabels,
testDistributedQueriesForHost,
testSaveHosts,
testDeleteHost,
testListHost,
testListHostsInPack,
testListPacksForHost,
testHostIDsByName,
testListPacks,
testDistributedQueryCampaign,
testCleanupDistributedQueryCampaigns,
2016-11-25 18:08:22 +00:00
testBuiltInLabels,
testLoadPacksForQueries,
testScheduledQuery,
testDeleteScheduledQuery,
testNewScheduledQuery,
testListScheduledQueriesInPack,
testCascadingDeletionOfQueries,
2016-12-29 18:32:28 +00:00
testOptions,
testOptionsToConfig,
testGetPackByName,
testGetQueryByName,
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,
testCleanupIncomingHosts,
testDuplicateNewQuery,
2017-01-20 17:22:33 +00:00
testIdempotentDeleteHost,
testChangeEmail,
testChangeLabelDetails,
testFlappingNetworkInterfaces,
testMigrationStatus,
testUnicode,
testCountHostsInTargets,
testHostStatus,
testResetOptions,
testApplyOsqueryOptions,
testApplyOsqueryOptionsNoOverrides,
testOsqueryOptionsForHost,
testApplyQueries,
testApplyPackSpecRoundtrip,
testApplyPackSpecMissingQueries,
testApplyPackSpecMissingName,
testGetPackSpec,
testApplyLabelSpecsRoundtrip,
testGetLabelSpec,
testLabelIDsByName,
testListLabelsForPack,
}