]> source.dussan.org Git - archiva.git/commitdiff
[MRM-154] digest utils parses filename incorrectly
authorBrett Porter <brett@apache.org>
Fri, 1 Sep 2006 04:28:31 +0000 (04:28 +0000)
committerBrett Porter <brett@apache.org>
Fri, 1 Sep 2006 04:28:31 +0000 (04:28 +0000)
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

archiva-utils/src/main/java/org/apache/maven/archiva/digest/DigestUtils.java
archiva-utils/src/test/java/org/apache/maven/archiva/digest/DigestUtilsTest.java [new file with mode: 0644]

index e006284f1d573e4615561b37db310694c95ff9a7..8cb659f2af6a84b1bf7603a2502c54c0fe0d32f4 100644 (file)
@@ -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 (file)
index 0000000..c4deb5d
--- /dev/null
@@ -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" );
+    }
+}