Skip to content

Commit

Permalink
pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ajermaky committed May 1, 2024
1 parent a11ba3d commit 39e319b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
56 changes: 28 additions & 28 deletions lib/go/edgecontext/edgecontext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,14 +796,14 @@ func TestFromHeader(t *testing.T) {

svc, ok := e.Service()
if !ok {
t.Errorf("Expected service to be true, got false")
t.Fatal("Expected service to be true, got false")
}
if name, ok := svc.Name(); !ok {
t.Error("Failed to get service name")
} else {
if name != expectedServiceName {
t.Errorf("Expected service name %q, got %q", expectedServiceName, name)
}
name, ok := svc.Name()
if !ok {
t.Fatal("Failed to get service name")
}
if name != expectedServiceName {
t.Errorf("Expected service name %q, got %q", expectedServiceName, name)
}

if id, ok := svc.OnBehalfOfID(); ok {
Expand All @@ -814,7 +814,7 @@ func TestFromHeader(t *testing.T) {
t.Errorf("expected no roles, got %q", roles)
}

if svc.IsElevatedAccess() {
if svc.RequestsElevatedAccess() {
t.Errorf("expected no elevated access, got true")
}
})
Expand All @@ -827,33 +827,33 @@ func TestFromHeader(t *testing.T) {

svc, ok := e.Service()
if !ok {
t.Errorf("Expected service to be true, got false")
t.Fatal("Expected service to be true, got false")
}
if name, ok := svc.Name(); !ok {
t.Error("Failed to get service name")
} else {
if name != expectedServiceName {
t.Errorf("Expected service name %q, got %q", expectedServiceName, name)
}
name, ok := svc.Name()
if !ok {
t.Fatal("Failed to get service name")
}
if name != expectedServiceName {
t.Errorf("Expected service name %q, got %q", expectedServiceName, name)
}

if id, ok := svc.OnBehalfOfID(); !ok {
t.Error("Failed to get on behalf of id")
} else {
if id != expectedLoID {
t.Errorf("Expected on behalf of id %q, got %q", expectedLoID, id)
}
id, ok := svc.OnBehalfOfID()
if !ok {
t.Fatal("Failed to get on behalf of id")
}
if id != expectedLoID {
t.Errorf("Expected on behalf of id %q, got %q", expectedLoID, id)
}

if roles, ok := svc.OnBehalfOfRoles(); !ok {
t.Error("Failed to get on behalf of roles")
} else {
if diff := cmp.Diff([]string{"admin"}, roles); diff != "" {
t.Errorf("mismatch (-want +got)\n%s\n", diff)
}
roles, ok := svc.OnBehalfOfRoles()
if !ok {
t.Fatal("Failed to get on behalf of roles")
}
if diff := cmp.Diff([]string{"admin"}, roles); diff != "" {
t.Errorf("mismatch (-want +got)\n%s\n", diff)
}

if !svc.IsElevatedAccess() {
if !svc.RequestsElevatedAccess() {
t.Errorf("expected elevated access, got false")
}
})
Expand Down
4 changes: 2 additions & 2 deletions lib/go/edgecontext/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func (s Service) OnBehalfOfRoles() (roles []string, ok bool) {
return nil, false
}

// IsElevatedAccess returns whether the service requested elevated access.
func (s Service) IsElevatedAccess() bool {
// RequestsElevatedAccess returns whether the service requested elevated access.
func (s Service) RequestsElevatedAccess() bool {
if s.isService() {
return AuthenticationToken(s).ServiceRequestedElevatedAccess
}
Expand Down

0 comments on commit 39e319b

Please sign in to comment.