Browse Source

change operations to operation

pull/20479/head
Xinyi Wang 10 months ago
parent
commit
7057901317
  1. 32
      test/integration/consul-container/test/resource/grpc_forwarding_test.go

32
test/integration/consul-container/test/resource/grpc_forwarding_test.go

@ -36,7 +36,7 @@ func TestClientForwardToServer(t *testing.T) {
}
type testCase struct {
description string
operations []operation
operation operation
aclEnabled bool
tlsEnabled bool
verifyIncoming bool
@ -45,68 +45,58 @@ func TestClientForwardToServer(t *testing.T) {
testCases := []testCase{
{
description: "The apply request should be forwarded to consul server agent",
operations: []operation{
{
operation: operation{
action: applyResource,
includeToken: false,
expectedCode: 0,
expectedMsg: "demo.v2.Artist 'korn' created.",
},
},
aclEnabled: false,
tlsEnabled: false,
verifyIncoming: false,
},
{
description: "The apply request should be denied if missing token when ACL is enabled",
operations: []operation{
{
operation: operation{
action: applyResource,
includeToken: false,
expectedCode: 1,
expectedMsg: "failed getting authorizer: ACL not found",
},
},
aclEnabled: true,
},
{
description: "The apply request should be allowed if providing token when ACL is enabled",
operations: []operation{
{
operation: operation{
action: applyResource,
includeToken: true,
expectedCode: 0,
expectedMsg: "demo.v2.Artist 'korn' created.",
},
},
aclEnabled: true,
tlsEnabled: false,
verifyIncoming: false,
},
{
description: "The apply request should be forwarded to consul server agent when server is in TLS mode",
operations: []operation{
{
operation: operation{
action: applyResource,
includeToken: false,
expectedCode: 0,
expectedMsg: "demo.v2.Artist 'korn' created.",
},
},
aclEnabled: false,
tlsEnabled: true,
verifyIncoming: false,
},
{
description: "The apply request should be forwarded to consul server agent when server and client are in TLS mode",
operations: []operation{
{
operation: operation{
action: applyResource,
includeToken: false,
expectedCode: 0,
expectedMsg: "demo.v2.Artist 'korn' created.",
},
},
aclEnabled: false,
tlsEnabled: true,
verifyIncoming: true,
@ -123,15 +113,13 @@ func TestClientForwardToServer(t *testing.T) {
defer terminate(t, cluster)
// perform actions and validate returned messages
for _, op := range tc.operations {
token := ""
if op.includeToken {
if tc.operation.includeToken {
token = cluster.TokenBootstrap
}
code, res := op.action(t, clientAgent, token, tc.verifyIncoming)
require.Equal(t, op.expectedCode, code)
require.Contains(t, res, op.expectedMsg)
}
code, res := tc.operation.action(t, clientAgent, token, tc.verifyIncoming)
require.Equal(t, tc.operation.expectedCode, code)
require.Contains(t, res, tc.operation.expectedMsg)
})
}
}

Loading…
Cancel
Save