From: Brett Porter Date: Fri, 1 Sep 2006 04:28:31 +0000 (+0000) Subject: [MRM-154] digest utils parses filename incorrectly X-Git-Tag: archiva-0.9-alpha-1~627 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d9e50a8d307929bbef0efa8992628f5b6f6cf5fd;p=archiva.git [MRM-154] digest utils parses filename incorrectly Submitted by: Nicolas de Loof (applied with changes) git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@439172 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-utils/src/main/java/org/apache/maven/archiva/digest/DigestUtils.java b/archiva-utils/src/main/java/org/apache/maven/archiva/digest/DigestUtils.java index e006284f1..8cb659f2a 100644 --- a/archiva-utils/src/main/java/org/apache/maven/archiva/digest/DigestUtils.java +++ b/archiva-utils/src/main/java/org/apache/maven/archiva/digest/DigestUtils.java @@ -42,7 +42,7 @@ public class DigestUtils if ( m.matches() ) { String filename = m.group( 1 ); - if ( !path.endsWith( filename ) ) + if ( !filename.endsWith( path ) ) { throw new DigesterException( "Supplied checksum does not match checksum pattern" ); } @@ -55,7 +55,7 @@ public class DigestUtils if ( m.matches() ) { String filename = m.group( 2 ); - if ( !path.endsWith( filename ) ) + if ( !filename.endsWith( path ) ) { throw new DigesterException( "Supplied checksum does not match checksum pattern" ); } diff --git a/archiva-utils/src/test/java/org/apache/maven/archiva/digest/DigestUtilsTest.java b/archiva-utils/src/test/java/org/apache/maven/archiva/digest/DigestUtilsTest.java new file mode 100644 index 000000000..c4deb5d99 --- /dev/null +++ b/archiva-utils/src/test/java/org/apache/maven/archiva/digest/DigestUtilsTest.java @@ -0,0 +1,36 @@ +package org.apache.maven.archiva.digest; + +/* + * Copyright 2005-2006 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import junit.framework.TestCase; + +public class DigestUtilsTest + extends TestCase +{ + public void testCleanChecksum() + throws DigesterException + { + // SHA1 checksum from www.ibiblio.org/maven2, incuding file path + DigestUtils.cleanChecksum( + "bcc82975c0f9c681fcb01cc38504c992553e93ba /home/projects/maven/repository-staging/to-ibiblio/maven2/servletapi/servletapi/2.4/servletapi-2.4.pom", + "SHA1", "servletapi/servletapi/2.4/servletapi-2.4.pom" ); + + DigestUtils.cleanChecksum( + "SHA1(/home/projects/maven/repository-staging/to-ibiblio/maven2/servletapi/servletapi/2.4/servletapi-2.4.pom)=bcc82975c0f9c681fcb01cc38504c992553e93ba", + "SHA1", "servletapi/servletapi/2.4/servletapi-2.4.pom" ); + } +}