DEV Community

Max
Max

Posted on

Solved: The Headache of Testing OAuth Integration (Free & Open Source Mock Server)

If you've ever tried to write End-to-End (E2E) tests for an application that relies on "Login with Google/GitHub/Microsoft," you know the pain.

You hit the OAuth button, and suddenly your test runner is fighting with:

  • Two-Factor Authentication (2FA) prompts.
  • Captcha challenges.
  • Rate limits from the provider.
  • "Suspicious login attempt" emails flooding your inbox.

I recently ran into this exact challenge for a project of mine. I went down the rabbit hole searching for a mock server that I could use during E2E testing to verify that my OAuth flow works correctly.

The Problem

Most solutions I found were either:

  1. Paid services (and often expensive for just a simple test).
  2. Complex local setups that required heavy configuration or Docker containers just to mock a single token exchange.

I didn't find anything simple. So, I built it.

Introducing: Open Source OAuth Mock Server

I created a hosted, open-source OAuth mock server that is completely free to use. It is designed to be a drop-in replacement for your real OAuth providers during testing.

Live Server:https://oauth.kogiqa.com/
GitHub Repo: oAuth-mock

How it works

The beauty of this tool is its simplicity. You don't need to change your code logic. You literally just swap the URL.

If your production config looks like this:
AUTH_URL=https://accounts.google.com/o/oauth2/v2/auth

You just change your test environment config to:
AUTH_URL=https://oauth.kogiqa.com/

That's it.

The server simulates a real OAuth provider. It acts as if the user successfully input their credentials and redirects back to your application with the correct authorization code or token structure.

Feature: Custom User Data via URL

One of the most useful features is the ability to customize the "mock" user profile on the fly without changing any server config.

If your test needs to verify that the UI displays the correct username or email, you can simply pass them as GET parameters in the URL:

https://oauth.kogiqa.com/?name=QA_User&email=qa@test.com

When the mock server redirects back to your app, the resulting token/profile data will contain QA_User and qa@test.com instead of generic defaults. This is perfect for testing different user scenarios dynamically.

Supported Providers

Out of the box, it supports simulating:

  • Google
  • Microsoft
  • GitHub
  • Facebook
  • Discord
  • Slack
  • Apple / Generic

Contribute!

This project is open source. If you need a specific OAuth provider that isn't listed, feel free to open a PR or an issue on the repository! I am actively maintaining it and will redeploy the server with new providers as they are added.

Check it out, star the repo, and let me know what you think!

GitHub Repo

Happy Testing!!!

Top comments (0)