Skip to content

Commit

Permalink
Added new CTK features
Browse files Browse the repository at this point in the history
  • Loading branch information
cdavernas committed May 20, 2024
1 parent b943a5a commit 0c87072
Show file tree
Hide file tree
Showing 13 changed files with 2,232 additions and 7 deletions.
147 changes: 147 additions & 0 deletions ctk/features/call.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
Feature: Call Task
As an implementer of the workflow DSL
I want to ensure that call tasks can be executed within the workflow
So that my implementation conforms to the expected behavior

# Tests HTTP call using `content` output
# Tests interpolated path parameters
# Tests auto-deserialization when reading response with 'application/json' content type
# Tests output filtering
Scenario: Call HTTP With Content Output
Given a workflow with definition:
"""yaml
document:
dsl: 1.0.0-alpha1
namespace: default
name: http-call-with-content-output
do:
getFirstAvailablePet:
call: http
with:
method: get
endpoint:
uri: https://petstore.swagger.io/v2/pet/findByStatus?status={status}
output:
from: .[0]
"""
And given the workflow input is:
"""yaml
status: available
"""
When the workflow is executed
Then the workflow should complete
And the workflow output should have properties 'id', 'name', 'status'

# Tests HTTP call using `response` output
# Tests interpolated path parameters
# Tests auto-deserialization when reading response with 'application/json' content type
Scenario: Call HTTP With Response Output
Given a workflow with definition:
"""yaml
document:
dsl: 1.0.0-alpha1
namespace: default
name: http-call-with-response-output
do:
getPetById:
call: http
with:
method: get
endpoint:
uri: https://petstore.swagger.io/v2/pet/{petId}
output: response
"""
And given the workflow input is:
"""yaml
petId: 1
"""
When the workflow is executed
Then the workflow should complete
And the workflow output should have properties 'request', 'request.method', 'request.uri', 'request.headers', 'headers', 'statusCode', 'content'
And the workflow output should have properties 'content.id', 'content.name', 'content.status'

# Tests HTTP call using `basic` authentication
# Tests interpolated path parameters
Scenario: Call HTTP Using Basic Authentication
Given a workflow with definition:
"""yaml
document:
dsl: 1.0.0-alpha1
namespace: default
name: http-call-with-basic-auth
do:
getSecuredEndpoint:
call: http
with:
method: get
endpoint:
uri: https://httpbin.org/basic-auth/{username}/{password}
authentication:
basic:
username: ${ .username }
password: ${ .password }
"""
And given the workflow input is:
"""yaml
username: serverless-workflow
password: conformance-test
"""
When the workflow is executed
Then the workflow should complete

# Tests OpenAPI call using `content` output
# Tests output filtering
Scenario: Call OpenAPI With Content Output
Given a workflow with definition:
"""yaml
document:
dsl: 1.0.0-alpha1
namespace: default
name: openapi-call-with-content-output
do:
getPetsByStatus:
call: openapi
with:
document:
uri: https://petstore.swagger.io/v2/swagger.json
operation: findPetsByStatus
parameters:
status: ${ .status }
output:
from: . | length
"""
And given the workflow input is:
"""yaml
status: available
"""
When the workflow is executed
Then the workflow should complete

# Tests OpenAPI call using `response` output
# Tests output filtering
Scenario: Call OpenAPI With Response Output
Given a workflow with definition:
"""yaml
document:
dsl: 1.0.0-alpha1
namespace: default
name: openapi-call-with-response-output
do:
getPetById:
call: openapi
with:
document:
uri: https://petstore.swagger.io/v2/swagger.json
operation: getPetById
parameters:
petId: ${ .petId }
output: response
"""
And given the workflow input is:
"""yaml
petId: 1
"""
When the workflow is executed
Then the workflow should complete
And the workflow output should have properties 'request', 'request.method', 'request.uri', 'request.headers', 'headers', 'statusCode', 'content'
And the workflow output should have properties 'content.id', 'content.name', 'content.status'
59 changes: 59 additions & 0 deletions ctk/features/composite.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Feature: Composite Task
As an implementer of the workflow DSL
I want to ensure that composite tasks can be executed within the workflow
So that my implementation conforms to the expected behavior

