From fcef640c1b8a4737843f3da8ba90afeaa04115ec Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 22 May 2025 16:22:12 -0700 Subject: [PATCH] Smoke tests against Spring Boot 3.5.1 snapshots --- gradle.properties | 2 +- .../oauth2authorizationserver/TempTests.java | 56 +++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 security/security-oauth2-authorization-server/src/appTest/java/com/example/security/oauth2authorizationserver/TempTests.java diff --git a/gradle.properties b/gradle.properties index ef3142cc..affbb41f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,6 +7,6 @@ reachabilityMetadataVersion=0.3.20 kotlinVersion=1.9.24 javaFormatVersion=0.0.39 nbtVersion=0.10.3 -springBootVersion=3.5.0-SNAPSHOT +springBootVersion=3.5.1-SNAPSHOT springCloudVersion=2025.0.0-SNAPSHOT springBootGeneration=3.5.x diff --git a/security/security-oauth2-authorization-server/src/appTest/java/com/example/security/oauth2authorizationserver/TempTests.java b/security/security-oauth2-authorization-server/src/appTest/java/com/example/security/oauth2authorizationserver/TempTests.java new file mode 100644 index 00000000..4afcab9e --- /dev/null +++ b/security/security-oauth2-authorization-server/src/appTest/java/com/example/security/oauth2authorizationserver/TempTests.java @@ -0,0 +1,56 @@ +/* + * Copyright 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.security.oauth2authorizationserver; + +import java.util.function.Consumer; + +import org.junit.jupiter.api.Test; + +import org.springframework.http.HttpHeaders; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.client.WebClient; + +/** + * @author pwebb + */ +public class TempTests { + + @Test + void performTokenRequestWhenInvalidClientCredentialsThenUnauthorized() { + WebClient client = WebClient.create("http://localhost:8080"); + // @formatter:off + MultiValueMap formData = new LinkedMultiValueMap<>(); + formData.add("grant_type", "client_credentials"); + formData.add("scope", "message:read"); + System.out.println( + client.post().uri("/oauth2/token").headers(badCredentials()) + .body(BodyInserters.fromFormData(formData)) + .exchange().block().statusCode()); + + +// .expectStatus().isUnauthorized() +// .expectBody().jsonPath("$.error").isEqualTo("invalid_client"); + // @formatter:on + } + + private static Consumer badCredentials() { + return (headers) -> headers.setBasicAuth("bad", "password"); + } + +}