mirror of
https://github.com/go-acme/lego.git
synced 2024-11-25 09:00:57 +02:00
test: force to have a reproducible context for oracle provider tests
This commit is contained in:
parent
6907a39266
commit
f4b153f26f
@ -199,6 +199,9 @@ func TestNewDNSProvider(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNewDNSProviderConfig(t *testing.T) {
|
func TestNewDNSProviderConfig(t *testing.T) {
|
||||||
|
envTest.ClearEnv()
|
||||||
|
defer envTest.RestoreEnv()
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
desc string
|
desc string
|
||||||
compartmentID string
|
compartmentID string
|
||||||
@ -206,8 +209,8 @@ func TestNewDNSProviderConfig(t *testing.T) {
|
|||||||
expected string
|
expected string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
desc: "invalid configuration",
|
desc: "configuration provider error",
|
||||||
configurationProvider: &configProvider{},
|
configurationProvider: mockConfigurationProvider("wrong-secret"),
|
||||||
compartmentID: "123",
|
compartmentID: "123",
|
||||||
expected: "oraclecloud: can not create client, bad configuration: x509: decryption password incorrect",
|
expected: "oraclecloud: can not create client, bad configuration: x509: decryption password incorrect",
|
||||||
},
|
},
|
||||||
@ -217,8 +220,9 @@ func TestNewDNSProviderConfig(t *testing.T) {
|
|||||||
expected: "oraclecloud: OCIConfigProvider is missing",
|
expected: "oraclecloud: OCIConfigProvider is missing",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: "missing CompartmentID",
|
desc: "missing CompartmentID",
|
||||||
expected: "oraclecloud: CompartmentID is missing",
|
configurationProvider: mockConfigurationProvider("secret"),
|
||||||
|
expected: "oraclecloud: CompartmentID is missing",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,6 +274,24 @@ func TestLiveCleanUp(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func mockConfigurationProvider(keyPassphrase string) *configProvider {
|
||||||
|
envTest.Apply(map[string]string{
|
||||||
|
envPrivKey: mustGeneratePrivateKey("secret"),
|
||||||
|
})
|
||||||
|
|
||||||
|
return &configProvider{
|
||||||
|
values: map[string]string{
|
||||||
|
EnvCompartmentOCID: "test",
|
||||||
|
EnvPrivKeyPass: "test",
|
||||||
|
EnvTenancyOCID: "test",
|
||||||
|
EnvUserOCID: "test",
|
||||||
|
EnvPubKeyFingerprint: "test",
|
||||||
|
EnvRegion: "test",
|
||||||
|
},
|
||||||
|
privateKeyPassphrase: keyPassphrase,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func mustGeneratePrivateKey(pwd string) string {
|
func mustGeneratePrivateKey(pwd string) string {
|
||||||
block, err := generatePrivateKey(pwd)
|
block, err := generatePrivateKey(pwd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user