@@ -765,6 +765,72 @@ var _ = Describe("interacting with BOSH releases on Artifactory", func() {
765765 })
766766 })
767767
768+ Describe ("regex pattern matching" , func () {
769+ When ("a release name contains a dot and only a non-matching file is returned" , func () {
770+ BeforeEach (func () {
771+ config .PathTemplate = "bosh-releases/{{.Name}}-{{.Version}}.tgz"
772+ requireAuth := requireBasicAuthMiddleware (correctUsername , correctPassword )
773+
774+ apiStorageListing := ApiStorageListing {}
775+ apiStorageListing .Children = append (apiStorageListing .Children , ApiStorageChildren {
776+ Path : "bosh-releases" ,
777+ Name : "myXrelease-2.3.4.tgz" ,
778+ ActualSha1 : "some-sha" ,
779+ })
780+
781+ apiStorageListingBytes , err := json .Marshal (apiStorageListing )
782+ Expect (err ).NotTo (HaveOccurred ())
783+
784+ artifactoryRouter .Handler (http .MethodPost , "/api/search/aql" , applyMiddleware (http .HandlerFunc (func (res http.ResponseWriter , _ * http.Request ) {
785+ res .WriteHeader (http .StatusOK )
786+ _ , _ = io .Writer .Write (res , apiStorageListingBytes )
787+ }), requireAuth ))
788+ })
789+
790+ It ("does not match a file where the dot is replaced by another character" , func () {
791+ _ , resultErr := source .GetMatchedRelease (cargo.BOSHReleaseTarballSpecification {
792+ Name : "my.release" ,
793+ Version : "2.3.4" ,
794+ })
795+
796+ Expect (resultErr ).To (HaveOccurred ())
797+ Expect (component .IsErrNotFound (resultErr )).To (BeTrue ())
798+ })
799+ })
800+
801+ When ("a file extension dot is replaced by another character" , func () {
802+ BeforeEach (func () {
803+ config .PathTemplate = "bosh-releases/{{.Name}}-{{.Version}}.tgz"
804+ requireAuth := requireBasicAuthMiddleware (correctUsername , correctPassword )
805+
806+ apiStorageListing := ApiStorageListing {}
807+ apiStorageListing .Children = append (apiStorageListing .Children , ApiStorageChildren {
808+ Path : "bosh-releases" ,
809+ Name : "mango-2.3.4Xtgz" ,
810+ ActualSha1 : "some-sha" ,
811+ })
812+
813+ apiStorageListingBytes , err := json .Marshal (apiStorageListing )
814+ Expect (err ).NotTo (HaveOccurred ())
815+
816+ artifactoryRouter .Handler (http .MethodPost , "/api/search/aql" , applyMiddleware (http .HandlerFunc (func (res http.ResponseWriter , _ * http.Request ) {
817+ res .WriteHeader (http .StatusOK )
818+ _ , _ = io .Writer .Write (res , apiStorageListingBytes )
819+ }), requireAuth ))
820+ })
821+
822+ It ("does not match the file" , func () {
823+ _ , resultErr := source .GetMatchedRelease (cargo.BOSHReleaseTarballSpecification {
824+ Name : "mango" ,
825+ Version : "2.3.4" ,
826+ })
827+
828+ Expect (resultErr ).To (HaveOccurred ())
829+ Expect (component .IsErrNotFound (resultErr )).To (BeTrue ())
830+ })
831+ })
832+ })
833+
768834 When ("a bosh release is not found" , func () {
769835 When ("there are no files" , func () {
770836 BeforeEach (func () {
0 commit comments