Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

net.uiqui:mock-oauth-server

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

net.uiqui:mock-oauth-server

OAuth2 mocked server for unit tests.

  • 1.1.1
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

OAuth Server Mock

OAuth2 mocked server for unit testing

Features

  • Method for signed JWT creation, with user defined claims
  • Http endpoint for retrieval of public keys

Requirements

  • Java >= 11

Quick Start

Gradle

testImplementation("net.uiqui:mock-oauth-server:1.1.1")

Maven

<dependency>
  <groupId>net.uiqui</groupId>
  <artifactId>mock-oauth-server</artifactId>
  <version>1.1.1</version>
  <scope>test</scope>
</dependency>

How to Use

  1. Create an instance of the OAuthServerMock
private val mockedOauthServer = OAuthServerMock()
  1. Start the server
@BeforeAll
@JvmStatic
fun init() {
    mockedOauthServer.start()
}
  1. Tell your app from where it can download the signing keys
@BeforeEach
fun setUp() {
    every { mockedAuthenticationConfig.jwksEndpoint } returns mockedOauthServer.getJwksUri()
}
  1. Generate a JWT with the required claims
val requiredClaims = mapOf(
    "iss" to "OAuth-Server-Mock",
    "aud" to "this-unit-test",
    "appid" to "ad4fc666-c793-11ec-9d64-0242ac120002"
)
val jwtToken = mockedOauthServer.generateJWT(requiredClaims)
  1. Use the JWT on your request
mockMvc.perform(
    get("/your/endpoint")
        .header(AUTHORIZATION, "Bearer $jwtToken")
)
  1. Shutdown the server
@AfterAll
@JvmStatic
fun cleanUp() {
    mockedOauthServer.shutdown()
}

You can find an example of an application using Spring Boot Security and mock-oauth-server here

License

This project is licensed under the terms of the MIT license

FAQs

Package last updated on 13 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc