Browse Source

Polish gh-2177

pull/2221/head
Joe Grandja 2 months ago
parent
commit
4a3a1baea4
  1. 5
      docs/src/test/java/sample/jpa/JpaTests.java
  2. 7
      docs/src/test/java/sample/redis/RedisTests.java
  3. 18
      docs/src/test/java/sample/util/RegisteredClients.java

5
docs/src/test/java/sample/jpa/JpaTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2020-2024 the original author or authors.
* Copyright 2020-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -63,6 +63,7 @@ import org.springframework.test.web.servlet.MockMvc; @@ -63,6 +63,7 @@ import org.springframework.test.web.servlet.MockMvc;
import org.springframework.util.StringUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static sample.util.RegisteredClients.deviceMessagingClient;
import static sample.util.RegisteredClients.messagingClient;
/**
@ -140,7 +141,7 @@ public class JpaTests { @@ -140,7 +141,7 @@ public class JpaTests {
assertThat(this.authorizationService).isInstanceOf(JpaOAuth2AuthorizationService.class);
assertThat(this.authorizationConsentService).isInstanceOf(JpaOAuth2AuthorizationConsentService.class);
RegisteredClient registeredClient = messagingClient();
RegisteredClient registeredClient = deviceMessagingClient();
this.registeredClientRepository.save(registeredClient);
DeviceAuthorizationGrantFlow deviceAuthorizationGrantFlow = new DeviceAuthorizationGrantFlow(this.mockMvc);

7
docs/src/test/java/sample/redis/RedisTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2020-2024 the original author or authors.
* Copyright 2020-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -63,6 +63,8 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -63,6 +63,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class RedisTests {
private static final RegisteredClient TEST_MESSAGING_CLIENT = RegisteredClients.messagingClient();
private static final RegisteredClient TEST_DEVICE_MESSAGING_CLIENT = RegisteredClients.deviceMessagingClient();
@Autowired
private MockMvc mockMvc;
@ -126,7 +128,7 @@ public class RedisTests { @@ -126,7 +128,7 @@ public class RedisTests {
assertThat(this.authorizationService).isInstanceOf(RedisOAuth2AuthorizationService.class);
assertThat(this.authorizationConsentService).isInstanceOf(RedisOAuth2AuthorizationConsentService.class);
RegisteredClient registeredClient = TEST_MESSAGING_CLIENT;
RegisteredClient registeredClient = TEST_DEVICE_MESSAGING_CLIENT;
DeviceAuthorizationGrantFlow deviceAuthorizationGrantFlow = new DeviceAuthorizationGrantFlow(this.mockMvc);
deviceAuthorizationGrantFlow.setUsername("user");
@ -194,6 +196,7 @@ public class RedisTests { @@ -194,6 +196,7 @@ public class RedisTests {
void postConstruct() throws IOException {
this.redisServer.start();
this.registeredClientRepository.save(TEST_MESSAGING_CLIENT);
this.registeredClientRepository.save(TEST_DEVICE_MESSAGING_CLIENT);
}
@PreDestroy

18
docs/src/test/java/sample/util/RegisteredClients.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2020-2023 the original author or authors.
* Copyright 2020-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -46,4 +46,20 @@ public class RegisteredClients { @@ -46,4 +46,20 @@ public class RegisteredClients {
.build();
}
// @formatter:on
// @formatter:off
public static RegisteredClient deviceMessagingClient() {
return RegisteredClient.withId(UUID.randomUUID().toString())
.clientId("device-messaging-client")
.clientSecret("{noop}secret")
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC)
.authorizationGrantType(AuthorizationGrantType.DEVICE_CODE)
.authorizationGrantType(AuthorizationGrantType.REFRESH_TOKEN)
.scope("message.read")
.scope("message.write")
.clientSettings(ClientSettings.builder().requireAuthorizationConsent(true).build())
.build();
}
// @formatter:on
}

Loading…
Cancel
Save