Jelajahi Sumber

Add scopes method to TestOAuth2AccessTokens

Issue: gh-6025
Josh Cummings 6 tahun lalu
induk
melakukan
39933b10ff

+ 10 - 0
oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/TestOAuth2AccessTokens.java

@@ -18,6 +18,8 @@ package org.springframework.security.oauth2.core;
 
 import java.time.Duration;
 import java.time.Instant;
+import java.util.Arrays;
+import java.util.HashSet;
 
 /**
  * @author Rob Winch
@@ -30,4 +32,12 @@ public class TestOAuth2AccessTokens {
 				Instant.now(),
 				Instant.now().plus(Duration.ofDays(1)));
 	}
+
+	public static OAuth2AccessToken scopes(String... scopes) {
+		return new OAuth2AccessToken(OAuth2AccessToken.TokenType.BEARER,
+				"scopes",
+				Instant.now(),
+				Instant.now().plus(Duration.ofDays(1)),
+				new HashSet<>(Arrays.asList(scopes)));
+	}
 }