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:
Zachary Wasserman 2017-03-15 08:55:30 -07:00 committed by GitHub
parent d3bf134c7e
commit 715d908613
133 changed files with 177 additions and 216 deletions

View File

@ -45,7 +45,6 @@ binary (which you're executing right now). Use the options below to customize
the way that the kolide server works. the way that the kolide server works.
`, `,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
ctx := context.Background()
config := configManager.LoadConfig() config := configManager.LoadConfig()
var logger kitlog.Logger var logger kitlog.Logger
@ -56,7 +55,7 @@ the way that the kolide server works.
} else { } else {
logger = kitlog.NewLogfmtLogger(output) logger = kitlog.NewLogfmtLogger(output)
} }
logger = kitlog.NewContext(logger).With("ts", kitlog.DefaultTimestampUTC) logger = kitlog.With(logger, "ts", kitlog.DefaultTimestampUTC)
} }
var ds kolide.Datastore var ds kolide.Datastore
@ -143,16 +142,16 @@ the way that the kolide server works.
Help: "Total duration of requests in microseconds.", Help: "Total duration of requests in microseconds.",
}, fieldKeys) }, fieldKeys)
svcLogger := kitlog.NewContext(logger).With("component", "service") svcLogger := kitlog.With(logger, "component", "service")
svc = service.NewLoggingService(svc, svcLogger) svc = service.NewLoggingService(svc, svcLogger)
svc = service.NewMetricsService(svc, requestCount, requestLatency) svc = service.NewMetricsService(svc, requestCount, requestLatency)
httpLogger := kitlog.NewContext(logger).With("component", "http") httpLogger := kitlog.With(logger, "component", "http")
var apiHandler, frontendHandler http.Handler var apiHandler, frontendHandler http.Handler
{ {
frontendHandler = prometheus.InstrumentHandler("get_frontend", service.ServeFrontend(httpLogger)) 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) setupRequired, err := service.RequireSetup(svc)
if err != nil { if err != nil {
@ -229,7 +228,7 @@ the way that the kolide server works.
sig := make(chan os.Signal) sig := make(chan os.Signal)
signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM) signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM)
<-sig //block on signal <-sig //block on signal
ctx, _ = context.WithTimeout(context.Background(), 30*time.Second) ctx, _ := context.WithTimeout(context.Background(), 30*time.Second)
errs <- srv.Shutdown(ctx) errs <- srv.Shutdown(ctx)
}() }()

6
glide.lock generated
View File

@ -1,5 +1,5 @@
hash: c1bacfac1e43a7b6cb050afc246e21a426e9781fac4146df1d5571d5c28c4d90 hash: f3cd6c2e30f6c19975df5373a3fd6132d5672273718275c6ecf4dfbe4993b149
updated: 2017-03-08T09:05:13.458507954-08:00 updated: 2017-03-14T10:36:42.833374871-07:00
imports: imports:
- name: github.com/alecthomas/template - name: github.com/alecthomas/template
version: a0175ee3bccc567396460bf5acd36800cb10c49c version: a0175ee3bccc567396460bf5acd36800cb10c49c
@ -27,7 +27,7 @@ imports:
- internal - internal
- redis - redis
- name: github.com/go-kit/kit - name: github.com/go-kit/kit
version: f66b0e13579bfc5a48b9e2a94b1209c107ea1f41 version: fadad6fffe0466b19df9efd9acde5c9a52df5fa4
subpackages: subpackages:
- endpoint - endpoint
- log - log

View File

@ -64,7 +64,7 @@ import:
- package: github.com/VividCortex/mysqlerr - package: github.com/VividCortex/mysqlerr
version: master version: master
- package: github.com/go-kit/kit - package: github.com/go-kit/kit
version: ~0.3.0 version: ~0.4.0
- package: github.com/go-yaml/yaml - package: github.com/go-yaml/yaml
- package: github.com/ryanuber/go-license - package: github.com/ryanuber/go-license
- package: github.com/igm/sockjs-go - package: github.com/igm/sockjs-go

View File