# Tests composite tasks with sequential sub tasks
Scenario: Composite Task With Sequential Sub Tasks
Given a workflow with definition:
"""yaml
document:
dsl: 1.0.0-alpha1
namespace: default
name: composite-sequential
do:
setRGB:
execute:
sequentially:
setRed:
set:
colors: ${ .colors + ["red"] }
setGreen:
set:
colors: ${ .colors + ["green"] }
setBlue:
set:
colors: ${ .colors + ["blue"] }
"""
When the workflow is executed
Then the workflow should complete with output:
"""yaml
colors: [ red, green, blue ]
"""

# Tests composite tasks With competing concurrent sub tasks
Scenario: Composite Task With Competing Concurrent Sub Tasks
Given a workflow with definition:
"""yaml
document:
dsl: 1.0.0-alpha1
namespace: default
name: composite-sequential
do:
setRGB:
execute:
concurrently:
setRed:
set:
colors: ${ .colors + ["red"] }
setGreen:
set:
colors: ${ .colors + ["green"] }
setBlue:
set:
colors: ${ .colors + ["blue"] }
compete: true
"""
When the workflow is executed
Then the workflow should complete
And the workflow output should have a 'colors' property containing 1 items
91 changes: 91 additions & 0 deletions ctk/features/data-flow.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
Feature: Data Flow
As an implementer of the workflow DSL
I want to ensure that data flows correctly through the workflow
So that my implementation conforms to the expected behavior

# Tests task input fileting
Scenario: Input Filtering
Given a workflow with definition:
"""yaml
document:
dsl: 1.0.0-alpha1
namespace: default
name: output-filtering
do:
setUsername:
input:
from: .user.claims.subject #filters the input of the task, using only the user's subject
set:
playerId: ${ . }
"""
And given the workflow input is:
"""yaml
user:
claims:
subject: 6AsnRgGEB0q2O7ux9JXFAw
"""
When the workflow is executed
Then the workflow should complete with output:
"""yaml
playerId: 6AsnRgGEB0q2O7ux9JXFAw
"""

# Tests task output filtering
Scenario: Output Filteing
Given a workflow with definition:
"""yaml
document:
dsl: 1.0.0-alpha1
namespace: default
name: output-filtering
do:
getPetById:
call: http
with:
method: get
endpoint:
uri: https://petstore.swagger.io/v2/pet/{petId} #simple interpolation, only possible with top level variables
output:
from: .id #filters the output of the http call, using only the id of the returned object
"""
And given the workflow input is:
"""yaml
petId: 1
"""
When the workflow is executed
Then the workflow should complete with output:
"""yaml
1
"""

# Tests using non-object output
Scenario: Use Non-object Output
Given a workflow with definition:
"""yaml
document:
dsl: 1.0.0-alpha1
namespace: default
name: non-object-output
do:
getPetById1:
call: http
with:
method: get
endpoint:
uri: https://petstore.swagger.io/v2/pet/{petId} #simple interpolation, only possible with top level variables
output:
from: .id
getPetById2:
call: http
with:
method: get
endpoint:
uri: https://petstore.swagger.io/v2/pet/2
output:
from: '{ ids: [ $input, .id ] }'
"""
When the workflow is executed
Then the workflow should complete with output:
"""yaml
ids: [ 1, 2 ]
"""
44 changes: 44 additions & 0 deletions ctk/features/emit.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Feature: Emit Task
As an implementer of the workflow DSL
I want to ensure that emit tasks can be executed within the workflow
So that my implementation conforms to the expected behavior

# Tests emit tasks
Scenario: Emit Task
Given a workflow with definition:
"""yaml
document:
dsl: 1.0.0-alpha1
namespace: default
name: emit
do:
emitUserGreeted:
emit:
event:
with:
source: https://fake-source.com
type: com.fake-source.user.greeted.v1
data:
greetings: ${ "Hello \(.user.firstName) \(.user.lastName)!" }
"""
And given the workflow input is:
"""yaml
user:
firstName: John
lastName: Doe
"""
When the workflow is executed
Then the workflow should complete
And the workflow output should have properties 'id', 'specversion', 'time', 'source', 'type', 'data'
And the workflow output should have a 'source' property with value:
"""yaml
https://fake-source.com
"""
And the workflow output should have a 'type' property with value:
"""yaml
com.fake-source.user.greeted.v1
"""
And the workflow output should have a 'data' property with value:
"""yaml
greetings: Hello John Doe!
"""
Loading

0 comments on commit 0c87072

Please sign in to comment.