Skip to content
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

Merged
merged 1 commit into from
Dec 12, 2018
Merged

[oauth2] export tests again #1212

merged 1 commit into from
Dec 12, 2018

Conversation

someone1
Copy link
Contributor

@someone1 someone1 commented Dec 7, 2018

Signed-off-by: Prateek Malhotra someone1@gmail.com

Related issue

#1204

Proposed changes

Exporting tests in the oauth2 package again, removed with 3a10df9#diff-88

Checklist

  • I have read the contributing guidelines
  • I confirm that this pull request does not address a security vulnerability. If this pull request addresses a security
    vulnerability, I confirm that I got green light (please contact hi@ory.sh) from the maintainers to push the changes.
  • I signed the Developer's Certificate of Origin
    by signing my commit(s). You can amend your signature to the most recent commit by using git commit --amend -s. If you
    amend the commit, you might need to force push using git push --force HEAD:<branch>. Please be very careful when using
    force push.
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation within the code base (if appropriate)
  • I have documented my changes in the developer guide (if appropriate)

Further comments

Copy link
Contributor Author

@someone1 someone1 left a 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
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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" {
Copy link
Contributor Author

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()
Copy link
Contributor Author

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.

@aeneasr
Copy link
Member

aeneasr commented Dec 8, 2018

Please add comments to the exported functions so we don't go back to making them unexported :)

Signed-off-by: Prateek Malhotra <someone1@gmail.com>
@someone1
Copy link
Contributor Author

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!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect :D

@aeneasr
Copy link
Member

aeneasr commented Dec 12, 2018

Thank you!

@aeneasr aeneasr merged commit 920bd5a into ory:master Dec 12, 2018
@aeneasr aeneasr mentioned this pull request Dec 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants