Skip to content

Commit

Permalink
Add auth0 package
Browse files Browse the repository at this point in the history
  • Loading branch information
cyx committed Jan 26, 2021
1 parent c9f4db1 commit 14507cd
Show file tree
Hide file tree
Showing 14 changed files with 856 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# project artifacts
auth0
/auth0

# Swap
[._]*.s[a-v][a-z]
Expand Down
11 changes: 11 additions & 0 deletions internal/auth0/actions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package auth0

import "gopkg.in/auth0.v5/management"

type ActionsAPI 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)
}
12 changes: 12 additions & 0 deletions internal/auth0/auth0.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package auth0

// API mimics `management.Management`s general interface, except it uses
// methods since we can't really mock fields.
type API interface {
Actions() ActionsAPI
Client() ClientAPI
Connection() ConnectionAPI
Log() LogAPI
Rule() RuleAPI
ResourceServer() ResourceServerAPI
}
26 changes: 26 additions & 0 deletions internal/auth0/client.go
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
}
150 changes: 150 additions & 0 deletions internal/auth0/client_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions internal/auth0/connection.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//go:generate mockgen -source=connection.go -destination=connection_mock.go -package=auth0

package auth0

import "gopkg.in/auth0.v5/management"

type ConnectionAPI interface {
// Create a new connection.
Create(c *management.Connection, opts ...management.RequestOption) error

// Read retrieves a connection by its id.
Read(id string, opts ...management.RequestOption) (c *management.Connection, err error)

// List all connections.
List(opts ...management.RequestOption) (c *management.ConnectionList, err error)

// Update a connection.
Update(id string, c *management.Connection, opts ...management.RequestOption) (err error)

// Delete a connection and all its users.
Delete(id string, opts ...management.RequestOption) (err error)

// ReadByName retrieves a connection by its name. This is a helper method when a
// connection id is not readily available.
ReadByName(name string, opts ...management.RequestOption) (*management.Connection, error)
}
150 changes: 150 additions & 0 deletions internal/auth0/connection_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 14507cd

Please sign in to comment.