@ -3,8 +3,9 @@
package host package host
import ( import (
"context"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
type key int type key int

View File

@ -3,10 +3,9 @@
package token package token
import ( import (
"context"
"net/http" "net/http"
"strings" "strings"
"golang.org/x/net/context"
) )
type key int type key int

View File

@ -3,8 +3,9 @@
package viewer package viewer
import ( import (
"context"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
type key int type key int

View File

@ -1,7 +1,7 @@
package kolide package kolide
import ( import (
"golang.org/x/net/context" "context"
) )
// AppConfigStore contains method for saving and retrieving // AppConfigStore contains method for saving and retrieving

View File

@ -1,10 +1,10 @@
package kolide package kolide
import ( import (
"context"
"time" "time"
"github.com/kolide/kolide/server/websocket" "github.com/kolide/kolide/server/websocket"
"golang.org/x/net/context"
) )
// CampaignStore defines the distributed query campaign related datastore // CampaignStore defines the distributed query campaign related datastore

View File

@ -1,11 +1,10 @@
package kolide package kolide
import ( import (
"context"
"crypto/rand" "crypto/rand"
"encoding/base64" "encoding/base64"
"time" "time"
"golang.org/x/net/context"
) )
const ( const (

View File

@ -1,11 +1,10 @@
package kolide package kolide
import ( import (
"context"
"errors" "errors"
"fmt" "fmt"
"strings" "strings"
"golang.org/x/net/context"
) )
type ImportConfigService interface { type ImportConfigService interface {

View File

@ -2,9 +2,8 @@ package kolide
import ( import (
"bytes" "bytes"
"context"
"html/template" "html/template"
"golang.org/x/net/context"
) )
// InviteStore contains the methods for // InviteStore contains the methods for

View File

@ -1,9 +1,8 @@
package kolide package kolide
import ( import (
"context"
"time" "time"
"golang.org/x/net/context"
) )
type LabelStore interface { type LabelStore interface {

View File

@ -1,12 +1,12 @@
package kolide package kolide
import ( import (
"context"
"fmt" "fmt"
"time" "time"
"github.com/dgrijalva/jwt-go" "github.com/dgrijalva/jwt-go"
"github.com/pkg/errors" "github.com/pkg/errors"
"golang.org/x/net/context"
) )
const ( const (

View File

@ -1,13 +1,12 @@
package kolide package kolide
import ( import (
"context"
"database/sql/driver" "database/sql/driver"
"encoding/json" "encoding/json"
"fmt" "fmt"
"strings" "strings"
"time" "time"
"golang.org/x/net/context"
) )
// OptionStore interface describes methods to access datastore // OptionStore interface describes methods to access datastore

View File

@ -1,6 +1,8 @@
package kolide package kolide
import "golang.org/x/net/context" import (
"context"
)
type OsqueryService interface { type OsqueryService interface {
EnrollAgent(ctx context.Context, enrollSecret, hostIdentifier string) (nodeKey string, err error) EnrollAgent(ctx context.Context, enrollSecret, hostIdentifier string) (nodeKey string, err error)

View File

@ -1,7 +1,7 @@
package kolide package kolide
import ( import (
"golang.org/x/net/context" "context"
) )
// PackStore is the datastore interface for managing query packs. // PackStore is the datastore interface for managing query packs.

View File

@ -1,6 +1,8 @@
package kolide package kolide
import "golang.org/x/net/context" import (
"context"
)
type QueryStore interface { type QueryStore interface {
// NewQuery creates a new query object in thie datastore. The returned // NewQuery creates a new query object in thie datastore. The returned

View File

@ -1,6 +1,8 @@
package kolide package kolide
import "golang.org/x/net/context" import (
"context"
)
// QueryResultStore defines functions for sending and receiving distributed // QueryResultStore defines functions for sending and receiving distributed
// query results over a pub/sub system. It is implemented by structs in package // query results over a pub/sub system. It is implemented by structs in package

View File

@ -1,7 +1,7 @@
package kolide package kolide
import ( import (
"golang.org/x/net/context" "context"
) )
type ScheduledQueryStore interface { type ScheduledQueryStore interface {

View File

@ -1,9 +1,8 @@
package kolide package kolide
import ( import (
"context"
"time" "time"
"golang.org/x/net/context"
) )
// SessionStore is the abstract interface that all session backends must // SessionStore is the abstract interface that all session backends must

View File

@ -1,7 +1,7 @@
package kolide package kolide
import ( import (
"golang.org/x/net/context" "context"
) )
type TargetSearchResults struct { type TargetSearchResults struct {

View File

@ -2,13 +2,13 @@ package kolide
import ( import (
"bytes" "bytes"
"context"
"crypto/rand" "crypto/rand"
"encoding/base64" "encoding/base64"
"fmt" "fmt"
"html/template" "html/template"
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"
"golang.org/x/net/context"
) )
// UserStore contains methods for managing users in a datastore // UserStore contains methods for managing users in a datastore

View File

@ -1,6 +1,7 @@
package license package license
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http" "net/http"
@ -13,7 +14,6 @@ import (
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/kolide/kolide/server/version" "github.com/kolide/kolide/server/version"
"github.com/pkg/errors" "github.com/pkg/errors"
"golang.org/x/net/context"
) )
const ( const (
@ -99,7 +99,7 @@ func NewChecker(ds kolide.Datastore, licenseEndpointURL string, opts ...Option)
o(response) o(response)
} }
response.logger = log.NewContext(response.logger).With("component", "license-checker") response.logger = log.With(response.logger, "component", "license-checker")
return response return response
} }

View File

@ -1,6 +1,7 @@
package license package license
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http" "net/http"
@ -16,7 +17,6 @@ import (
"github.com/kolide/kolide/server/mock" "github.com/kolide/kolide/server/mock"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context"
) )
var tokenString = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjRkOmM1OmRlOmE1Oj" + var tokenString = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjRkOmM1OmRlOmE1Oj" +

View File

@ -1,11 +1,10 @@
package pubsub package pubsub
import ( import (
"context"
"strconv" "strconv"
"sync" "sync"
"golang.org/x/net/context"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
) )

View File

@ -1,6 +1,7 @@
package pubsub package pubsub
import ( import (
"context"
"fmt" "fmt"
"os" "os"
"reflect" "reflect"
@ -13,7 +14,6 @@ import (
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context"
) )
// waitTimeout waits for the waitgroup for the specified max timeout. // waitTimeout waits for the waitgroup for the specified max timeout.

View File

@ -1,12 +1,11 @@
package pubsub package pubsub
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"time" "time"
"golang.org/x/net/context"
"github.com/garyburd/redigo/redis" "github.com/garyburd/redigo/redis"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/pkg/errors" "github.com/pkg/errors"

View File

@ -1,12 +1,12 @@
package service package service
import ( import (
"context"
"fmt" "fmt"
"github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/endpoint"
"github.com/kolide/kolide/server/contexts/viewer" "github.com/kolide/kolide/server/contexts/viewer"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
type appConfigRequest struct { type appConfigRequest struct {

View File

@ -1,6 +1,7 @@
package service package service
import ( import (
"context"
"encoding/json" "encoding/json"
"net/http" "net/http"
@ -10,7 +11,6 @@ import (
"github.com/kolide/kolide/server/contexts/viewer" "github.com/kolide/kolide/server/contexts/viewer"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/kolide/kolide/server/websocket" "github.com/kolide/kolide/server/websocket"
"golang.org/x/net/context"
) )
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -1,9 +1,10 @@
package service package service
import ( import (
"context"
"github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/endpoint"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
type certificateResponse struct { type certificateResponse struct {

View File

@ -1,9 +1,10 @@
package service package service
import ( import (
"context"
"github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/endpoint"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
type changeEmailRequest struct { type changeEmailRequest struct {

View File

@ -1,12 +1,12 @@
package service package service
import ( import (
"context"
"time" "time"
"github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/endpoint"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/pkg/errors" "github.com/pkg/errors"
"golang.org/x/net/context"
) )
type hostResponse struct { type hostResponse struct {

View File

@ -1,9 +1,10 @@
package service package service
import ( import (
"context"
"github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/endpoint"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
type importRequest struct { type importRequest struct {

View File

@ -1,9 +1,10 @@
package service package service
import ( import (
"context"
"github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/endpoint"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
type createInviteRequest struct { type createInviteRequest struct {

View File

@ -1,9 +1,10 @@
package service package service
import ( import (
"context"
"github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/endpoint"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
type getLabelRequest struct { type getLabelRequest struct {

View File

@ -1,11 +1,11 @@
package service package service
import ( import (
"context"
"time" "time"
"github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/endpoint"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
type licenseRequest struct { type licenseRequest struct {

View File

@ -1,6 +1,7 @@
package service package service
import ( import (
"context"
"errors" "errors"
"fmt" "fmt"
"reflect" "reflect"
@ -12,7 +13,6 @@ import (
"github.com/kolide/kolide/server/contexts/token" "github.com/kolide/kolide/server/contexts/token"
"github.com/kolide/kolide/server/contexts/viewer" "github.com/kolide/kolide/server/contexts/viewer"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
var errNoContext = errors.New("context key not set") var errNoContext = errors.New("context key not set")

View File

@ -1,6 +1,7 @@
package service package service
import ( import (
"context"
"testing" "testing"
"github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/endpoint"
@ -10,7 +11,6 @@ import (
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context"
) )
// TestEndpointPermissions tests that // TestEndpointPermissions tests that

View File

@ -1,9 +1,10 @@
package service package service
import ( import (
"context"
"github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/endpoint"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
type optionsResponse struct { type optionsResponse struct {

View File

@ -1,11 +1,11 @@
package service package service
import ( import (
"context"
"encoding/json" "encoding/json"
"github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/endpoint"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -1,9 +1,10 @@
package service package service
import ( import (
"context"
"github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/endpoint"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
type packResponse struct { type packResponse struct {

View File

@ -1,9 +1,10 @@
package service package service
import ( import (
"context"
"github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/endpoint"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -1,9 +1,10 @@
package service package service
import ( import (
"context"
"github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/endpoint"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -1,11 +1,11 @@
package service package service
import ( import (
"context"
"time" "time"
"github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/endpoint"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -1,7 +1,7 @@
package service package service
import ( import (
"golang.org/x/net/context" "context"
"github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/endpoint"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"

View File

@ -1,12 +1,12 @@
package service package service
import ( import (
"context"
"time" "time"
"github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/endpoint"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/pkg/errors" "github.com/pkg/errors"
"golang.org/x/net/context"
) )
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -2,6 +2,7 @@ package service
import ( import (
"bytes" "bytes"
"context"
"encoding/json" "encoding/json"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
@ -12,13 +13,10 @@ import (
"testing" "testing"
kitlog "github.com/go-kit/kit/log" 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/config"
"github.com/kolide/kolide/server/datastore/inmem" "github.com/kolide/kolide/server/datastore/inmem"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context"
) )
type testResource struct { type testResource struct {
@ -57,21 +55,11 @@ func setupEndpointTest(t *testing.T) *testResource {
svc = endpointService{svc} svc = endpointService{svc}
createTestUsers(t, test.ds) createTestUsers(t, test.ds)
logger := kitlog.NewLogfmtLogger(os.Stdout) logger := kitlog.NewLogfmtLogger(os.Stdout)
jwtKey := "CHANGEME" 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() routes := MakeHandler(svc, jwtKey, logger)
ke := MakeKolideServerEndpoints(svc, jwtKey)
ctxt := context.Background()
kh := makeKolideKitHandlers(ctxt, ke, opts)
attachKolideAPIRoutes(router, kh)
test.server = httptest.NewServer(router) test.server = httptest.NewServer(routes)
userParam := loginRequest{ userParam := loginRequest{
Username: "admin1", Username: "admin1",

View File

@ -1,11 +1,11 @@
package service package service
import ( import (
"context"
"net/http" "net/http"
"github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/endpoint"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -39,6 +39,7 @@ func testNonAdminUserSetAdmin(t *testing.T, r *testResource) {
user, err := r.ds.User("user1") user, err := r.ds.User("user1")
require.Nil(t, err) require.Nil(t, err)
assert.False(t, user.Admin) assert.False(t, user.Admin)
inJson := `{"admin":true}` inJson := `{"admin":true}`
buff := bytes.NewBufferString(inJson) buff := bytes.NewBufferString(inJson)
path := fmt.Sprintf("/api/v1/kolide/users/%d/admin", user.ID) 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{} client := &http.Client{}
resp, err := client.Do(req) resp, err := client.Do(req)
require.Nil(t, err) require.Nil(t, err)
assert.Equal(t, http.StatusServiceUnavailable, resp.StatusCode) assert.Equal(t, http.StatusForbidden, resp.StatusCode)
rb := make([]byte, 500)
resp.Body.Read(rb)
user, err = r.ds.User("user1") user, err = r.ds.User("user1")
require.Nil(t, err) require.Nil(t, err)
assert.False(t, user.Admin) assert.False(t, user.Admin)
@ -85,6 +85,7 @@ func testNonAdminUserSetEnabled(t *testing.T, r *testResource) {
user, err := r.ds.User("user1") user, err := r.ds.User("user1")
require.Nil(t, err) require.Nil(t, err)
assert.True(t, user.Enabled) assert.True(t, user.Enabled)
inJson := `{"enabled":false}` inJson := `{"enabled":false}`
buff := bytes.NewBufferString(inJson) buff := bytes.NewBufferString(inJson)
path := fmt.Sprintf("/api/v1/kolide/users/%d/enable", user.ID) 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{} client := &http.Client{}
resp, err := client.Do(req) resp, err := client.Do(req)
require.Nil(t, err) require.Nil(t, err)
assert.Equal(t, http.StatusServiceUnavailable, resp.StatusCode) assert.Equal(t, http.StatusForbidden, resp.StatusCode)
rb := make([]byte, 500)
resp.Body.Read(rb)
user, err = r.ds.User("user1") user, err = r.ds.User("user1")
require.Nil(t, err) require.Nil(t, err)
// shouldn't change // shouldn't change

View File

@ -1,6 +1,7 @@
package service package service
import ( import (
"context"
"net/http" "net/http"
"strings" "strings"
@ -10,7 +11,6 @@ import (
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"golang.org/x/net/context"
) )
// KolideEndpoints is a collection of RPC endpoints implemented by the Kolide API. // KolideEndpoints is a collection of RPC endpoints implemented by the Kolide API.
@ -227,9 +227,9 @@ type kolideHandlers struct {
GetLicense http.Handler 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 { 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{ return &kolideHandlers{
Login: newServer(e.Login, decodeLoginRequest), 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. // 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{ kolideAPIOptions := []kithttp.ServerOption{
kithttp.ServerBefore( kithttp.ServerBefore(
setRequestsContexts(svc, jwtKey), setRequestsContexts(svc, jwtKey),
@ -312,7 +312,7 @@ func MakeHandler(ctx context.Context, svc kolide.Service, jwtKey string, logger
} }
kolideEndpoints := MakeKolideServerEndpoints(svc, jwtKey) kolideEndpoints := MakeKolideServerEndpoints(svc, jwtKey)
kolideHandlers := makeKolideKitHandlers(ctx, kolideEndpoints, kolideAPIOptions) kolideHandlers := makeKolideKitHandlers(kolideEndpoints, kolideAPIOptions)
r := mux.NewRouter() r := mux.NewRouter()
attachKolideAPIRoutes(r, kolideHandlers) 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) { return func(w http.ResponseWriter, r *http.Request) {
configRouter := http.NewServeMux() configRouter := http.NewServeMux()
configRouter.Handle("/api/v1/setup", kithttp.NewServer( configRouter.Handle("/api/v1/setup", kithttp.NewServer(
context.Background(),
makeSetupEndpoint(svc), makeSetupEndpoint(svc),
decodeSetupRequest, decodeSetupRequest,
encodeResponse, encodeResponse,
)) ))
configRouter.Handle("/api/v1/license", kithttp.NewServer( configRouter.Handle("/api/v1/license", kithttp.NewServer(
context.Background(),
makeSetupLicenseEndpoint(svc), makeSetupLicenseEndpoint(svc),
decodeLicenseRequest, decodeLicenseRequest,
encodeResponse, encodeResponse,

View File

@ -9,7 +9,6 @@ import (
"github.com/kolide/kolide/server/config" "github.com/kolide/kolide/server/config"
"github.com/kolide/kolide/server/datastore/inmem" "github.com/kolide/kolide/server/datastore/inmem"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"golang.org/x/net/context"
) )
func TestAPIRoutes(t *testing.T) { func TestAPIRoutes(t *testing.T) {
@ -19,11 +18,9 @@ func TestAPIRoutes(t *testing.T) {
svc, err := newTestService(ds, nil) svc, err := newTestService(ds, nil)
assert.Nil(t, err) assert.Nil(t, err)
ctx := context.Background()
r := mux.NewRouter() r := mux.NewRouter()
ke := MakeKolideServerEndpoints(svc, "CHANGEME") ke := MakeKolideServerEndpoints(svc, "CHANGEME")
kh := makeKolideKitHandlers(ctx, ke, nil) kh := makeKolideKitHandlers(ke, nil)
attachKolideAPIRoutes(r, kh) attachKolideAPIRoutes(r, kh)
handler := mux.NewRouter() handler := mux.NewRouter()
handler.PathPrefix("/").Handler(r) handler.PathPrefix("/").Handler(r)

View File

@ -1,6 +1,7 @@
package service package service
import ( import (
"context"
"net/http" "net/http"
"strings" "strings"
@ -8,7 +9,6 @@ import (
"github.com/kolide/kolide/server/contexts/token" "github.com/kolide/kolide/server/contexts/token"
"github.com/kolide/kolide/server/contexts/viewer" "github.com/kolide/kolide/server/contexts/viewer"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
// setRequestsContexts updates the request with necessary context values for a request // setRequestsContexts updates the request with necessary context values for a request

View File

@ -20,7 +20,6 @@ import (
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context"
) )
func TestLogin(t *testing.T) { func TestLogin(t *testing.T) {
@ -40,7 +39,7 @@ func TestLogin(t *testing.T) {
} }
r := mux.NewRouter() r := mux.NewRouter()
ke := MakeKolideServerEndpoints(svc, "CHANGEME") ke := MakeKolideServerEndpoints(svc, "CHANGEME")
kh := makeKolideKitHandlers(context.Background(), ke, opts) kh := makeKolideKitHandlers(ke, opts)
attachKolideAPIRoutes(r, kh) attachKolideAPIRoutes(r, kh)
r.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { r.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "index") fmt.Fprint(w, "index")

View File

@ -1,10 +1,10 @@
package service package service
import ( import (
"context"
"time" "time"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
func (mw loggingMiddleware) NewAppConfig(ctx context.Context, p kolide.AppConfigPayload) (*kolide.AppConfig, error) { func (mw loggingMiddleware) NewAppConfig(ctx context.Context, p kolide.AppConfigPayload) (*kolide.AppConfig, error) {

View File

@ -1,9 +1,8 @@
package service package service
import ( import (
"context"
"time" "time"
"golang.org/x/net/context"
) )
func (mw loggingMiddleware) ChangeUserEmail(ctx context.Context, token string) (string, error) { func (mw loggingMiddleware) ChangeUserEmail(ctx context.Context, token string) (string, error) {

View File

@ -1,10 +1,10 @@
package service package service
import ( import (
"context"
"time" "time"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
func (mw loggingMiddleware) ListHosts(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Host, error) { func (mw loggingMiddleware) ListHosts(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Host, error) {

View File

@ -1,11 +1,11 @@
package service package service
import ( import (
"context"
"time" "time"
"github.com/kolide/kolide/server/contexts/viewer" "github.com/kolide/kolide/server/contexts/viewer"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
func (mw loggingMiddleware) InviteNewUser(ctx context.Context, payload kolide.InvitePayload) (*kolide.Invite, error) { func (mw loggingMiddleware) InviteNewUser(ctx context.Context, payload kolide.InvitePayload) (*kolide.Invite, error) {

View File

@ -1,10 +1,10 @@
package service package service
import ( import (
"context"
"time" "time"
"github.com/kolide/kolide/server/kolide" "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) { func (mw loggingMiddleware) ModifyLabel(ctx context.Context, id uint, p kolide.ModifyLabelPayload) (*kolide.Label, error) {

View File

@ -1,10 +1,10 @@
package service package service
import ( import (
"context"
"time" "time"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
func (mw loggingMiddleware) SaveLicense(ctx context.Context, jwtToken string) (*kolide.License, error) { func (mw loggingMiddleware) SaveLicense(ctx context.Context, jwtToken string) (*kolide.License, error) {

View File

@ -1,10 +1,10 @@
package service package service
import ( import (
"context"
"time" "time"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
func (mw loggingMiddleware) EnrollAgent(ctx context.Context, enrollSecret string, hostIdentifier string) (string, error) { func (mw loggingMiddleware) EnrollAgent(ctx context.Context, enrollSecret string, hostIdentifier string) (string, error) {

View File

@ -1,10 +1,10 @@
package service package service
import ( import (
"context"
"time" "time"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
func (mw loggingMiddleware) ListPacks(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Pack, error) { func (mw loggingMiddleware) ListPacks(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Pack, error) {

View File

@ -1,10 +1,10 @@
package service package service
import ( import (
"context"
"time" "time"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
func (mw loggingMiddleware) GetScheduledQuery(ctx context.Context, id uint) (*kolide.ScheduledQuery, error) { func (mw loggingMiddleware) GetScheduledQuery(ctx context.Context, id uint) (*kolide.ScheduledQuery, error) {

View File

@ -1,10 +1,10 @@
package service package service
import ( import (
"context"
"time" "time"
"github.com/kolide/kolide/server/kolide" "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) { func (mw loggingMiddleware) Login(ctx context.Context, username, password string) (user *kolide.User, token string, err error) {

View File

@ -1,11 +1,11 @@
package service package service
import ( import (
"context"
"time" "time"
"github.com/kolide/kolide/server/contexts/viewer" "github.com/kolide/kolide/server/contexts/viewer"
"github.com/kolide/kolide/server/kolide" "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) { func (mw loggingMiddleware) ChangeUserAdmin(ctx context.Context, id uint, isAdmin bool) (*kolide.User, error) {

View File

@ -1,11 +1,11 @@
package service package service
import ( import (
"context"
"fmt" "fmt"
"time" "time"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
func (mw metricsMiddleware) NewAppConfig(ctx context.Context, p kolide.AppConfigPayload) (*kolide.AppConfig, error) { func (mw metricsMiddleware) NewAppConfig(ctx context.Context, p kolide.AppConfigPayload) (*kolide.AppConfig, error) {

View File

@ -1,10 +1,9 @@
package service package service
import ( import (
"context"
"fmt" "fmt"
"time" "time"
"golang.org/x/net/context"
) )
func (mw metricsMiddleware) ChangeUserEmail(ctx context.Context, token string) (string, error) { func (mw metricsMiddleware) ChangeUserEmail(ctx context.Context, token string) (string, error) {

View File

@ -1,11 +1,11 @@
package service package service
import ( import (
"context"
"fmt" "fmt"
"time" "time"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
func (mw metricsMiddleware) InviteNewUser(ctx context.Context, payload kolide.InvitePayload) (*kolide.Invite, error) { func (mw metricsMiddleware) InviteNewUser(ctx context.Context, payload kolide.InvitePayload) (*kolide.Invite, error) {

View File

@ -1,11 +1,11 @@
package service package service
import ( import (
"context"
"fmt" "fmt"
"time" "time"
"github.com/kolide/kolide/server/kolide" "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) { func (mw metricsMiddleware) ModifyLabel(ctx context.Context, id uint, p kolide.ModifyLabelPayload) (*kolide.Label, error) {

View File

@ -1,11 +1,11 @@
package service package service
import ( import (
"context"
"fmt" "fmt"
"time" "time"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
func (mw metricsMiddleware) SaveLicense(ctx context.Context, jwtToken string) (*kolide.License, error) { func (mw metricsMiddleware) SaveLicense(ctx context.Context, jwtToken string) (*kolide.License, error) {

View File

@ -1,11 +1,11 @@
package service package service
import ( import (
"context"
"fmt" "fmt"
"time" "time"
"github.com/kolide/kolide/server/kolide" "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) { func (mw metricsMiddleware) Login(ctx context.Context, username string, password string) (*kolide.User, string, error) {

View File

@ -1,11 +1,11 @@
package service package service
import ( import (
"context"
"fmt" "fmt"
"time" "time"
"github.com/kolide/kolide/server/kolide" "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) { func (mw metricsMiddleware) ChangeUserAdmin(ctx context.Context, id uint, isAdmin bool) (*kolide.User, error) {

View File

@ -47,7 +47,7 @@ func osqueryLogFile(path string, appLogger kitlog.Logger) io.Writer {
MaxBackups: 3, MaxBackups: 3,
MaxAge: 28, //days MaxAge: 28, //days
} }
appLogger = kitlog.NewContext(appLogger).With("component", "osqueryd-logger") appLogger = kitlog.With(appLogger, "component", "osqueryd-logger")
sig := make(chan os.Signal) sig := make(chan os.Signal)
signal.Notify(sig, syscall.SIGHUP) signal.Notify(sig, syscall.SIGHUP)

View File

@ -1,13 +1,13 @@
package service package service
import ( import (
"context"
"fmt" "fmt"
"github.com/kolide/kolide/server/contexts/viewer" "github.com/kolide/kolide/server/contexts/viewer"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/kolide/kolide/server/mail" "github.com/kolide/kolide/server/mail"
"github.com/pkg/errors" "github.com/pkg/errors"
"golang.org/x/net/context"
) )
// mailError is set when an error performing mail operations // mailError is set when an error performing mail operations

View File

@ -1,6 +1,7 @@
package service package service
import ( import (
"context"
"testing" "testing"
"github.com/kolide/kolide/server/config" "github.com/kolide/kolide/server/config"
@ -8,7 +9,6 @@ import (
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context"
) )
func TestCreateAppConfig(t *testing.T) { func TestCreateAppConfig(t *testing.T) {

View File

@ -1,6 +1,7 @@
package service package service
import ( import (
"context"
"fmt" "fmt"
"time" "time"
@ -8,7 +9,6 @@ import (
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/kolide/kolide/server/websocket" "github.com/kolide/kolide/server/websocket"
"github.com/pkg/errors" "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) { func (svc service) NewDistributedQueryCampaign(ctx context.Context, queryString string, hosts []uint, labels []uint) (*kolide.DistributedQueryCampaign, error) {

View File

@ -2,6 +2,7 @@ package service
import ( import (
"bytes" "bytes"
"context"
"crypto/tls" "crypto/tls"
"crypto/x509" "crypto/x509"
"encoding/pem" "encoding/pem"
@ -10,7 +11,6 @@ import (
"net/url" "net/url"
"github.com/pkg/errors" "github.com/pkg/errors"
"golang.org/x/net/context"
) )
// Certificate returns the PEM encoded certificate chain for osqueryd TLS termination. // Certificate returns the PEM encoded certificate chain for osqueryd TLS termination.

View File

@ -1,8 +1,9 @@
package service package service
import ( import (
"context"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
func (svc service) ListHosts(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Host, error) { func (svc service) ListHosts(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Host, error) {

View File

@ -1,13 +1,13 @@
package service package service
import ( import (
"context"
"testing" "testing"
"github.com/kolide/kolide/server/config" "github.com/kolide/kolide/server/config"
"github.com/kolide/kolide/server/datastore/inmem" "github.com/kolide/kolide/server/datastore/inmem"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"golang.org/x/net/context"
) )
func TestListHosts(t *testing.T) { func TestListHosts(t *testing.T) {

View File

@ -1,13 +1,13 @@
package service package service
import ( import (
"context"
"errors" "errors"
"strconv" "strconv"
"strings" "strings"
"github.com/kolide/kolide/server/contexts/viewer" "github.com/kolide/kolide/server/contexts/viewer"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
func (svc service) ImportConfig(ctx context.Context, cfg *kolide.ImportConfig) (*kolide.ImportConfigResponse, error) { func (svc service) ImportConfig(ctx context.Context, cfg *kolide.ImportConfig) (*kolide.ImportConfigResponse, error) {

View File

@ -1,11 +1,11 @@
package service package service
import ( import (
"context"
"encoding/base64" "encoding/base64"
"html/template" "html/template"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
func (svc service) InviteNewUser(ctx context.Context, payload kolide.InvitePayload) (*kolide.Invite, error) { func (svc service) InviteNewUser(ctx context.Context, payload kolide.InvitePayload) (*kolide.Invite, error) {

View File

@ -1,6 +1,7 @@
package service package service
import ( import (
"context"
"testing" "testing"
"time" "time"
@ -10,7 +11,6 @@ import (
"github.com/kolide/kolide/server/mock" "github.com/kolide/kolide/server/mock"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context"
) )
func TestInviteNewUserMock(t *testing.T) { func TestInviteNewUserMock(t *testing.T) {

View File

@ -1,8 +1,9 @@
package service package service
import ( import (
"context"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
func (svc service) ListLabels(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Label, error) { func (svc service) ListLabels(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Label, error) {

View File

@ -1,6 +1,7 @@
package service package service
import ( import (
"context"
"testing" "testing"
"github.com/kolide/kolide/server/config" "github.com/kolide/kolide/server/config"
@ -9,7 +10,6 @@ import (
"github.com/kolide/kolide/server/mock" "github.com/kolide/kolide/server/mock"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context"
) )
func TestModifyLabel(t *testing.T) { func TestModifyLabel(t *testing.T) {

View File

@ -1,8 +1,9 @@
package service package service
import ( import (
"context"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
func (svc service) License(ctx context.Context) (*kolide.License, error) { func (svc service) License(ctx context.Context) (*kolide.License, error) {

View File

@ -1,6 +1,7 @@
package service package service
import ( import (
"context"
"testing" "testing"
"time" "time"
@ -9,7 +10,6 @@ import (
"github.com/kolide/kolide/server/mock" "github.com/kolide/kolide/server/mock"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context"
) )
func TestLicenseService(t *testing.T) { func TestLicenseService(t *testing.T) {

View File

@ -1,11 +1,11 @@
package service package service
import ( import (
"context"
"time" "time"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/pkg/errors" "github.com/pkg/errors"
"golang.org/x/net/context"
) )
const expectedCheckinIntervalMultiplier = 2 const expectedCheckinIntervalMultiplier = 2

View File

@ -1,6 +1,7 @@
package service package service
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"strconv" "strconv"
@ -12,7 +13,6 @@ import (
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/kolide/kolide/server/pubsub" "github.com/kolide/kolide/server/pubsub"
"github.com/pkg/errors" "github.com/pkg/errors"
"golang.org/x/net/context"
) )
type osqueryError struct { type osqueryError struct {

View File

@ -2,6 +2,7 @@ package service
import ( import (
"bytes" "bytes"
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"strings" "strings"
@ -9,8 +10,6 @@ import (
"testing" "testing"
"time" "time"
"golang.org/x/net/context"
"github.com/WatchBeam/clock" "github.com/WatchBeam/clock"
"github.com/kolide/kolide/server/config" "github.com/kolide/kolide/server/config"
hostctx "github.com/kolide/kolide/server/contexts/host" hostctx "github.com/kolide/kolide/server/contexts/host"

View File

@ -1,9 +1,10 @@
package service package service
import ( import (
"context"
"github.com/kolide/kolide/server/contexts/viewer" "github.com/kolide/kolide/server/contexts/viewer"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
func (svc service) ListPacks(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Pack, error) { func (svc service) ListPacks(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Pack, error) {

View File

@ -1,6 +1,7 @@
package service package service
import ( import (
"context"
"testing" "testing"
"github.com/WatchBeam/clock" "github.com/WatchBeam/clock"
@ -10,7 +11,6 @@ import (
"github.com/kolide/kolide/server/test" "github.com/kolide/kolide/server/test"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context"
) )
func TestListPacks(t *testing.T) { func TestListPacks(t *testing.T) {

View File

@ -1,9 +1,10 @@
package service package service
import ( import (
"context"
"github.com/kolide/kolide/server/contexts/viewer" "github.com/kolide/kolide/server/contexts/viewer"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"golang.org/x/net/context"
) )
func (svc service) ListQueries(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Query, error) { func (svc service) ListQueries(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Query, error) {

View File

@ -1,6 +1,7 @@
package service package service
import ( import (
"context"
"testing" "testing"
"github.com/kolide/kolide/server/config" "github.com/kolide/kolide/server/config"
@ -9,7 +10,6 @@ import (
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context"
) )
func TestListQueries(t *testing.T) { func TestListQueries(t *testing.T) {

View File

@ -1,9 +1,10 @@
package service package service
import ( import (
"context"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/pkg/errors" "github.com/pkg/errors"
"golang.org/x/net/context"
) )
func (svc service) GetScheduledQuery(ctx context.Context, id uint) (*kolide.ScheduledQuery, error) { func (svc service) GetScheduledQuery(ctx context.Context, id uint) (*kolide.ScheduledQuery, error) {

View File

@ -1,6 +1,7 @@
package service package service
import ( import (
"context"
"testing" "testing"
"github.com/kolide/kolide/server/config" "github.com/kolide/kolide/server/config"
@ -9,7 +10,6 @@ import (
"github.com/kolide/kolide/server/test" "github.com/kolide/kolide/server/test"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context"
) )
func TestGetScheduledQueriesInPack(t *testing.T) { func TestGetScheduledQueriesInPack(t *testing.T) {

View File

@ -1,6 +1,7 @@
package service package service
import ( import (
"context"
"crypto/rand" "crypto/rand"
"encoding/base64" "encoding/base64"
"strings" "strings"
@ -10,7 +11,6 @@ import (
"github.com/kolide/kolide/server/contexts/viewer" "github.com/kolide/kolide/server/contexts/viewer"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/pkg/errors" "github.com/pkg/errors"
"golang.org/x/net/context"
) )
func (svc service) Login(ctx context.Context, username, password string) (*kolide.User, string, error) { func (svc service) Login(ctx context.Context, username, password string) (*kolide.User, string, error) {

View File

@ -1,6 +1,7 @@
package service package service
import ( import (
"context"
"testing" "testing"
"time" "time"
@ -10,7 +11,6 @@ import (
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context"
) )
const bcryptCost = 6 const bcryptCost = 6

View File

@ -1,9 +1,10 @@
package service package service
import ( import (
"context"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/pkg/errors" "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) { func (svc service) SearchTargets(ctx context.Context, query string, selectedHostIDs []uint, selectedLabelIDs []uint) (*kolide.TargetSearchResults, error) {

View File

@ -1,6 +1,7 @@
package service package service
import ( import (
"context"
"fmt" "fmt"
"testing" "testing"
"time" "time"
@ -11,7 +12,6 @@ import (
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context"
) )
func TestSearchTargets(t *testing.T) { func TestSearchTargets(t *testing.T) {

View File

@ -1,6 +1,7 @@
package service package service
import ( import (
"context"
"crypto/rand" "crypto/rand"
"encoding/base64" "encoding/base64"
"html/template" "html/template"
@ -9,7 +10,6 @@ import (
"github.com/kolide/kolide/server/contexts/viewer" "github.com/kolide/kolide/server/contexts/viewer"
"github.com/kolide/kolide/server/kolide" "github.com/kolide/kolide/server/kolide"
"github.com/pkg/errors" "github.com/pkg/errors"
"golang.org/x/net/context"
) )
func (svc service) NewUser(ctx context.Context, p kolide.UserPayload) (*kolide.User, error) { func (svc service) NewUser(ctx context.Context, p kolide.UserPayload) (*kolide.User, error) {

View File

@ -1,6 +1,7 @@
package service package service
import ( import (
"context"
"errors" "errors"
"testing" "testing"
"time" "time"
@ -15,7 +16,6 @@ import (
pkg_errors "github.com/pkg/errors" pkg_errors "github.com/pkg/errors"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context"
) )
func TestAuthenticatedUser(t *testing.T) { func TestAuthenticatedUser(t *testing.T) {

Some files were not shown because too many files have changed in this diff Show More