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:
Ryan Hartje 2020-05-07 18:08:52 -05:00 committed by GitHub
parent 26d05abd4f
commit b86efe7604
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 2 deletions

View File

@ -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"))
}

View File

@ -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)
}
}
}