Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

Commit

Permalink
chore: update common to fad7388 (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
dipak-pawar authored Nov 27, 2018
1 parent 51b9098 commit 53398f8
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 29 deletions.
17 changes: 12 additions & 5 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ required = [

[[constraint]]
name = "github.com/fabric8-services/fabric8-common"
revision = "9830c6e8180475290fef242884f088e9c7ce16c0"
revision = "fad7388b32f4fed868290b465b3c81dbf83cfba1"
24 changes: 16 additions & 8 deletions configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ const (
// default values as well as to get each value

// General
varHTTPAddress = "http.address"
varMetricsHTTPAddress = "metrics.http.address"
varDeveloperModeEnabled = "developer.mode.enabled"
varCleanTestDataEnabled = "clean.test.data"
varDBLogsEnabled = "enable.db.logs"
defaultConfigFile = "config.yaml"
varLogLevel = "log.level"
varLogJSON = "log.json"
varHTTPAddress = "http.address"
varMetricsHTTPAddress = "metrics.http.address"
varDeveloperModeEnabled = "developer.mode.enabled"
varCleanTestDataEnabled = "clean.test.data"
varCleanTestDataErrorReportingRequired = "error.reporting.required"
varDBLogsEnabled = "enable.db.logs"
defaultConfigFile = "config.yaml"
varLogLevel = "log.level"
varLogJSON = "log.json"

// Postgres
varPostgresHost = "postgres.host"
Expand Down Expand Up @@ -462,6 +463,8 @@ func (c *ConfigurationData) setConfigDefaults() {

// By default, test data should be cleaned from DB, unless explicitly said otherwise.
c.v.SetDefault(varCleanTestDataEnabled, true)
// By default, error should be reported while cleaning test data from DB.
c.v.SetDefault(varCleanTestDataErrorReportingRequired, true)
// By default, DB logs are not output in the console
c.v.SetDefault(varDBLogsEnabled, false)

Expand Down Expand Up @@ -565,6 +568,11 @@ func (c *ConfigurationData) IsCleanTestDataEnabled() bool {
return c.v.GetBool(varCleanTestDataEnabled)
}

// IsCleanTestDataErrorReportingRequired returns `true` if there is any error while cleaning test data after each test. (default: true)
func (c *ConfigurationData) IsCleanTestDataErrorReportingRequired() bool {
return c.v.GetBool(varCleanTestDataErrorReportingRequired)
}

// IsDBLogsEnabled returns `true` if the DB logs (ie, SQL queries) should be output in the console. (default: false)
func (c *ConfigurationData) IsDBLogsEnabled() bool {
return c.v.GetBool(varDBLogsEnabled)
Expand Down
6 changes: 3 additions & 3 deletions controller/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package controller
import (
"github.com/fabric8-services/fabric8-cluster/app"
"github.com/fabric8-services/fabric8-cluster/configuration"
"github.com/fabric8-services/fabric8-common/auth"
"github.com/fabric8-services/fabric8-common/errors"
"github.com/fabric8-services/fabric8-common/httpsupport"
"github.com/fabric8-services/fabric8-common/log"
"github.com/fabric8-services/fabric8-common/token"

"github.com/goadesign/goa"
)
Expand All @@ -31,7 +31,7 @@ func NewClustersController(service *goa.Service, config clusterConfiguration) *C

// Show returns the list of available OSO clusters.
func (c *ClustersController) Show(ctx *app.ShowClustersContext) error {
if !token.IsSpecificServiceAccount(ctx, token.OsoProxy, token.Tenant, token.JenkinsIdler, token.JenkinsProxy, token.Auth) {
if !auth.IsSpecificServiceAccount(ctx, auth.OsoProxy, auth.Tenant, auth.JenkinsIdler, auth.JenkinsProxy, auth.Auth) {
log.Error(ctx, nil, "unauthorized access to cluster info")
return app.JSONErrorResponse(ctx, errors.NewUnauthorizedError("unauthorized access to cluster info"))
}
Expand All @@ -58,7 +58,7 @@ func (c *ClustersController) Show(ctx *app.ShowClustersContext) error {
// ShowAuthClient returns the list of available OSO clusters with full configuration including Auth client data.
// To be used by Auth service only
func (c *ClustersController) ShowAuthClient(ctx *app.ShowAuthClientClustersContext) error {
if !token.IsSpecificServiceAccount(ctx, token.Auth) {
if !auth.IsSpecificServiceAccount(ctx, auth.Auth) {
log.Error(ctx, nil, "unauthorized access to cluster info")
return app.JSONErrorResponse(ctx, errors.NewUnauthorizedError("unauthorized access to cluster info"))
}
Expand Down
11 changes: 5 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@ import (
"runtime"
"time"

"context"
"github.com/fabric8-services/fabric8-cluster/app"
"github.com/fabric8-services/fabric8-cluster/application/transaction"
"github.com/fabric8-services/fabric8-cluster/configuration"
"github.com/fabric8-services/fabric8-cluster/controller"
"github.com/fabric8-services/fabric8-cluster/gormapplication"
"github.com/fabric8-services/fabric8-cluster/migration"
"github.com/fabric8-services/fabric8-cluster/sentry"
"github.com/fabric8-services/fabric8-common/auth"
"github.com/fabric8-services/fabric8-common/goamiddleware"
"github.com/fabric8-services/fabric8-common/log"
"github.com/fabric8-services/fabric8-common/token"

"context"
"github.com/fabric8-services/fabric8-cluster/gormapplication"
"github.com/goadesign/goa"
"github.com/goadesign/goa/logging/logrus"
"github.com/goadesign/goa/middleware"
Expand Down Expand Up @@ -156,7 +155,7 @@ func main() {
defer haltWatcher()

// Setup Security
tokenManager, err := token.DefaultManager(config)
tokenManager, err := auth.DefaultManager(config)
if err != nil {
log.Panic(nil, map[string]interface{}{
"err": err,
Expand All @@ -166,7 +165,7 @@ func main() {
jwtMiddlewareTokenContext := goamiddleware.TokenContext(tokenManager, app.NewJWTSecurity())
service.Use(jwtMiddlewareTokenContext)

service.Use(token.InjectTokenManager(tokenManager))
service.Use(auth.InjectTokenManager(tokenManager))
service.Use(log.LogRequest(config.DeveloperModeEnabled()))
app.UseJWTMiddleware(service, jwt.New(tokenManager.PublicKeys(), nil, app.NewJWTSecurity()))

Expand Down
4 changes: 2 additions & 2 deletions sentry/sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"fmt"

"github.com/fabric8-services/fabric8-common/auth"
"github.com/fabric8-services/fabric8-common/sentry"
"github.com/fabric8-services/fabric8-common/token"

"github.com/getsentry/raven-go"
"github.com/goadesign/goa/middleware/security/jwt"
Expand All @@ -29,7 +29,7 @@ func Initialize(config configuration, commit string) (func(), error) {

func extractUserInfo() func(ctx context.Context) (*raven.User, error) {
return func(ctx context.Context) (*raven.User, error) {
m, err := token.ReadManagerFromContext(ctx)
m, err := auth.ReadManagerFromContext(ctx)
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions sentry/sentry_whitebox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"testing"

testsuite "github.com/fabric8-services/fabric8-cluster/test/suite"
"github.com/fabric8-services/fabric8-common/test/auth"
"github.com/fabric8-services/fabric8-common/token"
"github.com/fabric8-services/fabric8-common/auth"
testauth "github.com/fabric8-services/fabric8-common/test/auth"

"github.com/dgrijalva/jwt-go"
"github.com/getsentry/raven-go"
Expand All @@ -24,7 +24,7 @@ type TestWhiteboxSentry struct {
}

func failOnNoToken(t *testing.T) context.Context {
return token.ContextWithTokenManager(context.Background(), auth.TokenManager)
return auth.ContextWithTokenManager(context.Background(), testauth.TokenManager)
}

func failOnParsingToken(t *testing.T) context.Context {
Expand All @@ -37,7 +37,7 @@ func failOnParsingToken(t *testing.T) context.Context {

func (s *TestWhiteboxSentry) TestExtractUserInfo() {
f := extractUserInfo()
ctx, identity, err := auth.EmbedUserTokenInContext(nil, nil)
ctx, identity, err := testauth.EmbedUserTokenInContext(nil, nil)
require.NoError(s.T(), err)

tests := []struct {
Expand Down

0 comments on commit 53398f8

Please sign in to comment.