Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to support new rubygems.org API #9

Merged
merged 24 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
248b901
First pass adding V2 rubygems.org API support
headius Jul 19, 2023
a8d66d8
Deprecate tests using removed Marshal.4.8 api
headius Jul 20, 2023
6b18c7b
Update to JRuby 9.4.3.0
headius Jul 20, 2023
44dfde1
Add sonatype snapshots repo
headius Jul 20, 2023
c28d903
Tweak tests and versions to get tests passing
headius Jul 21, 2023
2a4000e
Use latest dependency graph plugin
headius Jul 21, 2023
7f5a586
Get more of V2 API working
headius Jul 26, 2023
f86ed41
Start hooking up gem stuff to new API
headius Jul 26, 2023
ed8513b
Missed files from API V2 and Gem testing
headius Jul 26, 2023
ebbf4d4
Unneeded file
headius Jul 26, 2023
f75d6ed
Start deprecating some defunct API stuff
headius Jul 26, 2023
06c7054
Start adding "info" compact index endpoint
headius Jul 26, 2023
3359dcf
Hook up compact and v2 to get most things working
headius Jul 27, 2023
bbd3689
Tweak tests for new local storage locations
headius Jul 27, 2023
e74ea43
Update dependencies to build a snapshot
headius Jul 28, 2023
794e6eb
Move to org.jruby.maven group ID
headius Jul 31, 2023
99b18ea
More tweaks to tests for the new formats
headius Jul 31, 2023
cb41dc7
Move user-agent to constant and add maven coords
headius Jul 31, 2023
1f12746
Use real gems to get more of these working
headius Jul 31, 2023
1964632
Hook up most v1/deps URLs to compact index
headius Jul 31, 2023
dc7b460
Use compact index to hook up bundler API
headius Aug 1, 2023
3d8fe11
Tweaks for specs to run with new API
headius Aug 1, 2023
4ffee02
Fix Maven downloaded message format
headius Aug 1, 2023
9d9d631
Bump version to 2.0
headius Aug 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ jobs:

# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
- name: Update dependency graph
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
if: github.ref == 'refs/heads/master'
uses: advanced-security/maven-dependency-submission-action@v3
6 changes: 3 additions & 3 deletions mavengem-protocol/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>mavengem</artifactId>
<groupId>org.torquebox.mojo</groupId>
<version>1.0.4-SNAPSHOT</version>
<groupId>org.jruby.maven</groupId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>mavengem-protocol</artifactId>

Expand All @@ -13,7 +13,7 @@

<dependencies>
<dependency>
<groupId>org.torquebox.mojo</groupId>
<groupId>org.jruby.maven</groupId>
<artifactId>rubygems-tools</artifactId>
<version>${project.version}</version>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,6 @@ public void registerProtocol() throws Exception {
assertThat(Handler.registerMavenGemProtocol(), is(false));
}

@Test
public void virtusPomWithAuthentication() throws Exception {
// this test goes online to rubygems.org
File cached = new File(cacheDir, "http___rubygems_org/quick/Marshal.4.8/v/virtus-1.0.5.gemspec.rz");
cached.delete();
URL url = new URL("mavengem:http://me:[email protected]/maven/releases/rubygems/virtus/1.0.5/virtus-1.0.5.pom");
try (InputStream in = url.openStream()) {
// just read the file
byte[] data = new byte[in.available()];
in.read(data, 0, in.available());
}
// the cached dir does not expose the credentials
assertThat(cached.getPath(), cached.exists(), is(true));
}

