-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from eurofurence/issue-94-fixes-part1
Issue 94 fixes part1
- Loading branch information
Showing
14 changed files
with
73 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ func TestNewRBACValidator(t *testing.T) { | |
inputJWT string | ||
inputAPIKey string | ||
inputClaims *common.AllClaims | ||
includeAdminHeader bool | ||
customAdminHeaderValue string | ||
} | ||
|
||
|
@@ -72,67 +71,13 @@ func TestNewRBACValidator(t *testing.T) { | |
EMail: "[email protected]", | ||
}, | ||
}, | ||
includeAdminHeader: true, | ||
}, | ||
expected: expected{ | ||
isAdmin: true, | ||
subject: "123456", | ||
roles: []string{"admin", "test"}, | ||
}, | ||
}, | ||
// TODO remove test case after 2FA is available | ||
// See reference https://github.com/eurofurence/reg-payment-service/issues/57 | ||
{ | ||
name: "Should not create manager with admin role when no admin header is set", | ||
args: args{ | ||
inputJWT: "valid", | ||
inputAPIKey: "", | ||
inputClaims: &common.AllClaims{ | ||
RegisteredClaims: jwt.RegisteredClaims{ | ||
Subject: "123456", | ||
}, | ||
CustomClaims: common.CustomClaims{ | ||
Groups: []string{"admin", "test"}, | ||
Name: "Peter", | ||
EMail: "[email protected]", | ||
}, | ||
}, | ||
includeAdminHeader: false, | ||
}, | ||
expected: expected{ | ||
isAdmin: false, | ||
isRegisteredUser: true, | ||
subject: "123456", | ||
roles: []string{"admin", "test"}, | ||
}, | ||
}, | ||
// TODO remove test case after 2FA is available | ||
// See reference https://github.com/eurofurence/reg-payment-service/issues/57 | ||
{ | ||
name: "Should not create manager with admin role when no valid admin header is set", | ||
args: args{ | ||
inputJWT: "valid", | ||
inputAPIKey: "", | ||
inputClaims: &common.AllClaims{ | ||
RegisteredClaims: jwt.RegisteredClaims{ | ||
Subject: "123456", | ||
}, | ||
CustomClaims: common.CustomClaims{ | ||
Groups: []string{"admin", "test"}, | ||
Name: "Peter", | ||
EMail: "[email protected]", | ||
}, | ||
}, | ||
includeAdminHeader: true, | ||
customAdminHeaderValue: "test-12345", | ||
}, | ||
expected: expected{ | ||
isAdmin: false, | ||
isRegisteredUser: true, | ||
subject: "123456", | ||
roles: []string{"admin", "test"}, | ||
}, | ||
}, | ||
{ | ||
name: "Should create manager with registered user role", | ||
args: args{ | ||
|
@@ -218,9 +163,6 @@ func TestNewRBACValidator(t *testing.T) { | |
|
||
if tt.args.inputClaims != nil { | ||
ctx = context.WithValue(ctx, common.CtxKeyClaims{}, tt.args.inputClaims) | ||
if tt.args.includeAdminHeader { | ||
ctx = context.WithValue(ctx, common.CtxKeyAdminHeader{}, coalesce(tt.args.customAdminHeaderValue, "available")) | ||
} | ||
} | ||
|
||
mgr, err := NewValidator(ctx) | ||
|
Oops, something went wrong.