Skip to content

Code demo from a presentation on using OpenID Connect and OAuth in Go, showcasing parallelized testing with WireMock and Testcontainers, as a use case from the Dynatrace.

License

Notifications You must be signed in to change notification settings

AntoniKania/oauth-wiremock-testcontainers-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Testing OpenID Connect and OAuth 2.0 with WireMock & Testcontainers - use case from Dynatrace

Overview

This repository contains demo code that was prepared for a presentation on the use case of open source projects such as WireMock and Testcontainers for testing puroses within Dynatrace. The code demonstrates how to use OpenID Connect and OAuth in Go for authentication and authorization purposes. Specifically, it shows the process of calling the OpenID Connect discovery endpoint to fetch server configurations and then using the token_endpoint value from the response to make a second call to the /token endpoint. This retrieves an access token using the client credentials flow. This setup is designed to run tests in parallel by default, utilizing the t.Parallel() call at the beginning of tests.

overview_paralel

Key Features

  • OpenID Connect Discovery: Automated fetching of server configuration details.
  • OAuth Client Credentials Flow: Secure method to obtain access tokens for microservices.
  • Parallel Test Execution: Speed up testing with Go's parallel execution feature.
  • WireMock Integration: Simulates the authorization server for testing, providing both the well-known and token endpoints.
  • Testcontainers Support: Manages the WireMock server instance within a Docker container directly from the test code.

Running locally

Prerequisites

  • Go: You must have Go installed on your machine. Visit Go's official website for installation instructions.
  • Docker: Required for running the WireMock server instance inside a container. Download Docker from Docker's official website.

Run the tests:

This project is configured to run tests in parallel by default, significantly reducing the test execution time. To run the tests, use the command:

go test ./...

This will automatically start the WireMock server in a Docker container, execute all tests, and then shut down the server.

sequence_diagram

Presentation

For a detailed explanation of the code and its use case within Dynatrace, check out the presentation! :)

About

Code demo from a presentation on using OpenID Connect and OAuth in Go, showcasing parallelized testing with WireMock and Testcontainers, as a use case from the Dynatrace.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages