-
Notifications
You must be signed in to change notification settings - Fork 55
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
Setup mocks #35
Merged
Merged
Setup mocks #35
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# project artifacts | ||
auth0 | ||
/auth0 | ||
|
||
# Swap | ||
[._]*.s[a-v][a-z] | ||
|
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//go:generate mockgen -source=actions.go -destination=actions_mock.go -package=auth0 | ||
package auth0 | ||
|
||
import "gopkg.in/auth0.v5/management" | ||
|
||
type ActionAPI interface { | ||
Create(a *management.Action) error | ||
Read(id string) (*management.Action, error) | ||
Update(id string, a *management.Action) error | ||
Delete(id string, opts ...management.RequestOption) error | ||
List(opts ...management.RequestOption) (c *management.ActionList, err error) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 auth0 | ||
|
||
import ( | ||
"gopkg.in/auth0.v5" | ||
"gopkg.in/auth0.v5/management" | ||
) | ||
|
||
// API mimics `management.Management`s general interface, except it refers to | ||
// the interfaces instead of the concrete structs. | ||
type API struct { | ||
Action ActionAPI | ||
Client ClientAPI | ||
Connection ConnectionAPI | ||
Log LogAPI | ||
Rule RuleAPI | ||
ResourceServer ResourceServerAPI | ||
} | ||
|
||
func NewAPI(m *management.Management) *API { | ||
return &API{ | ||
Action: m.Action, | ||
Client: m.Client, | ||
Connection: m.Connection, | ||
Log: m.Log, | ||
ResourceServer: m.ResourceServer, | ||
Rule: m.Rule, | ||
} | ||
} | ||
|
||
// Alias all the helper methods so we can keep just typing `auth0.Bool` and the | ||
// compiler can autocomplete our internal package. | ||
var ( | ||
Bool = auth0.Bool | ||
BoolValue = auth0.BoolValue | ||
String = auth0.String | ||
StringValue = auth0.StringValue | ||
Int = auth0.Int | ||
IntValue = auth0.IntValue | ||
Float64 = auth0.Float64 | ||
Float64Value = auth0.Float64Value | ||
Time = auth0.Time | ||
TimeValue = auth0.TimeValue | ||
) |
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,26 @@ | ||
//go:generate mockgen -source=client.go -destination=client_mock.go -package=auth0 | ||
|
||
package auth0 | ||
|
||
import "gopkg.in/auth0.v5/management" | ||
|
||
type ClientAPI interface { | ||
// Create a new client application. | ||
Create(c *management.Client, opts ...management.RequestOption) (err error) | ||
|
||
// Read a client by its id. | ||
Read(id string, opts ...management.RequestOption) (c *management.Client, err error) | ||
|
||
// List all client applications. | ||
List(opts ...management.RequestOption) (c *management.ClientList, err error) | ||
|
||
// Update a client. | ||
Update(id string, c *management.Client, opts ...management.RequestOption) (err error) | ||
|
||
// RotateSecret rotates a client secret. | ||
RotateSecret(id string, opts ...management.RequestOption) (c *management.Client, err error) | ||
|
||
// Delete a client and all its related assets (like rules, connections, etc) | ||
// given its id. | ||
Delete(id string, opts ...management.RequestOption) error | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why not pass the token details instead and make the client directly here?
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.
It's basically because the management constructor having a plethora of options and encoding that vs catching a fully formed struct being easier