builder/triton: Better AccessConfig tests

This commit adds an actual public/private key pair for testing since
these are now validated.
This commit is contained in:
James Nugent 2017-04-26 12:19:36 -07:00
parent d46a8593ae
commit c1cad8726b
2 changed files with 35 additions and 14 deletions

View File

@ -5,39 +5,60 @@ import (
)
func TestAccessConfig_Prepare(t *testing.T) {
ac := testAccessConfig(t)
ac := testAccessConfig()
errs := ac.Prepare(nil)
if errs != nil {
t.Fatal("should not error")
}
ac = testAccessConfig(t)
ac = testAccessConfig()
ac.Account = ""
errs = ac.Prepare(nil)
if errs == nil {
t.Fatal("should error")
}
ac = testAccessConfig(t)
ac = testAccessConfig()
ac.KeyID = ""
errs = ac.Prepare(nil)
if errs == nil {
t.Fatal("should error")
}
ac = testAccessConfig(t)
ac.KeyMaterial = ""
errs = ac.Prepare(nil)
if errs == nil {
t.Fatal("should error")
}
}
func testAccessConfig(t *testing.T) AccessConfig {
func testAccessConfig() AccessConfig {
return AccessConfig{
Endpoint: "test-endpoint",
Account: "test-account",
KeyID: "test-id",
KeyMaterial: "test-private-key",
KeyID: "c5:9d:37:d2:28:d3:ef:39:1b:0a:0e:37:d5:b4:7c:59",
KeyMaterial: testKeyMaterial,
}
}
const testKeyMaterial = `-----BEGIN RSA PRIVATE KEY-----
MIIEpgIBAAKCAQEAuujYxDCBu9W6es650mLcy9RaLGqjHT2KXPs4fHVr1sfBxPDk
ChpekrVEfE69wpf7/oduQwLmBTIBBNtr/aH5e8gt2uCe1kD6swjnAG+nWZB63/BW
XF9zFFE/Vs/dOyHIkqoLhVHurYYFBGqDXH4w1N02vfyQaH/VQDumF9ZiH6b9u28/
WtrHSLPeGidgrt3csh0Q4Bydm2xSCx4Kfeouv0rM25mFoiq/QaTXkfWS0sIzrhhU
rXL4N6B8tBRojHghpjh8LjG4ufJ7Q0QMWfeBfTqQ9llaEtiMIBznyq+oF7vwv0pc
Cw2eXcURfg/9e5M8S3gSthkqGN9NjQUSeNsgCQIDAQABAoIBAQCcy6zcmFyc+GTh
lP5psanMDC5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W34Y1gvMlwSDodlUk0v8rUHAK4bO
TKvdCYbxCQ+kqAFlicY1ZwxoeJzW6k3K+kJ+qWBn0yH4W61M8uKOIvciu1w1CXxG
XZHg281yLxOfJj9YnPG73+sZFucyhtNPiq/1pR4tpm6YLMk8KSTy7XU5
-----END RSA PRIVATE KEY-----`

View File

@ -6,7 +6,7 @@ import (
func testConfig(t *testing.T) Config {
return Config{
AccessConfig: testAccessConfig(t),
AccessConfig: testAccessConfig(),
SourceMachineConfig: testSourceMachineConfig(t),
TargetImageConfig: testTargetImageConfig(t),
}