File tree Expand file tree Collapse file tree 3 files changed +25
-5
lines changed
docs/src/test/java/sample Expand file tree Collapse file tree 3 files changed +25
-5
lines changed Original file line number Diff line number Diff line change 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.
6363import org .springframework .util .StringUtils ;
6464
6565import static org .assertj .core .api .Assertions .assertThat ;
66+ import static sample .util .RegisteredClients .deviceMessagingClient ;
6667import 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 );
Original file line number Diff line number Diff line change 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.
6363public 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
Original file line number Diff line number Diff line change 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}
You can’t perform that action at this time.
0 commit comments