Skip to content

Commit 4a3a1ba

Browse files
committed
Polish gh-2177
1 parent 5352e34 commit 4a3a1ba

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2024 the original author or authors.
2+
* Copyright 2020-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -63,6 +63,7 @@
6363
import org.springframework.util.StringUtils;
6464

6565
import static org.assertj.core.api.Assertions.assertThat;
66+
import static sample.util.RegisteredClients.deviceMessagingClient;
6667
import static sample.util.RegisteredClients.messagingClient;
6768

6869
/**
@@ -140,7 +141,7 @@ public void deviceAuthorizationWhenJpaCoreServicesAutowiredThenSuccess() throws
140141
assertThat(this.authorizationService).isInstanceOf(JpaOAuth2AuthorizationService.class);
141142
assertThat(this.authorizationConsentService).isInstanceOf(JpaOAuth2AuthorizationConsentService.class);
142143

143-
RegisteredClient registeredClient = messagingClient();
144+
RegisteredClient registeredClient = deviceMessagingClient();
144145
this.registeredClientRepository.save(registeredClient);
145146

146147
DeviceAuthorizationGrantFlow deviceAuthorizationGrantFlow = new DeviceAuthorizationGrantFlow(this.mockMvc);

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2024 the original author or authors.
2+
* Copyright 2020-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -63,6 +63,8 @@
6363
public class RedisTests {
6464
private static final RegisteredClient TEST_MESSAGING_CLIENT = RegisteredClients.messagingClient();
6565

66+
private static final RegisteredClient TEST_DEVICE_MESSAGING_CLIENT = RegisteredClients.deviceMessagingClient();
67+
6668
@Autowired
6769
private MockMvc mockMvc;
6870

@@ -126,7 +128,7 @@ public void deviceAuthorizationWhenRedisCoreServicesAutowiredThenUsed() throws E
126128
assertThat(this.authorizationService).isInstanceOf(RedisOAuth2AuthorizationService.class);
127129
assertThat(this.authorizationConsentService).isInstanceOf(RedisOAuth2AuthorizationConsentService.class);
128130

129-
RegisteredClient registeredClient = TEST_MESSAGING_CLIENT;
131+
RegisteredClient registeredClient = TEST_DEVICE_MESSAGING_CLIENT;
130132

131133
DeviceAuthorizationGrantFlow deviceAuthorizationGrantFlow = new DeviceAuthorizationGrantFlow(this.mockMvc);
132134
deviceAuthorizationGrantFlow.setUsername("user");
@@ -194,6 +196,7 @@ static class RedisServerConfig {
194196
void postConstruct() throws IOException {
195197
this.redisServer.start();
196198
this.registeredClientRepository.save(TEST_MESSAGING_CLIENT);
199+
this.registeredClientRepository.save(TEST_DEVICE_MESSAGING_CLIENT);
197200
}
198201

199202
@PreDestroy

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2023 the original author or authors.
2+
* Copyright 2020-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -46,4 +46,20 @@ public static RegisteredClient messagingClient() {
4646
.build();
4747
}
4848
// @formatter:on
49+
50+
// @formatter:off
51+
public static RegisteredClient deviceMessagingClient() {
52+
return RegisteredClient.withId(UUID.randomUUID().toString())
53+
.clientId("device-messaging-client")
54+
.clientSecret("{noop}secret")
55+
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC)
56+
.authorizationGrantType(AuthorizationGrantType.DEVICE_CODE)
57+
.authorizationGrantType(AuthorizationGrantType.REFRESH_TOKEN)
58+
.scope("message.read")
59+
.scope("message.write")
60+
.clientSettings(ClientSettings.builder().requireAuthorizationConsent(true).build())
61+
.build();
62+
}
63+
// @formatter:on
64+
4965
}

0 commit comments

Comments
 (0)