|
@@ -1,5 +1,5 @@
|
|
|
/*
|
|
|
- * Copyright 2002-2024 the original author or authors.
|
|
|
+ * Copyright 2002-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.
|
|
@@ -16,7 +16,13 @@
|
|
|
|
|
|
package org.springframework.security.oauth2.core;
|
|
|
|
|
|
+import java.util.stream.Stream;
|
|
|
+
|
|
|
+import org.junit.jupiter.api.DynamicTest;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
+import org.junit.jupiter.api.TestFactory;
|
|
|
+
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
|
@@ -69,4 +75,23 @@ public class ClientAuthenticationMethodTests {
|
|
|
.isEqualTo("self_signed_tls_client_auth");
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void valueOfWhenAnyAuthenticationMethodThenConstructs() {
|
|
|
+ String string = new String("any");
|
|
|
+ ClientAuthenticationMethod method = ClientAuthenticationMethod.valueOf(string);
|
|
|
+ assertThat(method.getValue()).isSameAs(string);
|
|
|
+ }
|
|
|
+
|
|
|
+ @TestFactory
|
|
|
+ Stream<DynamicTest> valueOfWhenMatchesStaticThenReturnsStatic() {
|
|
|
+ return Stream.of(ClientAuthenticationMethod.methods())
|
|
|
+ .map((method) -> DynamicTest.dynamicTest(testName(method.getValue()),
|
|
|
+ () -> assertThat(ClientAuthenticationMethod.valueOf(method.getValue())).isSameAs(method)));
|
|
|
+ }
|
|
|
+
|
|
|
+ String testName(String method) {
|
|
|
+ String methodName = StringUtils.capitalize(method.replaceAll("_", ""));
|
|
|
+ return "valueOfWhen" + methodName + "ThenReturnsStatic" + methodName;
|
|
|
+ }
|
|
|
+
|
|
|
}
|