Skip to content

Commit

Permalink
Revert Role fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabhbhatia-stripe committed Oct 10, 2024
1 parent bc38d13 commit a6b1a34
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions pkg/smokescreen/role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ func _testGetRole(t *testing.T, rfr_s string, rfr_e error, allow_missing bool, e
t.Fatalf("expected err %v got %v\n", expect_e, e)
}
if s != expect_s {
t.Fatalf("expected Role %v got %v\n", expect_s, s)
t.Fatalf("expected role %v got %v\n", expect_s, s)
}
}

func TestGetRole(t *testing.T) {
role := "some Role"
role := "some role"
genErr := errors.New("general error")
mre := MissingRoleError("missing Role")
mre := MissingRoleError("missing role")

t.Run("good", func(t *testing.T) {
_testGetRole(t, role, nil, false, role, nil)
Expand All @@ -44,7 +44,7 @@ func TestGetRole(t *testing.T) {
t.Run("missing not allowed -> err", func(t *testing.T) {
_testGetRole(t, "", mre, false, "", mre)
})
t.Run("missing allowed -> empty Role", func(t *testing.T) {
t.Run("missing allowed -> empty role", func(t *testing.T) {
_testGetRole(t, "", mre, true, "", nil)
})
}
16 changes: 8 additions & 8 deletions pkg/smokescreen/smokescreen.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ const (
LogFieldTraceID = "trace_id"
LogFieldInRemoteX509CN = "inbound_remote_x509_cn"
LogFieldInRemoteX509OU = "inbound_remote_x509_ou"
LogFieldRole = "Role"
LogFieldProject = "Project"
LogFieldRole = "role"
LogFieldProject = "project"
LogFieldContentLength = "content_length"
LogFieldDecisionReason = "decision_reason"
LogFieldEnforceWouldDeny = "enforce_would_deny"
Expand Down Expand Up @@ -938,7 +938,7 @@ func getRole(config *Config, req *http.Request) (string, error) {
"error": err,
"is_missing_role": IsMissingRoleError(err),
"allow_missing_role": config.AllowMissingRole,
}).Error("Unable to get Role for request")
}).Error("Unable to get role for request")
return "", err
}
}
Expand Down Expand Up @@ -981,7 +981,7 @@ func checkACLsForRequest(config *Config, req *http.Request, destination hostport
role, roleErr := getRole(config, req)
if roleErr != nil {
config.MetricsClient.Incr("acl.role_not_determined", 1)
decision.Reason = "Client Role cannot be determined"
decision.Reason = "Client role cannot be determined"
return decision
}

Expand Down Expand Up @@ -1011,7 +1011,7 @@ func checkACLsForRequest(config *Config, req *http.Request, destination hostport
if err != nil {
config.Log.WithFields(logrus.Fields{
"error": err,
"Role": role,
"role": role,
"upstream_proxy_name": req.Header.Get("X-Upstream-Https-Proxy"),
"destination_host": destination.Host,
"kind": "parse_failure",
Expand Down Expand Up @@ -1039,9 +1039,9 @@ func checkACLsForRequest(config *Config, req *http.Request, destination hostport
}

tags := map[string]string{
"Role": decision.Role,
"role": decision.Role,
"def_rule": fmt.Sprintf("%t", ACLDecision.Default),
"Project": ACLDecision.Project,
"project": ACLDecision.Project,
}

switch ACLDecision.Result {
Expand All @@ -1061,7 +1061,7 @@ func checkACLsForRequest(config *Config, req *http.Request, destination hostport
config.MetricsClient.IncrWithTags("acl.allow", tags, 1)
default:
config.Log.WithFields(logrus.Fields{
"Role": role,
"role": role,
"destination": destination.Host,
"action": ACLDecision.Result.String(),
}).Warn("Unknown ACL action")
Expand Down

0 comments on commit a6b1a34

Please sign in to comment.