-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove time.now check from authz (#11129)
* Merge pull request from GHSA-2p6r-37p9-89p2 * test: adding authz grant tests * fix TestCLITxGrantAuthorization/Invalid_expiration_time test case * comment out the test * reenable test * master update * update changelog and cli test * fix keeper tests * fix decoder test * cleaning * wip - tests * fix cli test * add a comment * update TestMsgGrantAuthorization * udpate changelog * fix sims * fix sims * update changelog * Update x/authz/authorization_grant.go Co-authored-by: Robert Zaremba <robert@zaremba.ch> Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
- Loading branch information
1 parent
fe9a486
commit 2129506
Showing
16 changed files
with
130 additions
and
81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package authz | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// TODO: remove and use: robert/expect-error | ||
func expecError(r *require.Assertions, expected string, received error) { | ||
if expected == "" { | ||
r.NoError(received) | ||
} else { | ||
r.Error(received) | ||
r.Contains(received.Error(), expected) | ||
} | ||
} | ||
|
||
func TestNewGrant(t *testing.T) { | ||
a := NewGenericAuthorization("some-type") | ||
var tcs = []struct { | ||
title string | ||
a Authorization | ||
blockTime time.Time | ||
expire time.Time | ||
err string | ||
}{ | ||
{"wrong expire time (1)", a, time.Unix(10, 0), time.Unix(8, 0), "expiration must be after"}, | ||
{"wrong expire time (2)", a, time.Unix(10, 0), time.Unix(10, 0), "expiration must be after"}, | ||
{"good expire time (1)", a, time.Unix(10, 0), time.Unix(10, 1), ""}, | ||
{"good expire time (2)", a, time.Unix(10, 0), time.Unix(11, 0), ""}, | ||
} | ||
|
||
for _, tc := range tcs { | ||
tc := tc | ||
t.Run(tc.title, func(t *testing.T) { | ||
_, err := NewGrant(tc.blockTime, tc.a, tc.expire) | ||
expecError(require.New(t), tc.err, err) | ||
}) | ||
} | ||
|
||
} |
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
Oops, something went wrong.