Fixes state cert tests (#3596)
Signed-off-by: Elena Kolevska <elena@kolevska.com>
This commit is contained in:
parent
1e095ed25a
commit
2e4fc0bbd9
|
@ -1,4 +1,4 @@
|
|||
version: '2'
|
||||
version: '3'
|
||||
services:
|
||||
sqlserver:
|
||||
image: mcr.microsoft.com/mssql/server:2019-latest
|
||||
|
|
|
@ -133,17 +133,13 @@ func TestAzureCosmosDBStorage(t *testing.T) {
|
|||
"partitionKey": "mypartition",
|
||||
}
|
||||
|
||||
test := func(setMeta, getMeta map[string]string, expectedValue string, expectedErr bool) {
|
||||
test := func(setMeta, getMeta map[string]string, expectedValue string) {
|
||||
// save state, default options: strong, last-write
|
||||
err = client.SaveState(ctx, statestore, stateKey, []byte(stateValue), setMeta)
|
||||
require.NoError(t, err)
|
||||
|
||||
// get state
|
||||
item, err := client.GetState(ctx, statestore, stateKey, getMeta)
|
||||
if expectedErr {
|
||||
require.Error(t, err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, expectedValue, string(item.Value))
|
||||
|
||||
|
@ -153,13 +149,13 @@ func TestAzureCosmosDBStorage(t *testing.T) {
|
|||
}
|
||||
|
||||
// Test with no partition key
|
||||
test(nil, meta1, stateValue, false)
|
||||
test(nil, meta1, stateValue)
|
||||
|
||||
// Test with specific partition key
|
||||
test(meta2, meta2, stateValue, false)
|
||||
test(meta2, meta2, stateValue)
|
||||
|
||||
// Test with incorrect partition key
|
||||
test(meta2, meta1, "", true)
|
||||
test(meta2, meta1, "")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -22,6 +22,9 @@ import (
|
|||
"github.com/dapr/components-contrib/state"
|
||||
"github.com/dapr/go-sdk/client"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
state_memcached "github.com/dapr/components-contrib/state/memcached"
|
||||
"github.com/dapr/components-contrib/tests/certification/embedded"
|
||||
"github.com/dapr/components-contrib/tests/certification/flow"
|
||||
|
@ -31,8 +34,6 @@ import (
|
|||
state_loader "github.com/dapr/dapr/pkg/components/state"
|
||||
dapr_testing "github.com/dapr/dapr/pkg/testing"
|
||||
"github.com/dapr/kit/logger"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -168,7 +169,7 @@ func TestMemcached(t *testing.T) {
|
|||
key := certificationTestPrefix + "_expiresInOneSecondKey"
|
||||
value := "This key will self-destroy in 1 second"
|
||||
|
||||
ttlExpirationTime := 1 * time.Second
|
||||
ttlExpirationTime := 3 * time.Second
|
||||
ttlInSeconds := int(ttlExpirationTime.Seconds())
|
||||
mapOptionsExpiringKey := map[string]string{
|
||||
"ttlInSeconds": strconv.Itoa(ttlInSeconds),
|
||||
|
|
|
@ -60,6 +60,20 @@ const (
|
|||
)
|
||||
|
||||
func TestSqlServer(t *testing.T) {
|
||||
// The default certificate created by the docker container sometimes contains a negative serial number.
|
||||
// A TLS certificate with a negative serial number is invalid, although it was tolerated until 1.22
|
||||
// Since Go 1.23 the default behavior has changed and the certificate is rejected.
|
||||
// This environment variable is used to revert to the old behavior.
|
||||
// Ref: https://github.com/microsoft/mssql-docker/issues/895
|
||||
oldDebugValue := os.Getenv("GODEBUG")
|
||||
err := os.Setenv("GODEBUG", "x509negativeserial=1")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to set GODEBUG environment variable: %v", err)
|
||||
}
|
||||
defer func() {
|
||||
os.Setenv("GODEBUG", oldDebugValue)
|
||||
}()
|
||||
|
||||
ports, err := dapr_testing.GetFreePorts(2)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
Loading…
Reference in New Issue