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

Syntax highlighting in readme #51

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Created by @NickMeves and @egrif during the [Greenhouse Software](https://medium
## Usage

Import the package
```
```go
import "github.com/oauth2-proxy/mockoidc"
```

Expand All @@ -23,7 +23,7 @@ goroutine. It will listen on localhost on a random port.
Then pull its configuration to integrate it with your application. Begin
testing!

```
```go
m, _ := mockoidc.Run()
defer m.Shutdown()

Expand All @@ -43,7 +43,7 @@ cfg := m.Config()
Alternatively, if you provide your own `tls.Config`, the server can run with
TLS:

```
```go
tlsConfig = &tls.Config{
// ...your TLS settings
}
Expand All @@ -58,7 +58,7 @@ The following endpoints are implemented. They can either be pulled from the
OIDC discovery document (`m.Issuer() + "/.well-known/openid-configuration`)
or retrieved directly from the MockOIDC server.

```
```go
m, _ := mockoidc.Run()
defer m.Shutdown()

Expand All @@ -80,7 +80,7 @@ subsequent `token_endpoint` call.

These can be seeded with your own test Users & codes that will be returned:

```
```go
m, _ := mockoidc.Run()
defer m.Shutdown()

Expand All @@ -102,7 +102,7 @@ m.QueueCode("12345")
Arbitrary errors can also be queued for handlers to return instead of their
default behavior:

```
```go
m, err := mockoidc.Run()
defer m.Shutdown()

Expand All @@ -120,14 +120,14 @@ time is completely mutable.

You can override the server's view of `time.Now`

```
```go
mockoidc.NowFunc = func() { //...custom logic }
```

As tests are running, you can fast-forward time to critical test points (e.g.
Access & Refresh Token expirations).

```
```go
m, _ := mockoidc.Run()

m.FastForward(time.Duration(1) * time.Hour)
Expand All @@ -140,7 +140,7 @@ Even though we can fast-forward time, the underlying tokens processed by the

We need to synchronize our timer with theirs:

```
```go
m, _ := mockoidc.Run()
defer m.Shutdown()

Expand All @@ -157,7 +157,7 @@ defer reset()
Everything started up with `mockoidc.Run()` can be done manually giving the
opportunity to finely tune the settings:

```
```go
// Create a fresh RSA Private Key for token signing
rsaKey, _ := rsa.GenerateKey(rand.Reader, 2048)

Expand All @@ -183,7 +183,7 @@ to predefined values (e.g. `clientID`, `clientSecret`, `AccessTTL`,
Additional internal components of the MockOIDC server are public if you need
to tamper with them as well:

```
```go
type MockOIDC struct {
// ...other stuff

Expand All @@ -203,7 +203,7 @@ When configuring the MockOIDC server manually, you have the opportunity to add
custom middleware before starting the server (e.g. request logging, test
validators, etc).

```
```go
m, _ := mockoidc.NewServer(nil)

middleware := func(next http.Handler) http.Handler {
Expand Down