Skip to content

Commit

Permalink
use new testdata
Browse files Browse the repository at this point in the history
  • Loading branch information
lindnerby committed Sep 24, 2024
1 parent a61acdf commit 6e86073
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 110 deletions.
107 changes: 0 additions & 107 deletions tests/e2e/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,113 +278,6 @@ var _ = Describe("Test 'create' command", Ordered, func() {
Expect(err.Error()).Should(ContainSubstring("could not push component version: component version already exists"))
})
})

Context("Given 'modulectl create' command with no security option", func() {
var cmd createCmd
It("When invoked with existing '--registry' and '--insecure' flag", func() {
cmd = createCmd{
moduleConfigFile: validModuleConfigFile,
registry: ociRegistry,
insecure: true,
output: templateOutputPath,
gitRemote: gitRemote,
}
})
It("Then the command should succeed", func() {
Expect(cmd.execute()).To(Succeed())

By("And module template file should be generated")
Expect(filesIn("/tmp/")).Should(ContainElement("template.yaml"))
})
It("Then module template should contain the expected content", func() {
template, err := readModuleTemplate(templateOutputPath)
Expect(err).ToNot(HaveOccurred())
descriptor := getDescriptor(template)
Expect(descriptor).ToNot(BeNil())
Expect(descriptor.SchemaVersion()).To(Equal(compdescv2.SchemaVersion))

By("And annotations should be correct")
annotations := template.Annotations
Expect(annotations[shared.ModuleVersionAnnotation]).To(Equal(moduleTemplateVersion))
Expect(annotations[shared.IsClusterScopedAnnotation]).To(Equal("false"))

By("And descriptor.component.repositoryContexts should be correct")
Expect(descriptor.RepositoryContexts).To(HaveLen(1))
repo := descriptor.GetEffectiveRepositoryContext()
Expect(repo.Object["baseUrl"]).To(Equal(ociRegistry))
Expect(repo.Object["componentNameMapping"]).To(Equal(string(ocmocireg.OCIRegistryURLPathMapping)))
Expect(repo.Object["type"]).To(Equal(ocireg.Type))

By("And descriptor.component.resources should be correct")
Expect(descriptor.Resources).To(HaveLen(3))
resource := descriptor.Resources[0]
Expect(resource.Name).To(Equal("template-operator"))
Expect(resource.Relation).To(Equal(ocmmetav1.ExternalRelation))
Expect(resource.Type).To(Equal("ociArtifact"))
Expect(resource.Version).To(Equal(moduleTemplateVersion))

resource = descriptor.Resources[1]
Expect(resource.Name).To(Equal("raw-manifest"))
Expect(resource.Relation).To(Equal(ocmmetav1.LocalRelation))
Expect(resource.Type).To(Equal("directory"))
Expect(resource.Version).To(Equal(moduleTemplateVersion))

resource = descriptor.Resources[2]
Expect(resource.Name).To(Equal("default-cr"))
Expect(resource.Relation).To(Equal(ocmmetav1.LocalRelation))
Expect(resource.Type).To(Equal("directory"))
Expect(resource.Version).To(Equal(moduleTemplateVersion))

By("And descriptor.component.resources[0].access should be correct")
resourceAccessSpec0, err := ocm.DefaultContext().AccessSpecForSpec(descriptor.Resources[0].Access)
Expect(err).ToNot(HaveOccurred())
ociArtifactAccessSpec, ok := resourceAccessSpec0.(*ociartifact.AccessSpec)
Expect(ok).To(BeTrue())
Expect(ociArtifactAccessSpec.GetType()).To(Equal(ociartifact.Type))
Expect(ociArtifactAccessSpec.ImageReference).To(Equal("europe-docker.pkg.dev/kyma-project/prod/template-operator:1.0.0"))

By("And descriptor.component.resources[1].access should be correct")
resourceAccessSpec1, err := ocm.DefaultContext().AccessSpecForSpec(descriptor.Resources[1].Access)
Expect(err).ToNot(HaveOccurred())
localBlobAccessSpec, ok := resourceAccessSpec1.(*localblob.AccessSpec)
Expect(ok).To(BeTrue())
Expect(localBlobAccessSpec.GetType()).To(Equal(localblob.Type))
Expect(localBlobAccessSpec.LocalReference).To(ContainSubstring("sha256:"))
Expect(localBlobAccessSpec.MediaType).To(Equal("application/x-tar"))

By("And descriptor.component.resources[2].access should be correct")
defaultCRResourceAccessSpec, err := ocm.DefaultContext().AccessSpecForSpec(descriptor.Resources[2].Access)
Expect(err).ToNot(HaveOccurred())
defaultCRAccessSpec, ok := defaultCRResourceAccessSpec.(*localblob.AccessSpec)
Expect(ok).To(BeTrue())
Expect(defaultCRAccessSpec.GetType()).To(Equal(localblob.Type))
Expect(defaultCRAccessSpec.LocalReference).To(ContainSubstring("sha256:"))
Expect(defaultCRAccessSpec.MediaType).To(Equal("application/x-tar"))

By("And descriptor.component.sources should be correct")
Expect(len(descriptor.Sources)).To(Equal(1))
source := descriptor.Sources[0]
sourceAccessSpec, err := ocm.DefaultContext().AccessSpecForSpec(source.Access)
Expect(err).ToNot(HaveOccurred())
githubAccessSpec, ok := sourceAccessSpec.(*github.AccessSpec)
Expect(ok).To(BeTrue())
Expect(github.Type).To(Equal(githubAccessSpec.Type))
Expect(githubAccessSpec.RepoURL).To(Equal("https://github.com/kyma-project/template-operator"))

By("And spec.mandatory should be false")
Expect(template.Spec.Mandatory).To(BeFalse())

By("And security scan labels should be correct")
secScanLabels := flatten(descriptor.Sources[0].Labels)
Expect(secScanLabels).To(HaveKeyWithValue("git.kyma-project.io/ref", "HEAD"))
Expect(secScanLabels).To(HaveKeyWithValue("scan.security.kyma-project.io/rc-tag", "1.0.0"))
Expect(secScanLabels).To(HaveKeyWithValue("scan.security.kyma-project.io/language", "golang-mod"))
Expect(secScanLabels).To(HaveKeyWithValue("scan.security.kyma-project.io/dev-branch", "main"))
Expect(secScanLabels).To(HaveKeyWithValue("scan.security.kyma-project.io/subprojects", "false"))
Expect(secScanLabels).To(HaveKeyWithValue("scan.security.kyma-project.io/exclude",
"**/test/**,**/*_test.go"))
})
})
})

// Test helper functions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: kyma-project.io/module/template-operator
channel: regular
version: 1.0.0
version: 1.0.1
manifest: https://github.com/kyma-project/template-operator/releases/download/1.0.1/template-operator.yaml
annotations:
operator.kyma-project.io/doc-url: https://kyma-project.io
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: kyma-project.io/module/template-operator
channel: regular
version: 1.0.0
version: 1.0.2
manifest: https://github.com/kyma-project/template-operator/releases/download/1.0.1/template-operator.yaml
defaultCR: https://github.com/kyma-project/template-operator/releases/download/1.0.1/default-sample-cr.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: kyma-project.io/module/template-operator
channel: regular
version: 1.0.0
version: 1.0.3
manifest: https://github.com/kyma-project/template-operator/releases/download/1.0.1/template-operator.yaml
security: sec-scanners-config.yaml

0 comments on commit 6e86073

Please sign in to comment.