temporary - this disables checksums until server implements (XAPID-544)
diff --git a/bundle.go b/bundle.go index a1b23c2..83eaff9 100644 --- a/bundle.go +++ b/bundle.go
@@ -202,12 +202,22 @@ case "crc-32": hashWriter = crc32.NewIEEE() default: - return nil, errors.New("checksumType must be md5 or crc-32") + // todo: temporary - this disables checksums until server implements (XAPID-544) + hashWriter = fakeHash{md5.New()} + //return nil, errors.New("checksumType must be md5 or crc-32") } return hashWriter, nil } +type fakeHash struct { + hash.Hash +} + +func (f fakeHash) Sum(b []byte) []byte { + return []byte("") +} + //func checksumFile(hashType, checksum string, fileName string) error { // // hashWriter, err := getHashWriter(hashType)
diff --git a/bundle_test.go b/bundle_test.go index 1c959d9..4f2bad2 100644 --- a/bundle_test.go +++ b/bundle_test.go
@@ -96,5 +96,69 @@ Expect(d.DeployErrorMessage).ToNot(BeEmpty()) Expect(d.LocalBundleURI).To(BeAnExistingFile()) }) + + // todo: temporary - this tests that checksum is disabled until server implements (XAPID-544) + It("should TEMPORARILY download even if empty Checksum and ChecksumType", func() { + + deploymentID := "bundle_download_temporary" + + uri, err := url.Parse(testServer.URL) + Expect(err).ShouldNot(HaveOccurred()) + + uri.Path = "/bundles/1" + bundleUri := uri.String() + bundle := bundleConfigJson{ + Name: uri.Path, + URI: bundleUri, + ChecksumType: "", + Checksum: "", + } + bundleJson, err := json.Marshal(bundle) + Expect(err).ShouldNot(HaveOccurred()) + + tx, err := getDB().Begin() + Expect(err).ShouldNot(HaveOccurred()) + + dep := DataDeployment{ + ID: deploymentID, + BundleConfigID: deploymentID, + ApidClusterID: deploymentID, + DataScopeID: deploymentID, + BundleConfigJSON: string(bundleJson), + ConfigJSON: string(bundleJson), + Created: "", + CreatedBy: "", + Updated: "", + UpdatedBy: "", + BundleName: deploymentID, + BundleURI: bundle.URI, + BundleChecksum: bundle.Checksum, + BundleChecksumType: bundle.ChecksumType, + LocalBundleURI: "", + DeployStatus: "", + DeployErrorCode: 0, + DeployErrorMessage: "", + } + + err = InsertDeployment(tx, dep) + Expect(err).ShouldNot(HaveOccurred()) + + err = tx.Commit() + Expect(err).ShouldNot(HaveOccurred()) + + go downloadBundle(dep) + + // give download time to finish + time.Sleep(bundleDownloadTimeout + (100 * time.Millisecond)) + + deployments, err := getReadyDeployments() + Expect(err).ShouldNot(HaveOccurred()) + + Expect(len(deployments)).To(Equal(1)) + d := deployments[0] + + Expect(d.ID).To(Equal(deploymentID)) + Expect(d.LocalBundleURI).To(BeAnExistingFile()) + }) }) })