mirror of https://github.com/apache/maven.git
[MNG-7128] test blocked HTTP repository in pom.xml
This commit is contained in:
parent
0e982c2c9a
commit
a3d6fac56a
|
@ -106,6 +106,7 @@ public class IntegrationTestSuite
|
|||
// Tests that don't run stable and need to be fixed
|
||||
// -------------------------------------------------------------------------------------------------------------
|
||||
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
|
||||
suite.addTestSuite( MavenITmng7128BlockExternalHttpReactorTest.class );
|
||||
suite.addTestSuite( MavenITmng6511OptionalProjectSelectionTest.class );
|
||||
suite.addTestSuite( MavenITmng7110ExtensionClassloader.class );
|
||||
suite.addTestSuite( MavenITmng7051OptionalProfileActivationTest.class );
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
package org.apache.maven.it;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class MavenITmng7128BlockExternalHttpReactorTest
|
||||
extends AbstractMavenIntegrationTestCase
|
||||
{
|
||||
private static final String PROJECT_PATH = "/mng-7128-block-external-http-reactor";
|
||||
|
||||
public MavenITmng7128BlockExternalHttpReactorTest()
|
||||
{
|
||||
super( "[3.8.1,)" );
|
||||
}
|
||||
|
||||
/**
|
||||
* This test verifies that defining a repository in pom.xml that uses HTTP is blocked.
|
||||
*/
|
||||
public void testBlockedHttpRepositoryInPom() throws IOException, VerificationException
|
||||
{
|
||||
final File projectDir = ResourceExtractor.simpleExtractResources( getClass(), PROJECT_PATH );
|
||||
final Verifier verifier = newVerifier( projectDir.getAbsolutePath() );
|
||||
verifier.addCliOption( "-s settings.xml" ); // ITs override global settings that provide blocked mirror: need to define the mirror in dedicated settings
|
||||
|
||||
try
|
||||
{
|
||||
verifier.executeGoal( "compiler:compile" );
|
||||
fail( "HTTP repository defined in pom.xml should have failed the build but did not." );
|
||||
}
|
||||
catch ( VerificationException ve )
|
||||
{
|
||||
// Inspect the reason why the build broke.
|
||||
verifier.verifyTextInLog( "[ERROR] Failed to execute goal on project http-repository-in-pom: "
|
||||
+ "Could not resolve dependencies for project org.apache.maven.its.mng7128:http-repository-in-pom:jar:1.0: "
|
||||
+ "Failed to collect dependencies at junit:junit:jar:1.3: "
|
||||
+ "Failed to read artifact descriptor for junit:junit:jar:1.3: "
|
||||
+ "Could not transfer artifact junit:junit:pom:1.3 from/to maven-default-http-blocker (http://0.0.0.0/): " // mirror introduced in MNG-7118
|
||||
+ "Blocked mirror for repositories: [insecure-http-repo (http://repo.maven.apache.org/, default, releases+snapshots)]" );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.apache.maven.its.mng7128</groupId>
|
||||
<artifactId>http-repository-in-pom</artifactId>
|
||||
<version>1.0</version>
|
||||
|
||||
<name>Maven Integration Test :: MNG-7128</name>
|
||||
<description>
|
||||
Define a HTTP repository in this reactor pom.xml: check that it is blocked.
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>1.3</version><!-- version intentionally not available in central to trigger download from defined repository -->
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>insecure-http-repo</id>
|
||||
<name>HTTP repository: should be blocked</name>
|
||||
<url>http://repo.maven.apache.org/</url><!-- intentionally insecure HTTP -->
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you 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.
|
||||
-->
|
||||
|
||||
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
|
||||
<mirrors>
|
||||
<mirror><!-- copied from Maven default settings.xml -->
|
||||
<id>maven-default-http-blocker</id>
|
||||
<mirrorOf>external:http:*</mirrorOf>
|
||||
<name>Pseudo repository to mirror external repositories initially using HTTP.</name>
|
||||
<url>http://0.0.0.0/</url>
|
||||
<blocked>true</blocked>
|
||||
</mirror>
|
||||
</mirrors>
|
||||
</settings>
|
Loading…
Reference in New Issue