@Test
public void ping() throws Exception {
URL url = new URL("mavengem:https://rubygems.org/something/maven/releases/ping");
Expand All @@ -60,7 +45,7 @@ public void ping() throws Exception {
@Test
public void railsMavenMetadata() throws Exception {
// this test goes online to rubygems.org
File cached = new File(cacheDir, "https___rubygems_org/api/v1/dependencies/rails.ruby");
File cached = new File(cacheDir, "https___rubygems_org/info/rails.compact");
cached.delete();
URL url = new URL("mavengem:https://rubygems.org/maven/releases/rubygems/rails/maven-metadata.xml");
try (InputStream in = url.openStream()) {
Expand All @@ -77,7 +62,7 @@ public void railsMavenMetadata() throws Exception {
@Test
public void railsPom() throws Exception {
// this test goes online to rubygems.org
File cached = new File(cacheDir, "https___rubygems_org/quick/Marshal.4.8/r/rails-4.2.5.gemspec.rz");
File cached = new File(cacheDir, "https___rubygems_org/api/v2/rubygems/rails/versions/4.2.5.json");
cached.delete();
URL url = new URL("mavengem:https://rubygems.org/maven/releases/rubygems/rails/4.2.5/rails-4.2.5.pom");
try (InputStream in = url.openStream()) {
Expand Down Expand Up @@ -106,4 +91,19 @@ public void fileNotFoundOnDirectory() throws Exception {
URL url = new URL("mavengem:https://rubygems.org/maven/releases/rubygems/rails");
url.openStream();
}

@Deprecated
public void virtusPomWithAuthentication() throws Exception {
// this test goes online to rubygems.org
File cached = new File(cacheDir, "http___rubygems_org/quick/Marshal.4.8/v/virtus-1.0.5.gemspec.rz");
cached.delete();
URL url = new URL("mavengem:http://me:[email protected]/maven/releases/rubygems/virtus/1.0.5/virtus-1.0.5.pom");
try (InputStream in = url.openStream()) {
// just read the file
byte[] data = new byte[in.available()];
in.read(data, 0, in.available());
}
// the cached dir does not expose the credentials
assertThat(cached.getPath(), cached.exists(), is(true));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,68 +28,6 @@ public void setup() throws Exception {
factory = new RubygemsFactory(cacheDir);
}

@Test
public void virtusPomWithAuthentication() throws Exception {
// this test goes online to rubygems.org
File cached = new File(cacheDir, "http___rubygems_org/quick/Marshal.4.8/v/virtus-1.0.5.gemspec.rz");

// with the /maven/releases prefix
URLConnection url = new MavenGemURLConnection(factory, new URL("http://me:[email protected]"), "/maven/releases/rubygems/virtus/1.0.5/virtus-1.0.5.pom");

// the cached dir does not expose the credentials
assertCached(url, cached);

// without the /maven/releases prefix
url = new MavenGemURLConnection(factory, new URL("http://me:[email protected]"), "/rubygems/virtus/1.0.5/virtus-1.0.5.pom");

// the cached dir does not expose the credentials
assertCached(url, cached);
}

@Test
public void virtusPomWithMirror() throws Exception {
// this test goes online to rubygems.org
File cached = new File(cacheDir, "http___rubygems_org/quick/Marshal.4.8/v/virtus-1.0.5.gemspec.rz");
RubygemsFactory factory = new RubygemsFactory(cacheDir, new URL("http://me:[email protected]"));

// with the /maven/releases prefix
URLConnection url = new MavenGemURLConnection(factory, new URL("http://example.com"), "/maven/releases/rubygems/virtus/1.0.5/virtus-1.0.5.pom");

// the cached dir does not expose the credentials
assertCached(url, cached);

// without the /maven/releases prefix
url = new MavenGemURLConnection(factory, new URL("http://example.com"), "/rubygems/virtus/1.0.5/virtus-1.0.5.pom");

// the cached dir does not expose the credentials
assertCached(url, cached);
}

@Test
public void virtusPomWithMirrors() throws Exception {
// this test goes online to rubygems.org
File cached = new File(cacheDir, "http___rubygems_org/quick/Marshal.4.8/v/virtus-1.0.5.gemspec.rz");
Map<URL, URL> mirrors = new HashMap<URL, URL>();
mirrors.put(new URL("http://example.com"), new URL("http://me:[email protected]"));
mirrors.put(new URL("http://hans:[email protected]"), new URL("http://rubygems.org"));
RubygemsFactory factory = new RubygemsFactory(cacheDir, mirrors);

// with the /maven/releases prefix
URLConnection url = new MavenGemURLConnection(factory, new URL("http://example.com"), "/maven/releases/rubygems/virtus/1.0.5/virtus-1.0.5.pom");

// the cached dir does not expose the credentials
assertCached(url, cached);

// without the /maven/releases prefix
url = new MavenGemURLConnection(factory, new URL("http://example.org"), "/rubygems/virtus/1.0.5/virtus-1.0.5.pom");
assertCached(url, cached);

// go direct here
cached = new File(cacheDir, "https___rubygems_org/quick/Marshal.4.8/v/virtus-1.0.5.gemspec.rz");
url = new MavenGemURLConnection(factory, new URL("https://rubygems.org"), "/rubygems/virtus/1.0.5/virtus-1.0.5.pom");
assertCached(url, cached);
}

private void assertCached(URLConnection url, File cached) throws Exception {
cached.delete();
try (InputStream in = url.getInputStream()) {
Expand All @@ -113,7 +51,7 @@ public void ping() throws Exception {
@Test
public void railsMavenMetadata() throws Exception {
// this test goes online to rubygems.org
File cached = new File(cacheDir, "https___rubygems_org/api/v1/dependencies/rails.ruby");
File cached = new File(cacheDir, "https___rubygems_org/info/rails.compact");
cached.delete();
URLConnection url = new MavenGemURLConnection(factory, new URL("https://rubygems.org"), "/maven/releases/rubygems/rails/maven-metadata.xml");
String result = download(url);
Expand All @@ -135,7 +73,7 @@ String download(URLConnection url) throws Exception {
@Test
public void railsPom() throws Exception {
// this test goes online to rubygems.org
File cached = new File(cacheDir, "https___rubygems_org/quick/Marshal.4.8/r/rails-4.2.5.gemspec.rz");
File cached = new File(cacheDir, "https___rubygems_org/api/v2/rubygems/rails/versions/4.2.5.json");
cached.delete();
URLConnection url = new MavenGemURLConnection(factory, new URL("https://rubygems.org"), "/rubygems/rails/4.2.5/rails-4.2.5.pom");
String result = download(url);
Expand All @@ -161,4 +99,66 @@ public void fileNotFoundOnDirectory() throws Exception {
URLConnection url = new MavenGemURLConnection(factory, new URL("https://rubygems.org"), "/maven/releases/rubygems/rails");
url.getInputStream();
}

@Deprecated
public void virtusPomWithAuthentication() throws Exception {
// this test goes online to rubygems.org
File cached = new File(cacheDir, "http___rubygems_org/quick/Marshal.4.8/v/virtus-1.0.5.gemspec.rz");

// with the /maven/releases prefix
URLConnection url = new MavenGemURLConnection(factory, new URL("http://me:[email protected]"), "/maven/releases/rubygems/virtus/1.0.5/virtus-1.0.5.pom");

// the cached dir does not expose the credentials
assertCached(url, cached);

// without the /maven/releases prefix
url = new MavenGemURLConnection(factory, new URL("http://me:[email protected]"), "/rubygems/virtus/1.0.5/virtus-1.0.5.pom");

// the cached dir does not expose the credentials
assertCached(url, cached);
}

@Deprecated
public void virtusPomWithMirror() throws Exception {
// this test goes online to rubygems.org
File cached = new File(cacheDir, "http___rubygems_org/quick/Marshal.4.8/v/virtus-1.0.5.gemspec.rz");
RubygemsFactory factory = new RubygemsFactory(cacheDir, new URL("http://me:[email protected]"));

// with the /maven/releases prefix
URLConnection url = new MavenGemURLConnection(factory, new URL("http://example.com"), "/maven/releases/rubygems/virtus/1.0.5/virtus-1.0.5.pom");

// the cached dir does not expose the credentials
assertCached(url, cached);

// without the /maven/releases prefix
url = new MavenGemURLConnection(factory, new URL("http://example.com"), "/rubygems/virtus/1.0.5/virtus-1.0.5.pom");

// the cached dir does not expose the credentials
assertCached(url, cached);
}

@Deprecated
public void virtusPomWithMirrors() throws Exception {
// this test goes online to rubygems.org
File cached = new File(cacheDir, "http___rubygems_org/quick/Marshal.4.8/v/virtus-1.0.5.gemspec.rz");
Map<URL, URL> mirrors = new HashMap<URL, URL>();
mirrors.put(new URL("http://example.com"), new URL("http://me:[email protected]"));
mirrors.put(new URL("http://hans:[email protected]"), new URL("http://rubygems.org"));
RubygemsFactory factory = new RubygemsFactory(cacheDir, mirrors);

// with the /maven/releases prefix
URLConnection url = new MavenGemURLConnection(factory, new URL("http://example.com"), "/maven/releases/rubygems/virtus/1.0.5/virtus-1.0.5.pom");

// the cached dir does not expose the credentials
assertCached(url, cached);

// without the /maven/releases prefix
url = new MavenGemURLConnection(factory, new URL("http://example.org"), "/rubygems/virtus/1.0.5/virtus-1.0.5.pom");
assertCached(url, cached);

// go direct here
cached = new File(cacheDir, "https___rubygems_org/quick/Marshal.4.8/v/virtus-1.0.5.gemspec.rz");
url = new MavenGemURLConnection(factory, new URL("https://rubygems.org"), "/rubygems/virtus/1.0.5/virtus-1.0.5.pom");
assertCached(url, cached);
}
}
6 changes: 3 additions & 3 deletions mavengem-wagon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>mavengem</artifactId>
<groupId>org.torquebox.mojo</groupId>
<version>1.0.4-SNAPSHOT</version>
<groupId>org.jruby.maven</groupId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>mavengem-wagon</artifactId>
<name>Mavengem Protocol Wagon</name>

<dependencies>
<dependency>
<groupId>org.torquebox.mojo</groupId>
<groupId>org.jruby.maven</groupId>
<artifactId>mavengem-protocol</artifactId>
<version>${project.version}</version>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion mavengem-wagon/src/it/mirror_with_auth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<extension>
<groupId>org.torquebox.mojo</groupId>
<artifactId>mavengem-wagon</artifactId>
<version>@project.version@</version>
<version>1.0.3</version>
</extension>
</extensions>
</build>
Expand Down
2 changes: 1 addition & 1 deletion mavengem-wagon/src/it/mirror_with_auth/postbuild.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.codehaus.plexus.util.FileUtils

String log = FileUtils.fileRead( new File( basedir, "build.log" ) );

[ "Downloaded: mavengem:http://rubygems.org/rubygems/jar-dependencies/0.2.6/jar-dependencies-0.2.6.pom", "Downloaded: mavengem:http://rubygems.org/rubygems/jar-dependencies/0.2.6/jar-dependencies-0.2.6.gem" ].each {
[ "Downloaded from mavengems-with-mirror-with-auth: mavengem:http://rubygems.org/rubygems/jar-dependencies/0.2.6/jar-dependencies-0.2.6.pom", "Downloaded from mavengems-with-mirror-with-auth: mavengem:http://rubygems.org/rubygems/jar-dependencies/0.2.6/jar-dependencies-0.2.6.gem" ].each {

if ( !log.contains( it ) ) throw new RuntimeException( "log file does not contain '" + it + "'" );

Expand Down
2 changes: 1 addition & 1 deletion mavengem-wagon/src/it/mirror_without_auth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<extension>
<groupId>org.torquebox.mojo</groupId>
<artifactId>mavengem-wagon</artifactId>
<version>@project.version@</version>
<version>1.0.3</version>
</extension>
</extensions>
</build>
Expand Down
2 changes: 1 addition & 1 deletion mavengem-wagon/src/it/mirror_without_auth/postbuild.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.codehaus.plexus.util.FileUtils

String log = FileUtils.fileRead( new File( basedir, "build.log" ) );

[ "Downloaded: mavengem:http://rubygems.org/rubygems/jar-dependencies/0.2.6/jar-dependencies-0.2.6.pom", "Downloaded: mavengem:http://rubygems.org/rubygems/jar-dependencies/0.2.6/jar-dependencies-0.2.6.gem" ].each {
[ "Downloaded from mavengems-with-mirror: mavengem:http://rubygems.org/rubygems/jar-dependencies/0.2.6/jar-dependencies-0.2.6.pom", "Downloaded from mavengems-with-mirror: mavengem:http://rubygems.org/rubygems/jar-dependencies/0.2.6/jar-dependencies-0.2.6.gem" ].each {

if ( !log.contains( it ) ) throw new RuntimeException( "log file does not contain '" + it + "'" );

Expand Down
2 changes: 1 addition & 1 deletion mavengem-wagon/src/it/no_mirror_with_auth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<extension>
<groupId>org.torquebox.mojo</groupId>
<artifactId>mavengem-wagon</artifactId>
<version>@project.version@</version>
<version>1.0.3</version>
</extension>
</extensions>
</build>
Expand Down
2 changes: 1 addition & 1 deletion mavengem-wagon/src/it/no_mirror_with_auth/postbuild.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.codehaus.plexus.util.FileUtils

String log = FileUtils.fileRead( new File( basedir, "build.log" ) );

[ "Downloaded: mavengem:https://rubygems.org/rubygems/jar-dependencies/0.2.6/jar-dependencies-0.2.6.pom", "Downloaded: mavengem:https://rubygems.org/rubygems/jar-dependencies/0.2.6/jar-dependencies-0.2.6.gem" ].each {
[ "Downloaded from mavengems-without-mirror-with-auth: mavengem:https://rubygems.org/rubygems/jar-dependencies/0.2.6/jar-dependencies-0.2.6.pom", "Downloaded from mavengems-without-mirror-with-auth: mavengem:https://rubygems.org/rubygems/jar-dependencies/0.2.6/jar-dependencies-0.2.6.gem" ].each {

if ( !log.contains( it ) ) throw new RuntimeException( "log file does not contain '" + it + "'" );

Expand Down
2 changes: 1 addition & 1 deletion mavengem-wagon/src/it/no_mirror_without_auth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<extension>
<groupId>org.torquebox.mojo</groupId>
<artifactId>mavengem-wagon</artifactId>
<version>@project.version@</version>
<version>1.0.3</version>
</extension>
</extensions>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.codehaus.plexus.util.FileUtils

String log = FileUtils.fileRead( new File( basedir, "build.log" ) );

[ "Downloaded: mavengem:https://rubygems.org/rubygems/jar-dependencies/0.2.6/jar-dependencies-0.2.6.pom", "Downloaded: mavengem:https://rubygems.org/rubygems/jar-dependencies/0.2.6/jar-dependencies-0.2.6.gem" ].each {
[ "Downloaded from mavengems-without-mirror: mavengem:https://rubygems.org/rubygems/jar-dependencies/0.2.6/jar-dependencies-0.2.6.pom", "Downloaded from mavengems-without-mirror: mavengem:https://rubygems.org/rubygems/jar-dependencies/0.2.6/jar-dependencies-0.2.6.gem" ].each {

if ( !log.contains( it ) ) throw new RuntimeException( "log file does not contain '" + it + "'" );

Expand Down
32 changes: 29 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<artifactId>oss-parent</artifactId>
<version>9</version>
</parent>
<groupId>org.torquebox.mojo</groupId>
<groupId>org.jruby.maven</groupId>
<artifactId>mavengem</artifactId>
<version>1.0.4-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Mavengem Protocol and Mavengem Wagon</name>

Expand Down Expand Up @@ -46,9 +46,35 @@
</modules>

<properties>
<jruby.version>9.1.17.0</jruby.version>
<jruby.version>9.4.3.0</jruby.version>
</properties>

<repositories>
<repository>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</pluginRepository>
</pluginRepositories>

<build>
<pluginManagement>
<plugins>
Expand Down
Loading