Vbox Checksum Bugfix (#9101)
* attempting to repro github issue 9049 * update vbox ovf configtest to table test for mixedcase bug
This commit is contained in:
parent
26d05abd4f
commit
b86efe7604
|
@ -155,8 +155,6 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
|
|||
errs = packer.MultiErrorAppend(errs, c.GuestAdditionsConfig.Prepare(&c.ctx)...)
|
||||
|
||||
c.ChecksumType = strings.ToLower(c.ChecksumType)
|
||||
c.Checksum = strings.ToLower(c.Checksum)
|
||||
|
||||
if c.SourcePath == "" {
|
||||
errs = packer.MultiErrorAppend(errs, fmt.Errorf("source_path is required"))
|
||||
}
|
||||
|
|
|
@ -110,3 +110,40 @@ func TestNewConfig_shutdown_timeout(t *testing.T) {
|
|||
t.Fatalf("bad: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestChecksumFileNameMixedCaseBug reproduces Github issue #9049:
|
||||
// https://github.com/hashicorp/packer/issues/9049
|
||||
func TestChecksumFileNameMixedCaseBug(t *testing.T) {
|
||||
tt := []struct {
|
||||
Name string
|
||||
ChecksumPath string
|
||||
}{
|
||||
{"Lowercase", "/tmp/random/file.md5"},
|
||||
{"MiXeDcAsE", "/tmp/RaNdOm/FiLe.Md5"},
|
||||
}
|
||||
|
||||
for _, tc := range tt {
|
||||
|
||||
cfg := testConfig(t)
|
||||
cfg["source_path"] = "bug.ovf"
|
||||
cfg["checksum_type"] = "file"
|
||||
cfg["checksum"] = tc.ChecksumPath
|
||||
cfg["type"] = "virtualbox-ovf"
|
||||
cfg["guest_additions_mode"] = "disable"
|
||||
cfg["headless"] = false
|
||||
|
||||
var c Config
|
||||
warns, err := c.Prepare(cfg)
|
||||
if err != nil {
|
||||
t.Errorf("config failed to Prepare, %s", err.Error())
|
||||
}
|
||||
|
||||
if len(warns) != 0 {
|
||||
t.Errorf("Encountered warnings during config preparation: %s", warns)
|
||||
}
|
||||
|
||||
if c.Checksum != tc.ChecksumPath {
|
||||
t.Errorf("%s test failed, Checksum and ChecksumPath are expected to be equal, expected: %s, got: %s", tc.Name, tc.ChecksumPath, c.Checksum)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue