You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/10/22 18:00:48 UTC

[GitHub] [maven-resolver] gnodet commented on a diff in pull request #203: [MRESOLVER-279] Simplify and improve trusted checksum sources

gnodet commented on code in PR #203:
URL: https://github.com/apache/maven-resolver/pull/203#discussion_r1002547214


##########
maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/checksum/FileTrustedChecksumsSourceTestSupport.java:
##########
@@ -51,58 +56,79 @@
 
     private FileTrustedChecksumsSourceSupport subject;
 
+    private boolean checksumWritten;
+
     @Before
     public void before() throws Exception
     {
         session = TestUtils.newSession();
         // populate local repository
-        Path basedir = session.getLocalRepository().getBasedir().toPath()
-                .resolve( FileTrustedChecksumsSourceSupport.LOCAL_REPO_PREFIX_DIR );
         checksumAlgorithmFactory = new Sha1ChecksumAlgorithmFactory();
-        subject = prepareSubject( basedir );
+        subject = prepareSubject();
+        checksumWritten = false;
+
+        try ( DefaultRepositorySystemSession prepareSession = new DefaultRepositorySystemSession( session ) )
+        {
+            enableSource( prepareSession );
+            try ( TrustedChecksumsSource.Writer writer = subject.getTrustedArtifactChecksumsWriter( prepareSession ) )
+            {
+                if ( writer != null )
+                {
+                    HashMap<String, String> checksums = new HashMap<>();
+                    checksums.put( checksumAlgorithmFactory.getName(), ARTIFACT_TRUSTED_CHECKSUM );
+                    writer.addTrustedArtifactChecksums( ARTIFACT_WITH_CHECKSUM, prepareSession.getLocalRepository(),
+                            Collections.singletonList( checksumAlgorithmFactory ), checksums );
+                    checksumWritten = true;
+                }
+            }
+        }
     }
 
-    protected abstract FileTrustedChecksumsSourceSupport prepareSubject( Path basedir ) throws IOException;
+    protected abstract FileTrustedChecksumsSourceSupport prepareSubject();
 
-    protected abstract void enableSource();
+    protected abstract void enableSource( DefaultRepositorySystemSession session );

Review Comment:
   I don't see the `session` parameter used.  Did I miss something ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org