mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 00:45:19 +00:00
Update go-kit to 0.4.0 (#1411)
Notable refactoring: - Use stdlib "context" in place of "golang.org/x/net/context" - Go-kit no longer wraps errors, so we remove the unwrap in transport_error.go - Use MakeHandler when setting up endpoint tests (fixes test bug caught during this refactoring) Closes #1411.
This commit is contained in:
parent
d3bf134c7e
commit
715d908613
11
cli/serve.go
11
cli/serve.go
@ -45,7 +45,6 @@ binary (which you're executing right now). Use the options below to customize
|
||||
the way that the kolide server works.
|
||||
`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx := context.Background()
|
||||
config := configManager.LoadConfig()
|
||||
|
||||
var logger kitlog.Logger
|
||||
@ -56,7 +55,7 @@ the way that the kolide server works.
|
||||
} else {
|
||||
logger = kitlog.NewLogfmtLogger(output)
|
||||
}
|
||||
logger = kitlog.NewContext(logger).With("ts", kitlog.DefaultTimestampUTC)
|
||||
logger = kitlog.With(logger, "ts", kitlog.DefaultTimestampUTC)
|
||||
}
|
||||
|
||||
var ds kolide.Datastore
|
||||
@ -143,16 +142,16 @@ the way that the kolide server works.
|
||||
Help: "Total duration of requests in microseconds.",
|
||||
}, fieldKeys)
|
||||
|
||||
svcLogger := kitlog.NewContext(logger).With("component", "service")
|
||||
svcLogger := kitlog.With(logger, "component", "service")
|
||||
svc = service.NewLoggingService(svc, svcLogger)
|
||||
svc = service.NewMetricsService(svc, requestCount, requestLatency)
|
||||
|
||||
httpLogger := kitlog.NewContext(logger).With("component", "http")
|
||||
httpLogger := kitlog.With(logger, "component", "http")
|
||||
|
||||
var apiHandler, frontendHandler http.Handler
|
||||
{
|
||||
frontendHandler = prometheus.InstrumentHandler("get_frontend", service.ServeFrontend(httpLogger))
|
||||
apiHandler = service.MakeHandler(ctx, svc, config.Auth.JwtKey, httpLogger)
|
||||
apiHandler = service.MakeHandler(svc, config.Auth.JwtKey, httpLogger)
|
||||
|
||||
setupRequired, err := service.RequireSetup(svc)
|
||||
if err != nil {
|
||||
@ -229,7 +228,7 @@ the way that the kolide server works.
|
||||
sig := make(chan os.Signal)
|
||||
signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM)
|
||||
<-sig //block on signal
|
||||
ctx, _ = context.WithTimeout(context.Background(), 30*time.Second)
|
||||
ctx, _ := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
errs <- srv.Shutdown(ctx)
|
||||
}()
|
||||
|
||||
|
6
glide.lock
generated
6
glide.lock
generated
@ -1,5 +1,5 @@
|
||||
hash: c1bacfac1e43a7b6cb050afc246e21a426e9781fac4146df1d5571d5c28c4d90
|
||||
updated: 2017-03-08T09:05:13.458507954-08:00
|
||||
hash: f3cd6c2e30f6c19975df5373a3fd6132d5672273718275c6ecf4dfbe4993b149
|
||||
updated: 2017-03-14T10:36:42.833374871-07:00
|
||||
imports:
|
||||
- name: github.com/alecthomas/template
|
||||
version: a0175ee3bccc567396460bf5acd36800cb10c49c
|
||||
@ -27,7 +27,7 @@ imports:
|
||||
- internal
|
||||
- redis
|
||||
- name: github.com/go-kit/kit
|
||||
version: f66b0e13579bfc5a48b9e2a94b1209c107ea1f41
|
||||
version: fadad6fffe0466b19df9efd9acde5c9a52df5fa4
|
||||
subpackages:
|
||||
- endpoint
|
||||
- log
|
||||
|
@ -64,7 +64,7 @@ import:
|
||||
- package: github.com/VividCortex/mysqlerr
|
||||
version: master
|
||||
- package: github.com/go-kit/kit
|
||||
version: ~0.3.0
|
||||
version: ~0.4.0
|
||||
- package: github.com/go-yaml/yaml
|
||||
- package: github.com/ryanuber/go-license
|
||||
- package: github.com/igm/sockjs-go
|
||||
|
@ -3,8 +3,9 @@
|
||||
package host
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type key int
|
||||
|
@ -3,10 +3,9 @@
|
||||
package token
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type key int
|
||||
|
@ -3,8 +3,9 @@
|
||||
package viewer
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type key int
|
||||
|
@ -1,7 +1,7 @@
|
||||
package kolide
|
||||
|
||||
import (
|
||||
"golang.org/x/net/context"
|
||||
"context"
|
||||
)
|
||||
|
||||
// AppConfigStore contains method for saving and retrieving
|
||||
|
@ -1,10 +1,10 @@
|
||||
package kolide
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/kolide/kolide/server/websocket"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// CampaignStore defines the distributed query campaign related datastore
|
||||
|
@ -1,11 +1,10 @@
|
||||
package kolide
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -1,11 +1,10 @@
|
||||
package kolide
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type ImportConfigService interface {
|
||||
|
@ -2,9 +2,8 @@ package kolide
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"html/template"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// InviteStore contains the methods for
|
||||
|
@ -1,9 +1,8 @@
|
||||
package kolide
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type LabelStore interface {
|
||||
|
@ -1,12 +1,12 @@
|
||||
package kolide
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -1,13 +1,12 @@
|
||||
package kolide
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// OptionStore interface describes methods to access datastore
|
||||
|
@ -1,6 +1,8 @@
|
||||
package kolide
|
||||
|
||||
import "golang.org/x/net/context"
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type OsqueryService interface {
|
||||
EnrollAgent(ctx context.Context, enrollSecret, hostIdentifier string) (nodeKey string, err error)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package kolide
|
||||
|
||||
import (
|
||||
"golang.org/x/net/context"
|
||||
"context"
|
||||
)
|
||||
|
||||
// PackStore is the datastore interface for managing query packs.
|
||||
|
@ -1,6 +1,8 @@
|
||||
package kolide
|
||||
|
||||
import "golang.org/x/net/context"
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type QueryStore interface {
|
||||
// NewQuery creates a new query object in thie datastore. The returned
|
||||
|
@ -1,6 +1,8 @@
|
||||
package kolide
|
||||
|
||||
import "golang.org/x/net/context"
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// QueryResultStore defines functions for sending and receiving distributed
|
||||
// query results over a pub/sub system. It is implemented by structs in package
|
||||
|
@ -1,7 +1,7 @@
|
||||
package kolide
|
||||
|
||||
import (
|
||||
"golang.org/x/net/context"
|
||||
"context"
|
||||
)
|
||||
|
||||
type ScheduledQueryStore interface {
|
||||
|
@ -1,9 +1,8 @@
|
||||
package kolide
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// SessionStore is the abstract interface that all session backends must
|
||||
|
@ -1,7 +1,7 @@
|
||||
package kolide
|
||||
|
||||
import (
|
||||
"golang.org/x/net/context"
|
||||
"context"
|
||||
)
|
||||
|
||||
type TargetSearchResults struct {
|
||||
|
@ -2,13 +2,13 @@ package kolide
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"html/template"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// UserStore contains methods for managing users in a datastore
|
||||
|
@ -1,6 +1,7 @@
|
||||
package license
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@ -13,7 +14,6 @@ import (
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/kolide/kolide/server/version"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -99,7 +99,7 @@ func NewChecker(ds kolide.Datastore, licenseEndpointURL string, opts ...Option)
|
||||
o(response)
|
||||
}
|
||||
|
||||
response.logger = log.NewContext(response.logger).With("component", "license-checker")
|
||||
response.logger = log.With(response.logger, "component", "license-checker")
|
||||
return response
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package license
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@ -16,7 +17,6 @@ import (
|
||||
"github.com/kolide/kolide/server/mock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var tokenString = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjRkOmM1OmRlOmE1Oj" +
|
||||
|
@ -1,11 +1,10 @@
|
||||
package pubsub
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
)
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package pubsub
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
@ -13,7 +14,6 @@ import (
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// waitTimeout waits for the waitgroup for the specified max timeout.
|
||||
|
@ -1,12 +1,11 @@
|
||||
package pubsub
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/garyburd/redigo/redis"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -1,12 +1,12 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/kolide/kolide/server/contexts/viewer"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type appConfigRequest struct {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
@ -10,7 +11,6 @@ import (
|
||||
"github.com/kolide/kolide/server/contexts/viewer"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/kolide/kolide/server/websocket"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,9 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type certificateResponse struct {
|
||||
|
@ -1,9 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type changeEmailRequest struct {
|
||||
|
@ -1,12 +1,12 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type hostResponse struct {
|
||||
|
@ -1,9 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type importRequest struct {
|
||||
|
@ -1,9 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type createInviteRequest struct {
|
||||
|
@ -1,9 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type getLabelRequest struct {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type licenseRequest struct {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
@ -12,7 +13,6 @@ import (
|
||||
"github.com/kolide/kolide/server/contexts/token"
|
||||
"github.com/kolide/kolide/server/contexts/viewer"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var errNoContext = errors.New("context key not set")
|
||||
|
@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
@ -10,7 +11,6 @@ import (
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// TestEndpointPermissions tests that
|
||||
|
@ -1,9 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type optionsResponse struct {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,9 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type packResponse struct {
|
||||
|
@ -1,9 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,9 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,11 +1,11 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,7 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"golang.org/x/net/context"
|
||||
"context"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
|
@ -1,12 +1,12 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -2,6 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@ -12,13 +13,10 @@ import (
|
||||
"testing"
|
||||
|
||||
kitlog "github.com/go-kit/kit/log"
|
||||
kithttp "github.com/go-kit/kit/transport/http"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/kolide/kolide/server/config"
|
||||
"github.com/kolide/kolide/server/datastore/inmem"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type testResource struct {
|
||||
@ -57,21 +55,11 @@ func setupEndpointTest(t *testing.T) *testResource {
|
||||
svc = endpointService{svc}
|
||||
createTestUsers(t, test.ds)
|
||||
logger := kitlog.NewLogfmtLogger(os.Stdout)
|
||||
|
||||
jwtKey := "CHANGEME"
|
||||
opts := []kithttp.ServerOption{
|
||||
kithttp.ServerBefore(setRequestsContexts(svc, jwtKey)),
|
||||
kithttp.ServerErrorLogger(logger),
|
||||
kithttp.ServerAfter(kithttp.SetContentType("application/json; charset=utf-8")),
|
||||
}
|
||||
|
||||
router := mux.NewRouter()
|
||||
ke := MakeKolideServerEndpoints(svc, jwtKey)
|
||||
ctxt := context.Background()
|
||||
kh := makeKolideKitHandlers(ctxt, ke, opts)
|
||||
attachKolideAPIRoutes(router, kh)
|
||||
routes := MakeHandler(svc, jwtKey, logger)
|
||||
|
||||
test.server = httptest.NewServer(router)
|
||||
test.server = httptest.NewServer(routes)
|
||||
|
||||
userParam := loginRequest{
|
||||
Username: "admin1",
|
||||
|
@ -1,11 +1,11 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -39,6 +39,7 @@ func testNonAdminUserSetAdmin(t *testing.T, r *testResource) {
|
||||
user, err := r.ds.User("user1")
|
||||
require.Nil(t, err)
|
||||
assert.False(t, user.Admin)
|
||||
|
||||
inJson := `{"admin":true}`
|
||||
buff := bytes.NewBufferString(inJson)
|
||||
path := fmt.Sprintf("/api/v1/kolide/users/%d/admin", user.ID)
|
||||
@ -49,9 +50,8 @@ func testNonAdminUserSetAdmin(t *testing.T, r *testResource) {
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, http.StatusServiceUnavailable, resp.StatusCode)
|
||||
rb := make([]byte, 500)
|
||||
resp.Body.Read(rb)
|
||||
assert.Equal(t, http.StatusForbidden, resp.StatusCode)
|
||||
|
||||
user, err = r.ds.User("user1")
|
||||
require.Nil(t, err)
|
||||
assert.False(t, user.Admin)
|
||||
@ -85,6 +85,7 @@ func testNonAdminUserSetEnabled(t *testing.T, r *testResource) {
|
||||
user, err := r.ds.User("user1")
|
||||
require.Nil(t, err)
|
||||
assert.True(t, user.Enabled)
|
||||
|
||||
inJson := `{"enabled":false}`
|
||||
buff := bytes.NewBufferString(inJson)
|
||||
path := fmt.Sprintf("/api/v1/kolide/users/%d/enable", user.ID)
|
||||
@ -95,9 +96,8 @@ func testNonAdminUserSetEnabled(t *testing.T, r *testResource) {
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, http.StatusServiceUnavailable, resp.StatusCode)
|
||||
rb := make([]byte, 500)
|
||||
resp.Body.Read(rb)
|
||||
assert.Equal(t, http.StatusForbidden, resp.StatusCode)
|
||||
|
||||
user, err = r.ds.User("user1")
|
||||
require.Nil(t, err)
|
||||
// shouldn't change
|
||||
|
@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
@ -10,7 +11,6 @@ import (
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// KolideEndpoints is a collection of RPC endpoints implemented by the Kolide API.
|
||||
@ -227,9 +227,9 @@ type kolideHandlers struct {
|
||||
GetLicense http.Handler
|
||||
}
|
||||
|
||||
func makeKolideKitHandlers(ctx context.Context, e KolideEndpoints, opts []kithttp.ServerOption) *kolideHandlers {
|
||||
func makeKolideKitHandlers(e KolideEndpoints, opts []kithttp.ServerOption) *kolideHandlers {
|
||||
newServer := func(e endpoint.Endpoint, decodeFn kithttp.DecodeRequestFunc) http.Handler {
|
||||
return kithttp.NewServer(ctx, e, decodeFn, encodeResponse, opts...)
|
||||
return kithttp.NewServer(e, decodeFn, encodeResponse, opts...)
|
||||
}
|
||||
return &kolideHandlers{
|
||||
Login: newServer(e.Login, decodeLoginRequest),
|
||||
@ -299,7 +299,7 @@ func makeKolideKitHandlers(ctx context.Context, e KolideEndpoints, opts []kithtt
|
||||
}
|
||||
|
||||
// MakeHandler creates an HTTP handler for the Kolide server endpoints.
|
||||
func MakeHandler(ctx context.Context, svc kolide.Service, jwtKey string, logger kitlog.Logger) http.Handler {
|
||||
func MakeHandler(svc kolide.Service, jwtKey string, logger kitlog.Logger) http.Handler {
|
||||
kolideAPIOptions := []kithttp.ServerOption{
|
||||
kithttp.ServerBefore(
|
||||
setRequestsContexts(svc, jwtKey),
|
||||
@ -312,7 +312,7 @@ func MakeHandler(ctx context.Context, svc kolide.Service, jwtKey string, logger
|
||||
}
|
||||
|
||||
kolideEndpoints := MakeKolideServerEndpoints(svc, jwtKey)
|
||||
kolideHandlers := makeKolideKitHandlers(ctx, kolideEndpoints, kolideAPIOptions)
|
||||
kolideHandlers := makeKolideKitHandlers(kolideEndpoints, kolideAPIOptions)
|
||||
|
||||
r := mux.NewRouter()
|
||||
attachKolideAPIRoutes(r, kolideHandlers)
|
||||
@ -420,13 +420,11 @@ func WithSetup(svc kolide.Service, logger kitlog.Logger, next http.Handler) http
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
configRouter := http.NewServeMux()
|
||||
configRouter.Handle("/api/v1/setup", kithttp.NewServer(
|
||||
context.Background(),
|
||||
makeSetupEndpoint(svc),
|
||||
decodeSetupRequest,
|
||||
encodeResponse,
|
||||
))
|
||||
configRouter.Handle("/api/v1/license", kithttp.NewServer(
|
||||
context.Background(),
|
||||
makeSetupLicenseEndpoint(svc),
|
||||
decodeLicenseRequest,
|
||||
encodeResponse,
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"github.com/kolide/kolide/server/config"
|
||||
"github.com/kolide/kolide/server/datastore/inmem"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func TestAPIRoutes(t *testing.T) {
|
||||
@ -19,11 +18,9 @@ func TestAPIRoutes(t *testing.T) {
|
||||
svc, err := newTestService(ds, nil)
|
||||
assert.Nil(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
r := mux.NewRouter()
|
||||
ke := MakeKolideServerEndpoints(svc, "CHANGEME")
|
||||
kh := makeKolideKitHandlers(ctx, ke, nil)
|
||||
kh := makeKolideKitHandlers(ke, nil)
|
||||
attachKolideAPIRoutes(r, kh)
|
||||
handler := mux.NewRouter()
|
||||
handler.PathPrefix("/").Handler(r)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
@ -8,7 +9,6 @@ import (
|
||||
"github.com/kolide/kolide/server/contexts/token"
|
||||
"github.com/kolide/kolide/server/contexts/viewer"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// setRequestsContexts updates the request with necessary context values for a request
|
||||
|
@ -20,7 +20,6 @@ import (
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func TestLogin(t *testing.T) {
|
||||
@ -40,7 +39,7 @@ func TestLogin(t *testing.T) {
|
||||
}
|
||||
r := mux.NewRouter()
|
||||
ke := MakeKolideServerEndpoints(svc, "CHANGEME")
|
||||
kh := makeKolideKitHandlers(context.Background(), ke, opts)
|
||||
kh := makeKolideKitHandlers(ke, opts)
|
||||
attachKolideAPIRoutes(r, kh)
|
||||
r.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, "index")
|
||||
|
@ -1,10 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (mw loggingMiddleware) NewAppConfig(ctx context.Context, p kolide.AppConfigPayload) (*kolide.AppConfig, error) {
|
||||
|
@ -1,9 +1,8 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (mw loggingMiddleware) ChangeUserEmail(ctx context.Context, token string) (string, error) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (mw loggingMiddleware) ListHosts(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Host, error) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/kolide/kolide/server/contexts/viewer"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (mw loggingMiddleware) InviteNewUser(ctx context.Context, payload kolide.InvitePayload) (*kolide.Invite, error) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (mw loggingMiddleware) ModifyLabel(ctx context.Context, id uint, p kolide.ModifyLabelPayload) (*kolide.Label, error) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (mw loggingMiddleware) SaveLicense(ctx context.Context, jwtToken string) (*kolide.License, error) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (mw loggingMiddleware) EnrollAgent(ctx context.Context, enrollSecret string, hostIdentifier string) (string, error) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (mw loggingMiddleware) ListPacks(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Pack, error) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (mw loggingMiddleware) GetScheduledQuery(ctx context.Context, id uint) (*kolide.ScheduledQuery, error) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (mw loggingMiddleware) Login(ctx context.Context, username, password string) (user *kolide.User, token string, err error) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/kolide/kolide/server/contexts/viewer"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (mw loggingMiddleware) ChangeUserAdmin(ctx context.Context, id uint, isAdmin bool) (*kolide.User, error) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (mw metricsMiddleware) NewAppConfig(ctx context.Context, p kolide.AppConfigPayload) (*kolide.AppConfig, error) {
|
||||
|
@ -1,10 +1,9 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (mw metricsMiddleware) ChangeUserEmail(ctx context.Context, token string) (string, error) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (mw metricsMiddleware) InviteNewUser(ctx context.Context, payload kolide.InvitePayload) (*kolide.Invite, error) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (mw metricsMiddleware) ModifyLabel(ctx context.Context, id uint, p kolide.ModifyLabelPayload) (*kolide.Label, error) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (mw metricsMiddleware) SaveLicense(ctx context.Context, jwtToken string) (*kolide.License, error) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (mw metricsMiddleware) Login(ctx context.Context, username string, password string) (*kolide.User, string, error) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (mw metricsMiddleware) ChangeUserAdmin(ctx context.Context, id uint, isAdmin bool) (*kolide.User, error) {
|
||||
|
@ -47,7 +47,7 @@ func osqueryLogFile(path string, appLogger kitlog.Logger) io.Writer {
|
||||
MaxBackups: 3,
|
||||
MaxAge: 28, //days
|
||||
}
|
||||
appLogger = kitlog.NewContext(appLogger).With("component", "osqueryd-logger")
|
||||
appLogger = kitlog.With(appLogger, "component", "osqueryd-logger")
|
||||
|
||||
sig := make(chan os.Signal)
|
||||
signal.Notify(sig, syscall.SIGHUP)
|
||||
|
@ -1,13 +1,13 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/kolide/kolide/server/contexts/viewer"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/kolide/kolide/server/mail"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// mailError is set when an error performing mail operations
|
||||
|
@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/kolide/kolide/server/config"
|
||||
@ -8,7 +9,6 @@ import (
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func TestCreateAppConfig(t *testing.T) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
@ -8,7 +9,6 @@ import (
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/kolide/kolide/server/websocket"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (svc service) NewDistributedQueryCampaign(ctx context.Context, queryString string, hosts []uint, labels []uint) (*kolide.DistributedQueryCampaign, error) {
|
||||
|
@ -2,6 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
@ -10,7 +11,6 @@ import (
|
||||
"net/url"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// Certificate returns the PEM encoded certificate chain for osqueryd TLS termination.
|
||||
|
@ -1,8 +1,9 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (svc service) ListHosts(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Host, error) {
|
||||
|
@ -1,13 +1,13 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/kolide/kolide/server/config"
|
||||
"github.com/kolide/kolide/server/datastore/inmem"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func TestListHosts(t *testing.T) {
|
||||
|
@ -1,13 +1,13 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/kolide/kolide/server/contexts/viewer"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (svc service) ImportConfig(ctx context.Context, cfg *kolide.ImportConfig) (*kolide.ImportConfigResponse, error) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"html/template"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (svc service) InviteNewUser(ctx context.Context, payload kolide.InvitePayload) (*kolide.Invite, error) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -10,7 +11,6 @@ import (
|
||||
"github.com/kolide/kolide/server/mock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func TestInviteNewUserMock(t *testing.T) {
|
||||
|
@ -1,8 +1,9 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (svc service) ListLabels(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Label, error) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/kolide/kolide/server/config"
|
||||
@ -9,7 +10,6 @@ import (
|
||||
"github.com/kolide/kolide/server/mock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func TestModifyLabel(t *testing.T) {
|
||||
|
@ -1,8 +1,9 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (svc service) License(ctx context.Context) (*kolide.License, error) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -9,7 +10,6 @@ import (
|
||||
"github.com/kolide/kolide/server/mock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func TestLicenseService(t *testing.T) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
const expectedCheckinIntervalMultiplier = 2
|
||||
|
@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
@ -12,7 +13,6 @@ import (
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/kolide/kolide/server/pubsub"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type osqueryError struct {
|
||||
|
@ -2,6 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
@ -9,8 +10,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/WatchBeam/clock"
|
||||
"github.com/kolide/kolide/server/config"
|
||||
hostctx "github.com/kolide/kolide/server/contexts/host"
|
||||
|
@ -1,9 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/kolide/kolide/server/contexts/viewer"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (svc service) ListPacks(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Pack, error) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/WatchBeam/clock"
|
||||
@ -10,7 +11,6 @@ import (
|
||||
"github.com/kolide/kolide/server/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func TestListPacks(t *testing.T) {
|
||||
|
@ -1,9 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/kolide/kolide/server/contexts/viewer"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (svc service) ListQueries(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Query, error) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/kolide/kolide/server/config"
|
||||
@ -9,7 +10,6 @@ import (
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func TestListQueries(t *testing.T) {
|
||||
|
@ -1,9 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (svc service) GetScheduledQuery(ctx context.Context, id uint) (*kolide.ScheduledQuery, error) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/kolide/kolide/server/config"
|
||||
@ -9,7 +10,6 @@ import (
|
||||
"github.com/kolide/kolide/server/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func TestGetScheduledQueriesInPack(t *testing.T) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"strings"
|
||||
@ -10,7 +11,6 @@ import (
|
||||
"github.com/kolide/kolide/server/contexts/viewer"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (svc service) Login(ctx context.Context, username, password string) (*kolide.User, string, error) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -10,7 +11,6 @@ import (
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
const bcryptCost = 6
|
||||
|
@ -1,9 +1,10 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (svc service) SearchTargets(ctx context.Context, query string, selectedHostIDs []uint, selectedLabelIDs []uint) (*kolide.TargetSearchResults, error) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
@ -11,7 +12,6 @@ import (
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func TestSearchTargets(t *testing.T) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"html/template"
|
||||
@ -9,7 +10,6 @@ import (
|
||||
"github.com/kolide/kolide/server/contexts/viewer"
|
||||
"github.com/kolide/kolide/server/kolide"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (svc service) NewUser(ctx context.Context, p kolide.UserPayload) (*kolide.User, error) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
"time"
|
||||
@ -15,7 +16,6 @@ import (
|
||||
pkg_errors "github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func TestAuthenticatedUser(t *testing.T) {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user