-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add dconfs to control whether generate auth --------- Co-authored-by: zeyu10 <[email protected]>
- Loading branch information
1 parent
06e7f90
commit 6005c38
Showing
4 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...low-impl/src/test/groovy/com/weibo/rill/flow/impl/auth/FlowAuthHeaderGeneratorTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.weibo.rill.flow.impl.auth | ||
|
||
import com.weibo.rill.flow.interfaces.model.task.TaskInfo | ||
import com.weibo.rill.flow.service.dconfs.BizDConfs | ||
import org.springframework.http.HttpHeaders | ||
import spock.lang.Specification | ||
|
||
class FlowAuthHeaderGeneratorTest extends Specification { | ||
BizDConfs bizDConfs = Mock(BizDConfs) | ||
FlowAuthHeaderGenerator flowAuthHeaderGenerator = new FlowAuthHeaderGenerator(bizDConfs: bizDConfs, authSecret: 123, | ||
flowServerHost: "http://127.0.0.1", flowCallbackUri: "/flow/trigger.json") | ||
|
||
def setup() { | ||
bizDConfs.getGenerateAuthHeaderBusinessIds() >> ["business1"] | ||
} | ||
|
||
def "test appendRequestHeader when execution id is null"() { | ||
given: | ||
HttpHeaders httpHeaders = new HttpHeaders() | ||
when: | ||
flowAuthHeaderGenerator.appendRequestHeader(httpHeaders, null, null, Map.of()) | ||
then: | ||
!httpHeaders.get("X-Callback-Url").get(0).contains("sign") | ||
} | ||
|
||
def "test appendRequestHeader when execution id not matches business ids"() { | ||
given: | ||
HttpHeaders httpHeaders = new HttpHeaders() | ||
Map<String, Object> input = new HashMap<>() | ||
when: | ||
flowAuthHeaderGenerator.appendRequestHeader(httpHeaders, "business2", null, input) | ||
then: | ||
!httpHeaders.get("X-Callback-Url").get(0).contains("sign") | ||
} | ||
|
||
def "test appendRequestHeader when execution id matches business ids"() { | ||
given: | ||
HttpHeaders httpHeaders = new HttpHeaders() | ||
Map<String, Object> input = new HashMap<>() | ||
when: | ||
flowAuthHeaderGenerator.appendRequestHeader(httpHeaders, "business1", null, input) | ||
then: | ||
httpHeaders.get("X-Callback-Url").get(0).contains("sign") | ||
} | ||
|
||
def "test appendRequestHeader when execution id not matches business ids but generate_auth is 1"() { | ||
given: | ||
HttpHeaders httpHeaders = new HttpHeaders() | ||
Map<String, Object> input = new HashMap<>() | ||
input.put("generate_auth", "1") | ||
when: | ||
flowAuthHeaderGenerator.appendRequestHeader(httpHeaders, "business2", null, input) | ||
then: | ||
httpHeaders.get("X-Callback-Url").get(0).contains("sign") | ||
} | ||
|
||
def "test appendRequestHeader when execution id not matches business ids but generate_auth is true"() { | ||
given: | ||
HttpHeaders httpHeaders = new HttpHeaders() | ||
Map<String, Object> input = new HashMap<>() | ||
input.put("generate_auth", true) | ||
when: | ||
flowAuthHeaderGenerator.appendRequestHeader(httpHeaders, "business2", new TaskInfo(name: "testTask"), input) | ||
then: | ||
httpHeaders.get("X-Callback-Url").get(0).contains("sign") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters