mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 13:55:55 +00:00
5dc8eabcce
* Update SCADA provider version Also update mocks for SCADA provider. * Create SCADA provider w/o HCP config, then update Adds a placeholder config option to allow us to initialize a SCADA provider without the HCP configuration. Also adds an update method to then add the HCP configuration. We need this to be able to eventually always register a SCADA listener at startup before the HCP config values are known. * Pass cloud configuration to HCP manager Save the entire cloud configuration and pass it to the HCP manager. * Update and start SCADA provider in HCP manager Move config updating and starting to the HCP manager. The HCP manager will eventually be responsible for all processes that contribute to linking to HCP.
53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package scada
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hashicorp/consul/agent/hcp/config"
|
|
"github.com/hashicorp/go-hclog"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestUpdateHCPConfig(t *testing.T) {
|
|
for name, tc := range map[string]struct {
|
|
cfg config.CloudConfig
|
|
expectedErr string
|
|
}{
|
|
"Success": {
|
|
cfg: config.CloudConfig{
|
|
ResourceID: "organization/85702e73-8a3d-47dc-291c-379b783c5804/project/8c0547c0-10e8-1ea2-dffe-384bee8da634/hashicorp.consul.global-network-manager.cluster/test",
|
|
ClientID: "test",
|
|
ClientSecret: "test",
|
|
},
|
|
},
|
|
"Empty": {
|
|
cfg: config.CloudConfig{},
|
|
expectedErr: "could not parse resource: unexpected number of tokens 1",
|
|
},
|
|
"InvalidResource": {
|
|
cfg: config.CloudConfig{
|
|
ResourceID: "invalid",
|
|
},
|
|
expectedErr: "could not parse resource: unexpected number of tokens 1",
|
|
},
|
|
} {
|
|
t.Run(name, func(t *testing.T) {
|
|
// Create a provider
|
|
p, err := New(hclog.NewNullLogger())
|
|
require.NoError(t, err)
|
|
|
|
// Update the provider
|
|
err = p.UpdateHCPConfig(tc.cfg)
|
|
if tc.expectedErr != "" {
|
|
require.Error(t, err)
|
|
require.Contains(t, err.Error(), tc.expectedErr)
|
|
return
|
|
}
|
|
require.NoError(t, err)
|
|
})
|
|
}
|
|
}
|