Backport test fix from ent. (#15279)

This commit is contained in:
Derek Menteer 2022-11-07 12:17:46 -06:00 committed by GitHub
parent 985a4ee1b1
commit c064ddf606
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 0 deletions

View File

@ -193,6 +193,9 @@ type verifyWatchRequest func(t testing.TB, request any)
func genVerifyDCSpecificWatch(expectedDatacenter string) verifyWatchRequest { func genVerifyDCSpecificWatch(expectedDatacenter string) verifyWatchRequest {
return func(t testing.TB, request any) { return func(t testing.TB, request any) {
reqReal, ok := request.(*structs.DCSpecificRequest) reqReal, ok := request.(*structs.DCSpecificRequest)
reqReal.QueryOptions = structs.QueryOptions{
Token: aclToken,
}
require.True(t, ok) require.True(t, ok)
require.Equal(t, aclToken, reqReal.Token) require.Equal(t, aclToken, reqReal.Token)
require.Equal(t, expectedDatacenter, reqReal.Datacenter) require.Equal(t, expectedDatacenter, reqReal.Datacenter)
@ -216,6 +219,7 @@ func genVerifyTrustBundleReadWatch(peer string) verifyWatchRequest {
func genVerifyLeafWatchWithDNSSANs(expectedService string, expectedDatacenter string, expectedDNSSANs []string) verifyWatchRequest { func genVerifyLeafWatchWithDNSSANs(expectedService string, expectedDatacenter string, expectedDNSSANs []string) verifyWatchRequest {
return func(t testing.TB, request any) { return func(t testing.TB, request any) {
reqReal, ok := request.(*cachetype.ConnectCALeafRequest) reqReal, ok := request.(*cachetype.ConnectCALeafRequest)
reqReal.Token = aclToken
require.True(t, ok) require.True(t, ok)
require.Equal(t, aclToken, reqReal.Token) require.Equal(t, aclToken, reqReal.Token)
require.Equal(t, expectedDatacenter, reqReal.Datacenter) require.Equal(t, expectedDatacenter, reqReal.Datacenter)
@ -240,6 +244,9 @@ func genVerifyTrustBundleListWatch(service string) verifyWatchRequest {
func genVerifyTrustBundleListWatchForMeshGateway(partition string) verifyWatchRequest { func genVerifyTrustBundleListWatchForMeshGateway(partition string) verifyWatchRequest {
return func(t testing.TB, request any) { return func(t testing.TB, request any) {
reqReal, ok := request.(*cachetype.TrustBundleListRequest) reqReal, ok := request.(*cachetype.TrustBundleListRequest)
reqReal.QueryOptions = structs.QueryOptions{
Token: aclToken,
}
require.True(t, ok) require.True(t, ok)
require.Equal(t, string(structs.ServiceKindMeshGateway), reqReal.Request.Kind) require.Equal(t, string(structs.ServiceKindMeshGateway), reqReal.Request.Kind)
require.True(t, acl.EqualPartitions(partition, reqReal.Request.Partition), "%q != %q", partition, reqReal.Request.Partition) require.True(t, acl.EqualPartitions(partition, reqReal.Request.Partition), "%q != %q", partition, reqReal.Request.Partition)
@ -281,6 +288,9 @@ func genVerifyResolvedConfigWatch(expectedService string, expectedDatacenter str
func genVerifyIntentionWatch(expectedService string, expectedDatacenter string) verifyWatchRequest { func genVerifyIntentionWatch(expectedService string, expectedDatacenter string) verifyWatchRequest {
return func(t testing.TB, request any) { return func(t testing.TB, request any) {
reqReal, ok := request.(*structs.ServiceSpecificRequest) reqReal, ok := request.(*structs.ServiceSpecificRequest)
reqReal.QueryOptions = structs.QueryOptions{
Token: aclToken,
}
require.True(t, ok) require.True(t, ok)
require.Equal(t, aclToken, reqReal.Token) require.Equal(t, aclToken, reqReal.Token)
require.Equal(t, expectedDatacenter, reqReal.Datacenter) require.Equal(t, expectedDatacenter, reqReal.Datacenter)
@ -291,6 +301,9 @@ func genVerifyIntentionWatch(expectedService string, expectedDatacenter string)
func genVerifyPreparedQueryWatch(expectedName string, expectedDatacenter string) verifyWatchRequest { func genVerifyPreparedQueryWatch(expectedName string, expectedDatacenter string) verifyWatchRequest {
return func(t testing.TB, request any) { return func(t testing.TB, request any) {
reqReal, ok := request.(*structs.PreparedQueryExecuteRequest) reqReal, ok := request.(*structs.PreparedQueryExecuteRequest)
reqReal.QueryOptions = structs.QueryOptions{
Token: aclToken,
}
require.True(t, ok) require.True(t, ok)
require.Equal(t, aclToken, reqReal.Token) require.Equal(t, aclToken, reqReal.Token)
require.Equal(t, expectedDatacenter, reqReal.Datacenter) require.Equal(t, expectedDatacenter, reqReal.Datacenter)
@ -302,6 +315,9 @@ func genVerifyPreparedQueryWatch(expectedName string, expectedDatacenter string)
func genVerifyDiscoveryChainWatch(expected *structs.DiscoveryChainRequest) verifyWatchRequest { func genVerifyDiscoveryChainWatch(expected *structs.DiscoveryChainRequest) verifyWatchRequest {
return func(t testing.TB, request any) { return func(t testing.TB, request any) {
reqReal, ok := request.(*structs.DiscoveryChainRequest) reqReal, ok := request.(*structs.DiscoveryChainRequest)
reqReal.QueryOptions = structs.QueryOptions{
Token: aclToken,
}
require.True(t, ok) require.True(t, ok)
require.Equal(t, aclToken, reqReal.Token) require.Equal(t, aclToken, reqReal.Token)
require.Equal(t, expected, reqReal) require.Equal(t, expected, reqReal)
@ -311,6 +327,9 @@ func genVerifyDiscoveryChainWatch(expected *structs.DiscoveryChainRequest) verif
func genVerifyMeshConfigWatch(expectedDatacenter string) verifyWatchRequest { func genVerifyMeshConfigWatch(expectedDatacenter string) verifyWatchRequest {
return func(t testing.TB, request any) { return func(t testing.TB, request any) {
reqReal, ok := request.(*structs.ConfigEntryQuery) reqReal, ok := request.(*structs.ConfigEntryQuery)
reqReal.QueryOptions = structs.QueryOptions{
Token: aclToken,
}
require.True(t, ok) require.True(t, ok)
require.Equal(t, aclToken, reqReal.Token) require.Equal(t, aclToken, reqReal.Token)
require.Equal(t, expectedDatacenter, reqReal.Datacenter) require.Equal(t, expectedDatacenter, reqReal.Datacenter)
@ -338,6 +357,9 @@ func genVerifyServiceSpecificRequest(expectedService, expectedFilter, expectedDa
func genVerifyServiceSpecificPeeredRequest(expectedService, expectedFilter, expectedDatacenter, expectedPeer string, connect bool) verifyWatchRequest { func genVerifyServiceSpecificPeeredRequest(expectedService, expectedFilter, expectedDatacenter, expectedPeer string, connect bool) verifyWatchRequest {
return func(t testing.TB, request any) { return func(t testing.TB, request any) {
reqReal, ok := request.(*structs.ServiceSpecificRequest) reqReal, ok := request.(*structs.ServiceSpecificRequest)
reqReal.QueryOptions = structs.QueryOptions{
Token: aclToken,
}
require.True(t, ok) require.True(t, ok)
require.Equal(t, aclToken, reqReal.Token) require.Equal(t, aclToken, reqReal.Token)
require.Equal(t, expectedDatacenter, reqReal.Datacenter) require.Equal(t, expectedDatacenter, reqReal.Datacenter)