Merge pull request #3724 from boumenot/pr-azure-lint
Azure: Lint issues
This commit is contained in:
commit
ddef181e76
|
@ -16,7 +16,7 @@ func getFakeSasUrl(name string) string {
|
|||
func TestArtifactString(t *testing.T) {
|
||||
template := CaptureTemplate{
|
||||
Resources: []CaptureResources{
|
||||
CaptureResources{
|
||||
{
|
||||
Properties: CaptureProperties{
|
||||
StorageProfile: CaptureStorageProfile{
|
||||
OSDisk: CaptureDisk{
|
||||
|
@ -57,7 +57,7 @@ func TestArtifactString(t *testing.T) {
|
|||
func TestArtifactProperties(t *testing.T) {
|
||||
template := CaptureTemplate{
|
||||
Resources: []CaptureResources{
|
||||
CaptureResources{
|
||||
{
|
||||
Properties: CaptureProperties{
|
||||
StorageProfile: CaptureStorageProfile{
|
||||
OSDisk: CaptureDisk{
|
||||
|
@ -97,7 +97,7 @@ func TestArtifactProperties(t *testing.T) {
|
|||
func TestArtifactOverHypenatedCaptureUri(t *testing.T) {
|
||||
template := CaptureTemplate{
|
||||
Resources: []CaptureResources{
|
||||
CaptureResources{
|
||||
{
|
||||
Properties: CaptureProperties{
|
||||
StorageProfile: CaptureStorageProfile{
|
||||
OSDisk: CaptureDisk{
|
||||
|
@ -134,7 +134,7 @@ func TestArtifactRejectMalformedTemplates(t *testing.T) {
|
|||
func TestArtifactRejectMalformedStorageUri(t *testing.T) {
|
||||
template := CaptureTemplate{
|
||||
Resources: []CaptureResources{
|
||||
CaptureResources{
|
||||
{
|
||||
Properties: CaptureProperties{
|
||||
StorageProfile: CaptureStorageProfile{
|
||||
OSDisk: CaptureDisk{
|
||||
|
|
|
@ -228,7 +228,7 @@ func (b *Builder) getServicePrincipalTokens(say func(string)) (*azure.ServicePri
|
|||
var err error
|
||||
|
||||
if b.config.useDeviceLogin {
|
||||
servicePrincipalToken, err = packerAzureCommon.Authenticate(*b.config.cloudEnvironment, b.config.SubscriptionID, b.config.TenantID, say)
|
||||
servicePrincipalToken, err = packerAzureCommon.Authenticate(*b.config.cloudEnvironment, b.config.TenantID, say)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ func (c *Config) toVirtualMachineCaptureParameters() *compute.VirtualMachineCapt
|
|||
func (c *Config) createCertificate() (string, error) {
|
||||
privateKey, err := rsa.GenerateKey(rand.Reader, 2048)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Failed to Generate Private Key: %s", err)
|
||||
err = fmt.Errorf("Failed to Generate Private Key: %s", err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ func (c *Config) createCertificate() (string, error) {
|
|||
|
||||
serialNumber, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 128))
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Failed to Generate Serial Number: %v", err)
|
||||
err = fmt.Errorf("Failed to Generate Serial Number: %v", err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
package arm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -345,7 +344,7 @@ func TestUseDeviceLoginIsDisabledForWindows(t *testing.T) {
|
|||
|
||||
_, _, err := newConfig(config, getPackerConfiguration())
|
||||
if err == nil {
|
||||
t.Fatalf("Expected test to fail, but it succeeded")
|
||||
t.Fatal("Expected test to fail, but it succeeded")
|
||||
}
|
||||
|
||||
multiError, _ := err.(*packer.MultiError)
|
||||
|
@ -465,7 +464,7 @@ func TestConfigShouldRejectMalformedCaptureContainerName(t *testing.T) {
|
|||
func getArmBuilderConfiguration() map[string]string {
|
||||
m := make(map[string]string)
|
||||
for _, v := range requiredConfigValues {
|
||||
m[v] = fmt.Sprintf("ignored00")
|
||||
m[v] = "ignored00"
|
||||
}
|
||||
|
||||
m["communicator"] = "none"
|
||||
|
@ -476,7 +475,7 @@ func getArmBuilderConfiguration() map[string]string {
|
|||
func getArmBuilderConfigurationWithWindows() map[string]string {
|
||||
m := make(map[string]string)
|
||||
for _, v := range requiredConfigValues {
|
||||
m[v] = fmt.Sprintf("ignored00")
|
||||
m[v] = "ignored00"
|
||||
}
|
||||
|
||||
m["object_id"] = "ignored00"
|
||||
|
|
|
@ -97,19 +97,19 @@ func TestStepCaptureImageShouldTakeStepArgumentsFromStateBag(t *testing.T) {
|
|||
var expectedCaptureTemplate = stateBag.Get(constants.ArmCaptureTemplate).(*CaptureTemplate)
|
||||
|
||||
if actualComputeName != expectedComputeName {
|
||||
t.Fatalf("Expected StepCaptureImage to source 'constants.ArmComputeName' from the state bag, but it did not.")
|
||||
t.Fatal("Expected StepCaptureImage to source 'constants.ArmComputeName' from the state bag, but it did not.")
|
||||
}
|
||||
|
||||
if actualResourceGroupName != expectedResourceGroupName {
|
||||
t.Fatalf("Expected StepCaptureImage to source 'constants.ArmResourceGroupName' from the state bag, but it did not.")
|
||||
t.Fatal("Expected StepCaptureImage to source 'constants.ArmResourceGroupName' from the state bag, but it did not.")
|
||||
}
|
||||
|
||||
if actualVirtualMachineCaptureParameters != expectedVirtualMachineCaptureParameters {
|
||||
t.Fatalf("Expected StepCaptureImage to source 'constants.ArmVirtualMachineCaptureParameters' from the state bag, but it did not.")
|
||||
t.Fatal("Expected StepCaptureImage to source 'constants.ArmVirtualMachineCaptureParameters' from the state bag, but it did not.")
|
||||
}
|
||||
|
||||
if actualCaptureTemplate != expectedCaptureTemplate {
|
||||
t.Fatalf("Expected StepCaptureImage to source 'constants.ArmCaptureTemplate' from the state bag, but it did not.")
|
||||
t.Fatal("Expected StepCaptureImage to source 'constants.ArmCaptureTemplate' from the state bag, but it did not.")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,16 +74,16 @@ func TestStepCreateResourceGroupShouldTakeStepArgumentsFromStateBag(t *testing.T
|
|||
var expectedResourceGroupName = stateBag.Get(constants.ArmResourceGroupName).(string)
|
||||
|
||||
if actualResourceGroupName != expectedResourceGroupName {
|
||||
t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.")
|
||||
t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.")
|
||||
}
|
||||
|
||||
if actualLocation != expectedLocation {
|
||||
t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.")
|
||||
t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.")
|
||||
}
|
||||
|
||||
_, ok := stateBag.GetOk(constants.ArmIsResourceGroupCreated)
|
||||
if !ok {
|
||||
t.Fatalf("Expected the step to add item to stateBag['constants.ArmIsResourceGroupCreated'], but it did not.")
|
||||
t.Fatal("Expected the step to add item to stateBag['constants.ArmIsResourceGroupCreated'], but it did not.")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ func TestStepDeleteResourceGroupShouldDeleteStateBagArmResourceGroupCreated(t *t
|
|||
|
||||
value, ok := stateBag.GetOk(constants.ArmIsResourceGroupCreated)
|
||||
if !ok {
|
||||
t.Fatalf("Expected the resource bag value arm.IsResourceGroupCreated to exist")
|
||||
t.Fatal("Expected the resource bag value arm.IsResourceGroupCreated to exist")
|
||||
}
|
||||
|
||||
if value.(bool) {
|
||||
|
|
|
@ -77,11 +77,11 @@ func TestStepDeployTemplateShouldTakeStepArgumentsFromStateBag(t *testing.T) {
|
|||
var expectedResourceGroupName = stateBag.Get(constants.ArmResourceGroupName).(string)
|
||||
|
||||
if actualDeploymentName != expectedDeploymentName {
|
||||
t.Fatalf("Expected StepValidateTemplate to source 'constants.ArmDeploymentName' from the state bag, but it did not.")
|
||||
t.Fatal("Expected StepValidateTemplate to source 'constants.ArmDeploymentName' from the state bag, but it did not.")
|
||||
}
|
||||
|
||||
if actualResourceGroupName != expectedResourceGroupName {
|
||||
t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.")
|
||||
t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,10 +77,10 @@ func TestStepGetCertificateShouldTakeStepArgumentsFromStateBag(t *testing.T) {
|
|||
var expectedKeyVaultName = stateBag.Get(constants.ArmKeyVaultName).(string)
|
||||
|
||||
if actualKeyVaultName != expectedKeyVaultName {
|
||||
t.Fatalf("Expected StepGetCertificate to source 'constants.ArmKeyVaultName' from the state bag, but it did not.")
|
||||
t.Fatal("Expected StepGetCertificate to source 'constants.ArmKeyVaultName' from the state bag, but it did not.")
|
||||
}
|
||||
if actualSecretName != DefaultSecretName {
|
||||
t.Fatalf("Expected StepGetCertificate to use default value for secret, but it did not.")
|
||||
t.Fatal("Expected StepGetCertificate to use default value for secret, but it did not.")
|
||||
}
|
||||
|
||||
expectedCertificateUrl, ok := stateBag.GetOk(constants.ArmCertificateUrl)
|
||||
|
|
|
@ -75,11 +75,11 @@ func TestStepGetIPAddressShouldTakeStepArgumentsFromStateBag(t *testing.T) {
|
|||
var expectedIPAddressName = stateBag.Get(constants.ArmPublicIPAddressName).(string)
|
||||
|
||||
if actualIPAddressName != expectedIPAddressName {
|
||||
t.Fatalf("Expected StepGetIPAddress to source 'constants.ArmIPAddressName' from the state bag, but it did not.")
|
||||
t.Fatal("Expected StepGetIPAddress to source 'constants.ArmIPAddressName' from the state bag, but it did not.")
|
||||
}
|
||||
|
||||
if actualResourceGroupName != expectedResourceGroupName {
|
||||
t.Fatalf("Expected StepGetIPAddress to source 'constants.ArmResourceGroupName' from the state bag, but it did not.")
|
||||
t.Fatal("Expected StepGetIPAddress to source 'constants.ArmResourceGroupName' from the state bag, but it did not.")
|
||||
}
|
||||
|
||||
expectedIPAddress, ok := stateBag.GetOk(constants.SSHHost)
|
||||
|
|
|
@ -82,11 +82,11 @@ func TestStepGetOSDiskShouldTakeValidateArgumentsFromStateBag(t *testing.T) {
|
|||
var expectedResourceGroupName = stateBag.Get(constants.ArmResourceGroupName).(string)
|
||||
|
||||
if actualComputeName != expectedComputeName {
|
||||
t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.")
|
||||
t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.")
|
||||
}
|
||||
|
||||
if actualResourceGroupName != expectedResourceGroupName {
|
||||
t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.")
|
||||
t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.")
|
||||
}
|
||||
|
||||
expectedOSDiskVhd, ok := stateBag.GetOk(constants.ArmOSDiskVhd)
|
||||
|
|
|
@ -75,11 +75,11 @@ func TestStepPowerOffComputeShouldTakeStepArgumentsFromStateBag(t *testing.T) {
|
|||
var expectedResourceGroupName = stateBag.Get(constants.ArmResourceGroupName).(string)
|
||||
|
||||
if actualComputeName != expectedComputeName {
|
||||
t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.")
|
||||
t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.")
|
||||
}
|
||||
|
||||
if actualResourceGroupName != expectedResourceGroupName {
|
||||
t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.")
|
||||
t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
func TestProcessStepResultShouldContinueForNonErrors(t *testing.T) {
|
||||
stateBag := new(multistep.BasicStateBag)
|
||||
|
||||
code := processStepResult(nil, func(error) { t.Fatalf("Should not be called!") }, stateBag)
|
||||
code := processStepResult(nil, func(error) { t.Fatal("Should not be called!") }, stateBag)
|
||||
if _, ok := stateBag.GetOk(constants.Error); ok {
|
||||
t.Errorf("Error was nil, but was still in the state bag.")
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ func TestProcessStepResultShouldContinueOnSuccessfulTask(t *testing.T) {
|
|||
Err: nil,
|
||||
}
|
||||
|
||||
code := processInterruptibleResult(result, func(error) { t.Fatalf("Should not be called!") }, stateBag)
|
||||
code := processInterruptibleResult(result, func(error) { t.Fatal("Should not be called!") }, stateBag)
|
||||
if _, ok := stateBag.GetOk(constants.Error); ok {
|
||||
t.Errorf("Error was nil, but was still in the state bag.")
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ func TestProcessStepResultShouldHaltWhenTaskIsCancelled(t *testing.T) {
|
|||
Err: nil,
|
||||
}
|
||||
|
||||
code := processInterruptibleResult(result, func(error) { t.Fatalf("Should not be called!") }, stateBag)
|
||||
code := processInterruptibleResult(result, func(error) { t.Fatal("Should not be called!") }, stateBag)
|
||||
if _, ok := stateBag.GetOk(constants.Error); ok {
|
||||
t.Errorf("Error was nil, but was still in the state bag.")
|
||||
}
|
||||
|
|
|
@ -75,11 +75,11 @@ func TestStepValidateTemplateShouldTakeStepArgumentsFromStateBag(t *testing.T) {
|
|||
var expectedResourceGroupName = stateBag.Get(constants.ArmResourceGroupName).(string)
|
||||
|
||||
if actualDeploymentName != expectedDeploymentName {
|
||||
t.Fatalf("Expected the step to source 'constants.ArmDeploymentName' from the state bag, but it did not.")
|
||||
t.Fatal("Expected the step to source 'constants.ArmDeploymentName' from the state bag, but it did not.")
|
||||
}
|
||||
|
||||
if actualResourceGroupName != expectedResourceGroupName {
|
||||
t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.")
|
||||
t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ var (
|
|||
|
||||
// Authenticate fetches a token from the local file cache or initiates a consent
|
||||
// flow and waits for token to be obtained.
|
||||
func Authenticate(env azure.Environment, subscriptionID, tenantID string, say func(string)) (*azure.ServicePrincipalToken, error) {
|
||||
func Authenticate(env azure.Environment, tenantID string, say func(string)) (*azure.ServicePrincipalToken, error) {
|
||||
clientID, ok := clientIDs[env.Name]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("packer-azure application not set up for Azure environment %q", env.Name)
|
||||
|
@ -81,7 +81,7 @@ func Authenticate(env azure.Environment, subscriptionID, tenantID string, say fu
|
|||
// will go stale every 14 days and we will delete the token file,
|
||||
// re-initiate the device flow.
|
||||
say("Validating the token.")
|
||||
if err := validateToken(env, spt); err != nil {
|
||||
if err = validateToken(env, spt); err != nil {
|
||||
say(fmt.Sprintf("Error: %v", err))
|
||||
say("Stored Azure credentials expired. Please reauthenticate.")
|
||||
say(fmt.Sprintf("Deleting %s", tokenPath))
|
||||
|
@ -96,7 +96,7 @@ func Authenticate(env azure.Environment, subscriptionID, tenantID string, say fu
|
|||
|
||||
// Start an OAuth 2.0 device flow
|
||||
say(fmt.Sprintf("Initiating device flow: %s", tokenPath))
|
||||
spt, err = tokenFromDeviceFlow(say, *oauthCfg, tokenPath, clientID, apiScope)
|
||||
spt, err = tokenFromDeviceFlow(say, *oauthCfg, clientID, apiScope)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ func tokenFromFile(say func(string), oauthCfg azure.OAuthConfig, tokenPath, clie
|
|||
// consent application on a browser and in the meanwhile the authentication
|
||||
// endpoint is polled until user gives consent, denies or the flow times out.
|
||||
// Returned token must be saved.
|
||||
func tokenFromDeviceFlow(say func(string), oauthCfg azure.OAuthConfig, tokenPath, clientID, resource string) (*azure.ServicePrincipalToken, error) {
|
||||
func tokenFromDeviceFlow(say func(string), oauthCfg azure.OAuthConfig, clientID, resource string) (*azure.ServicePrincipalToken, error) {
|
||||
cl := autorest.NewClientWithUserAgent(userAgent)
|
||||
deviceCode, err := azure.InitiateDeviceAuth(&cl, oauthCfg, clientID, resource)
|
||||
if err != nil {
|
||||
|
|
|
@ -20,7 +20,7 @@ func TestInterruptibleTaskShouldImmediatelyEndOnCancel(t *testing.T) {
|
|||
|
||||
result := testSubject.Run()
|
||||
if result.IsCancelled != true {
|
||||
t.Fatalf("Expected the task to be cancelled, but it was not.")
|
||||
t.Fatal("Expected the task to be cancelled, but it was not.")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ func (s *StepCreateCert) Run(state multistep.StateBag) multistep.StepAction {
|
|||
|
||||
err := s.createCert(state)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Error creating temporary certificate: %s", err)
|
||||
err = fmt.Errorf("Error creating temporary certificate: %s", err)
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
return multistep.ActionHalt
|
||||
|
@ -45,11 +45,11 @@ func (s *StepCreateCert) Cleanup(state multistep.StateBag) {}
|
|||
|
||||
func (s *StepCreateCert) createCert(state multistep.StateBag) error {
|
||||
|
||||
log.Printf("createCert: Generating RSA key pair...")
|
||||
log.Println("createCert: Generating RSA key pair...")
|
||||
|
||||
priv, err := rsa.GenerateKey(rand.Reader, 2048)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Failed to Generate Private Key: %s", err)
|
||||
err = fmt.Errorf("Failed to Generate Private Key: %s", err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ func (s *StepCreateCert) createCert(state multistep.StateBag) error {
|
|||
state.Put(constants.PrivateKey, privkey)
|
||||
log.Printf("createCert: Private key:\n%s", privkey)
|
||||
|
||||
log.Printf("createCert: Creating certificate...")
|
||||
log.Println("createCert: Creating certificate...")
|
||||
|
||||
host := fmt.Sprintf("%s.cloudapp.net", s.TmpServiceName)
|
||||
notBefore := time.Now()
|
||||
|
@ -71,7 +71,7 @@ func (s *StepCreateCert) createCert(state multistep.StateBag) error {
|
|||
|
||||
serialNumber, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 128))
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Failed to Generate Serial Number: %v", err)
|
||||
err = fmt.Errorf("Failed to Generate Serial Number: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ func (s *StepCreateCert) createCert(state multistep.StateBag) error {
|
|||
|
||||
derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Failed to Create Certificate: %s", err)
|
||||
err = fmt.Errorf("Failed to Create Certificate: %s", err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ func (s *StepGeneralizeOS) Run(state multistep.StateBag) multistep.StepAction {
|
|||
}
|
||||
|
||||
if err := comm.Start(cmd); err != nil {
|
||||
err := fmt.Errorf("Failed executing OS generalization command: %s", err)
|
||||
err = fmt.Errorf("Failed executing OS generalization command: %s", err)
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
return multistep.ActionHalt
|
||||
|
|
|
@ -46,7 +46,7 @@ func (s *TemplateBuilder) BuildLinux(sshAuthorizedKey string) error {
|
|||
profile.LinuxConfiguration = &compute.LinuxConfiguration{
|
||||
SSH: &compute.SSHConfiguration{
|
||||
PublicKeys: &[]compute.SSHPublicKey{
|
||||
compute.SSHPublicKey{
|
||||
{
|
||||
Path: to.StringPtr(s.toVariable(variableSshKeyPath)),
|
||||
KeyData: to.StringPtr(sshAuthorizedKey),
|
||||
},
|
||||
|
@ -66,12 +66,12 @@ func (s *TemplateBuilder) BuildWindows(keyVaultName, winRMCertificateUrl string)
|
|||
profile := resource.Properties.OsProfile
|
||||
|
||||
profile.Secrets = &[]compute.VaultSecretGroup{
|
||||
compute.VaultSecretGroup{
|
||||
{
|
||||
SourceVault: &compute.SubResource{
|
||||
ID: to.StringPtr(s.toResourceID(resourceKeyVaults, keyVaultName)),
|
||||
},
|
||||
VaultCertificates: &[]compute.VaultCertificate{
|
||||
compute.VaultCertificate{
|
||||
{
|
||||
CertificateStore: to.StringPtr("My"),
|
||||
CertificateURL: to.StringPtr(winRMCertificateUrl),
|
||||
},
|
||||
|
@ -83,7 +83,7 @@ func (s *TemplateBuilder) BuildWindows(keyVaultName, winRMCertificateUrl string)
|
|||
ProvisionVMAgent: to.BoolPtr(true),
|
||||
WinRM: &compute.WinRMConfiguration{
|
||||
Listeners: &[]compute.WinRMListener{
|
||||
compute.WinRMListener{
|
||||
{
|
||||
Protocol: "https",
|
||||
CertificateURL: to.StringPtr(winRMCertificateUrl),
|
||||
},
|
||||
|
|
|
@ -12,13 +12,13 @@ import (
|
|||
|
||||
func TestTemplateParametersShouldHaveExpectedKeys(t *testing.T) {
|
||||
params := TemplateParameters{
|
||||
AdminUsername: &TemplateParameter{"sentinel"},
|
||||
AdminPassword: &TemplateParameter{"sentinel"},
|
||||
DnsNameForPublicIP: &TemplateParameter{"sentinel"},
|
||||
OSDiskName: &TemplateParameter{"sentinel"},
|
||||
StorageAccountBlobEndpoint: &TemplateParameter{"sentinel"},
|
||||
VMName: &TemplateParameter{"sentinel"},
|
||||
VMSize: &TemplateParameter{"sentinel"},
|
||||
AdminUsername: &TemplateParameter{Value: "sentinel"},
|
||||
AdminPassword: &TemplateParameter{Value: "sentinel"},
|
||||
DnsNameForPublicIP: &TemplateParameter{Value: "sentinel"},
|
||||
OSDiskName: &TemplateParameter{Value: "sentinel"},
|
||||
StorageAccountBlobEndpoint: &TemplateParameter{Value: "sentinel"},
|
||||
VMName: &TemplateParameter{Value: "sentinel"},
|
||||
VMSize: &TemplateParameter{Value: "sentinel"},
|
||||
}
|
||||
|
||||
bs, err := json.Marshal(params)
|
||||
|
@ -53,13 +53,13 @@ func TestTemplateParametersShouldHaveExpectedKeys(t *testing.T) {
|
|||
|
||||
func TestParameterValuesShouldBeSet(t *testing.T) {
|
||||
params := TemplateParameters{
|
||||
AdminUsername: &TemplateParameter{"adminusername00"},
|
||||
AdminPassword: &TemplateParameter{"adminpassword00"},
|
||||
DnsNameForPublicIP: &TemplateParameter{"dnsnameforpublicip00"},
|
||||
OSDiskName: &TemplateParameter{"osdiskname00"},
|
||||
StorageAccountBlobEndpoint: &TemplateParameter{"storageaccountblobendpoint00"},
|
||||
VMName: &TemplateParameter{"vmname00"},
|
||||
VMSize: &TemplateParameter{"vmsize00"},
|
||||
AdminUsername: &TemplateParameter{Value: "adminusername00"},
|
||||
AdminPassword: &TemplateParameter{Value: "adminpassword00"},
|
||||
DnsNameForPublicIP: &TemplateParameter{Value: "dnsnameforpublicip00"},
|
||||
OSDiskName: &TemplateParameter{Value: "osdiskname00"},
|
||||
StorageAccountBlobEndpoint: &TemplateParameter{Value: "storageaccountblobendpoint00"},
|
||||
VMName: &TemplateParameter{Value: "vmname00"},
|
||||
VMSize: &TemplateParameter{Value: "vmsize00"},
|
||||
}
|
||||
|
||||
bs, err := json.Marshal(params)
|
||||
|
@ -89,7 +89,7 @@ func TestParameterValuesShouldBeSet(t *testing.T) {
|
|||
|
||||
func TestEmptyValuesShouldBeOmitted(t *testing.T) {
|
||||
params := TemplateParameters{
|
||||
AdminUsername: &TemplateParameter{"adminusername00"},
|
||||
AdminUsername: &TemplateParameter{Value: "adminusername00"},
|
||||
}
|
||||
|
||||
bs, err := json.Marshal(params)
|
||||
|
|
|
@ -25,8 +25,8 @@ type VaultClient struct {
|
|||
}
|
||||
|
||||
type Secret struct {
|
||||
ID *string `json:"id,omitempty"`
|
||||
Value string `json:"value"`
|
||||
ID *string `json:"id,omitempty"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
func (client *VaultClient) GetSecret(vaultName, secretName string) (*Secret, error) {
|
||||
|
|
|
@ -29,7 +29,7 @@ func decodeBMPString(bmpString []byte) (string, error) {
|
|||
func TestBMPStringDecode(t *testing.T) {
|
||||
_, err := decodeBMPString([]byte("a"))
|
||||
if err == nil {
|
||||
t.Fatalf("expected decode to fail, but it succeeded")
|
||||
t.Fatal("expected decode to fail, but it succeeded")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ func makeSalt(saltByteCount int) ([]byte, error) {
|
|||
//
|
||||
// derBytes is a DER encoded certificate.
|
||||
// privateKey is an RSA
|
||||
func Encode(derBytes []byte, privateKey interface{}, password string) (pfxBytes []byte, err error) {
|
||||
func Encode(derBytes []byte, privateKey interface{}, password string) ([]byte, error) {
|
||||
secret, err := bmpString(password)
|
||||
if err != nil {
|
||||
return nil, ErrIncorrectPassword
|
||||
|
|
|
@ -25,7 +25,7 @@ func TestPfxRoundTriRsa(t *testing.T) {
|
|||
|
||||
actualPrivateKey, ok := key.(*rsa.PrivateKey)
|
||||
if !ok {
|
||||
t.Fatalf("failed to decode private key")
|
||||
t.Fatal("failed to decode private key")
|
||||
}
|
||||
|
||||
if privateKey.D.Cmp(actualPrivateKey.D) != 0 {
|
||||
|
|
|
@ -28,7 +28,7 @@ var (
|
|||
|
||||
// marshalPKCS8PrivateKey converts a private key to PKCS#8 encoded form.
|
||||
// See http://www.rsa.com/rsalabs/node.asp?id=2130 and RFC5208.
|
||||
func marshalPKCS8PrivateKey(key interface{}) (der []byte, err error) {
|
||||
func marshalPKCS8PrivateKey(key interface{}) ([]byte, error) {
|
||||
pkcs := pkcs8{
|
||||
Version: 0,
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ func TestRoundTripPkcs8Rsa(t *testing.T) {
|
|||
}
|
||||
|
||||
if actualPrivateKey.Validate() != nil {
|
||||
t.Fatalf("private key did not validate")
|
||||
t.Fatal("private key did not validate")
|
||||
}
|
||||
|
||||
if actualPrivateKey.N.Cmp(privateKey.N) != 0 {
|
||||
|
|
|
@ -97,6 +97,6 @@ func TestRoundTripPkcs8ShroudedKeyBag(t *testing.T) {
|
|||
|
||||
actualPrivateKey := key.(*rsa.PrivateKey)
|
||||
if actualPrivateKey.D.Cmp(privateKey.D) != 0 {
|
||||
t.Fatalf("failed to round-trip rsa.PrivateKey.D")
|
||||
t.Fatal("failed to round-trip rsa.PrivateKey.D")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue