Browse Source

优化OAuth2

zhouhao 7 years ago
parent
commit
237836e7c0

+ 13 - 2
hsweb-commons/hsweb-commons-service/hsweb-commons-service-oauth2/src/test/java/org/hswebframework/web/service/oauth2/MockOAuth2Request.java

@@ -5,6 +5,7 @@ import org.hswebframework.web.authorization.oauth2.client.request.OAuth2Request;
 import org.hswebframework.web.authorization.oauth2.client.request.TokenExpiredCallBack;
 import org.hswebframework.web.authorization.oauth2.client.response.OAuth2Response;
 
+import java.io.InputStream;
 import java.util.Map;
 import java.util.function.Consumer;
 import java.util.function.Function;
@@ -13,10 +14,10 @@ import java.util.function.Function;
 public class MockOAuth2Request implements OAuth2Request {
 
 
-    private Function<String,OAuth2Response> responseGetter;
+    private Function<String, OAuth2Response> responseGetter;
 
 
-    public MockOAuth2Request(Function<String,OAuth2Response> responseGetter) {
+    public MockOAuth2Request(Function<String, OAuth2Response> responseGetter) {
         this.responseGetter = responseGetter;
     }
 
@@ -42,6 +43,16 @@ public class MockOAuth2Request implements OAuth2Request {
         return this;
     }
 
+    @Override
+    public OAuth2Response upload(String name, InputStream inputStream) {
+        return responseGetter.apply("post");
+    }
+
+    @Override
+    public OAuth2Response upload(String name, InputStream inputStream, String fileName) {
+        return responseGetter.apply("post");
+    }
+
     @Override
     public OAuth2Request requestBody(String value) {
         log.info("set request body :{}", value);

+ 7 - 0
hsweb-commons/hsweb-commons-service/hsweb-commons-service-oauth2/src/test/java/org/hswebframework/web/service/oauth2/MockOAuth2Response.java

@@ -8,6 +8,8 @@ import org.hswebframework.web.authorization.simple.builder.SimpleAuthenticationB
 import org.hswebframework.web.authorization.simple.builder.SimpleDataAccessConfigBuilderFactory;
 import org.hswebframework.web.oauth2.core.ErrorType;
 
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
 import java.util.List;
 import java.util.function.BiConsumer;
 
@@ -18,6 +20,11 @@ public class MockOAuth2Response implements OAuth2Response {
     private ResponseConvertHandler handler = new HswebResponseConvertSupport(new SimpleAuthenticationBuilderFactory(new SimpleDataAccessConfigBuilderFactory()));
 
 
+    @Override
+    public InputStream asStream() {
+        return new ByteArrayInputStream(result.getBytes());
+    }
+
     public MockOAuth2Response(String result) {
         this.result = result;
     }

+ 1 - 0
hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/pom.xml

@@ -69,6 +69,7 @@
             <groupId>org.hswebframework.web</groupId>
             <artifactId>hsweb-authorization-basic</artifactId>
             <version>${project.version}</version>
+            <optional>true</optional>
         </dependency>
     </dependencies>
 </project>

+ 1 - 2
hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/resources/META-INF/spring.factories

@@ -1,4 +1,3 @@
 # Auto Configure
 org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-org.hswebframework.web.oauth2.OAuth2GranterAutoConfiguration,\
-  org.hswebframework.web.oauth2.OAuth2AuthorizationAutoConfiguration
+org.hswebframework.web.oauth2.OAuth2GranterAutoConfiguration

+ 1 - 1
pom.xml

@@ -99,7 +99,7 @@
 
         <hsweb.ezorm.version>3.0.1-SNAPSHOT</hsweb.ezorm.version>
         <hsweb.utils.version>3.0.2</hsweb.utils.version>
-        <hsweb.expands.version>3.0.0</hsweb.expands.version>
+        <hsweb.expands.version>3.0.2-SNAPSHOTS</hsweb.expands.version>
 
         <swagger.version>2.7.0</swagger.version>
     </properties>