-
Notifications
You must be signed in to change notification settings - Fork 231
Expand file tree
/
Copy pathsecurity_interceptor_test.go
More file actions
31 lines (25 loc) · 1016 Bytes
/
security_interceptor_test.go
File metadata and controls
31 lines (25 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package workflow_security_interceptor_test
import (
"go.temporal.io/sdk/interceptor"
"go.temporal.io/sdk/worker"
"testing"
"github.com/stretchr/testify/require"
"go.temporal.io/sdk/testsuite"
wsi "github.com/temporalio/samples-go/workflow-security-interceptor"
)
func TestSecurityInterceptorWorkflow(t *testing.T) {
var ts testsuite.WorkflowTestSuite
env := ts.NewTestWorkflowEnvironment()
env.SetWorkerOptions(worker.Options{
Interceptors: []interceptor.WorkerInterceptor{wsi.NewWorkerInterceptor()},
})
env.RegisterWorkflow(wsi.Workflow)
env.RegisterWorkflow(wsi.ChildWorkflow)
env.RegisterWorkflow(wsi.ProhibitedChildWorkflow)
env.RegisterActivity(wsi.ValidateChildWorkflowTypeActivity)
env.ExecuteWorkflow(wsi.Workflow)
err := env.GetWorkflowError()
require.Error(t, err, "expected prohibited child workflow to fail")
require.Contains(t, err.Error(), "Child workflow type \"ProhibitedChildWorkflow\" not allowed",
"expected error to contain prohibited child workflow type message")
}