Skip to content

Commit

Permalink
re-enable router metrics test
Browse files Browse the repository at this point in the history
  • Loading branch information
deads2k committed Dec 13, 2017
1 parent 1e1b68e commit de921c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 8 additions & 0 deletions pkg/router/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (l Listener) handler() http.Handler {

func (l Listener) authorizeHandler(protected http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
fmt.Printf("#### 1a\n")
if len(l.Username) > 0 || len(l.Password) > 0 {
if u, p, ok := req.BasicAuth(); ok {
if u == l.Username && p == l.Password {
Expand All @@ -62,14 +63,18 @@ func (l Listener) authorizeHandler(protected http.Handler) http.Handler {
}
}

fmt.Printf("#### 1b\n")
user, ok, err := l.Authenticator.AuthenticateRequest(req)
if !ok || err != nil {
fmt.Printf("#### 1c\n")
// older routers will not have permission to check token access review, so treat this
// as an authorization denied if so
if !ok || errors.IsUnauthorized(err) {
fmt.Printf("#### 1d %v\n", err)
glog.V(5).Infof("Unable to authenticate: %v", err)
http.Error(w, "Unable to authenticate due to an error", http.StatusUnauthorized)
} else {
fmt.Printf("#### 1e %v\n", err)
glog.V(3).Infof("Unable to authenticate: %v", err)
http.Error(w, "Unable to authenticate due to an error", http.StatusInternalServerError)
}
Expand Down Expand Up @@ -99,10 +104,13 @@ func (l Listener) authorizeHandler(protected http.Handler) http.Handler {
scopedRecord.User = user
authorized, reason, err := l.Authorizer.Authorize(scopedRecord)
if authorized != authorizer.DecisionAllow || err != nil {
fmt.Printf("#### 1f\n")
if !ok || errors.IsUnauthorized(err) {
fmt.Printf("#### 1g %v\n", err)
glog.V(5).Infof("Unable to authorize: %v", err)
http.Error(w, fmt.Sprintf("Forbidden: %s", reason), http.StatusForbidden)
} else {
fmt.Printf("#### 1h %v\n", err)
glog.V(3).Infof("Unable to authorize: %v", err)
http.Error(w, "Unable to authorize the user due to an error", http.StatusInternalServerError)
}
Expand Down
3 changes: 0 additions & 3 deletions test/extended/util/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,6 @@ var (
// these broke in the rebase, but everything else is working
`should function for intra-pod communication`,
`should function for node-pod communication`,
// consistent 500 errors
"should expose prometheus metrics for a route",
"should expose the profiling endpoints",
// super flaky
"should only deploy the last deployment",

Expand Down

0 comments on commit de921c0

Please sign in to comment.