Esempio n. 1
0
// Ensure the VM template is correct when using a custom image.
func TestVirtualMachineDeployment04(t *testing.T) {
	config := map[string]string{
		"capture_name_prefix":    "ignore",
		"capture_container_name": "ignore",
		"location":               "ignore",
		"image_url":              "https://localhost/custom.vhd",
		"resource_group_name":    "ignore",
		"storage_account":        "ignore",
		"subscription_id":        "ignore",
		"os_type":                constants.Target_Linux,
		"communicator":           "none",
	}

	c, _, err := newConfig(config, getPackerConfiguration())
	if err != nil {
		t.Fatal(err)
	}

	deployment, err := GetVirtualMachineDeployment(c)
	if err != nil {
		t.Fatal(err)
	}

	bs, err := json.MarshalIndent(deployment.Properties.Template, "", "  ")
	if err != nil {
		t.Fatal(err)
	}

	reader := strings.NewReader(string(bs))
	err = approvals.Verify(t, reader)
	if err != nil {
		t.Fatal(err)
	}
}
Esempio n. 2
0
// Ensure that a Windows template is configured as expected.
//  * Include WinRM configuration.
//  * Include KeyVault configuration, which is needed for WinRM.
func TestBuildWindows00(t *testing.T) {
	testSubject, err := NewTemplateBuilder()
	if err != nil {
		t.Fatal(err)
	}

	err = testSubject.BuildWindows("--test-key-vault-name", "--test-winrm-certificate-url--")
	if err != nil {
		t.Fatal(err)
	}

	err = testSubject.SetMarketPlaceImage("MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter", "latest")
	if err != nil {
		t.Fatal(err)
	}

	doc, err := testSubject.ToJSON()
	if err != nil {
		t.Fatal(err)
	}

	reader := strings.NewReader(*doc)

	err = approvals.Verify(t, reader)
	if err != nil {
		t.Fatal(err)
	}
}
Esempio n. 3
0
// Ensure that a user can specify a custom VHD when building a Linux template.
func TestBuildLinux01(t *testing.T) {
	testSubject, err := NewTemplateBuilder()
	if err != nil {
		t.Fatal(err)
	}

	err = testSubject.BuildLinux("--test-ssh-authorized-key--")
	if err != nil {
		t.Fatal(err)
	}

	err = testSubject.SetImageUrl("http://azure/custom.vhd", compute.Linux)
	if err != nil {
		t.Fatal(err)
	}

	doc, err := testSubject.ToJSON()
	if err != nil {
		t.Fatal(err)
	}

	reader := strings.NewReader(*doc)

	err = approvals.Verify(t, reader)
	if err != nil {
		t.Fatal(err)
	}
}
Esempio n. 4
0
// Ensure that a Linux template is configured as expected.
//  * Include SSH configuration: authorized key, and key path.
func TestBuildLinux00(t *testing.T) {
	testSubject, err := NewTemplateBuilder()
	if err != nil {
		t.Fatal(err)
	}

	err = testSubject.BuildLinux("--test-ssh-authorized-key--")
	if err != nil {
		t.Fatal(err)
	}

	err = testSubject.SetMarketPlaceImage("Canonical", "UbuntuServer", "16.04", "latest")
	if err != nil {
		t.Fatal(err)
	}

	doc, err := testSubject.ToJSON()
	if err != nil {
		t.Fatal(err)
	}

	reader := strings.NewReader(*doc)

	err = approvals.Verify(t, reader)
	if err != nil {
		t.Fatal(err)
	}
}
Esempio n. 5
0
// Ensure the KeyVault template is correct.
func TestKeyVaultDeployment03(t *testing.T) {
	c, _, _ := newConfig(getArmBuilderConfigurationWithWindows(), getPackerConfiguration())
	deployment, err := GetKeyVaultDeployment(c)
	if err != nil {
		t.Fatal(err)
	}

	bs, err := json.MarshalIndent(deployment.Properties.Template, "", "  ")
	if err != nil {
		t.Fatal(err)
	}

	reader := strings.NewReader(string(bs))
	err = approvals.Verify(t, reader)
	if err != nil {
		t.Fatal(err)
	}
}
Esempio n. 6
0
// Ensure the VM template is correct when using a market place image.
func TestVirtualMachineDeployment03(t *testing.T) {
	m := getArmBuilderConfiguration()
	m["image_publisher"] = "ImagePublisher"
	m["image_offer"] = "ImageOffer"
	m["image_sku"] = "ImageSku"
	m["image_version"] = "ImageVersion"

	c, _, _ := newConfig(m, getPackerConfiguration())
	deployment, err := GetVirtualMachineDeployment(c)
	if err != nil {
		t.Fatal(err)
	}

	bs, err := json.MarshalIndent(deployment.Properties.Template, "", "  ")
	if err != nil {
		t.Fatal(err)
	}

	reader := strings.NewReader(string(bs))
	err = approvals.Verify(t, reader)
	if err != nil {
		t.Fatal(err)
	}
}