-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[oauth2] export tests again #1212
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some notes on changes I made and why (wasn't as simple as renaming the file!)
@@ -52,28 +53,80 @@ var defaultRequest = fosite.Request{ | |||
Session: &Session{DefaultSession: &openid.DefaultSession{Subject: "bar"}}, | |||
} | |||
|
|||
func mockRequestForeignKey(t *testing.T, id string, x managerTestSetup, createClient bool) { | |||
var lifespan = time.Hour |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to copy theses out since they're originally found in a _test.go file here: https://github.com/ory/hydra/blob/master/oauth2/handler_test.go#L55
ConsentRequest: cr, Session: new(consent.ConsentRequestSessionData), AuthenticatedAt: time.Now(), | ||
Challenge: id, | ||
RequestedAt: time.Now(), | ||
}) | ||
require.NoError(t, err) | ||
} | ||
|
||
func testHelperUniqueConstraints(m managerTestSetup, storageType string) func(t *testing.T) { | ||
type ManagerTestSetup struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't bother properly naming the exported fields although I could if desired
@@ -141,17 +132,7 @@ func TestManagers(t *testing.T) { | |||
} | |||
|
|||
for k, store := range fositeStores { | |||
if k != "memory" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved these to the exported package to make it easier to track changes to tests.
} | ||
|
||
func TestHelperRunner(t *testing.T, store ManagerTestSetup, k string) { | ||
t.Helper() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marked this function as a Helper
since its function name would be useless in any stack output when running tests.
Please add comments to the exported functions so we don't go back to making them unexported :) |
29add95
to
8a3d031
Compare
Signed-off-by: Prateek Malhotra <someone1@gmail.com>
8a3d031
to
86bc691
Compare
This should be good to merge, let me know if there's any other changes you'd like made! |
} | ||
|
||
// TestHelperRunner is used to run the database suite of tests in this package. | ||
// KEEP EXPORTED AND AVAILABLE FOR THIRD PARTIES TO TEST PLUGINS! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect :D
Thank you! |
Signed-off-by: Prateek Malhotra someone1@gmail.com
Related issue
#1204
Proposed changes
Exporting tests in the
oauth2
package again, removed with 3a10df9#diff-88Checklist
vulnerability, I confirm that I got green light (please contact hi@ory.sh) from the maintainers to push the changes.
by signing my commit(s). You can amend your signature to the most recent commit by using
git commit --amend -s
. If youamend the commit, you might need to force push using
git push --force HEAD:<branch>
. Please be very careful when usingforce push.
Further comments