mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-18 05:22:10 +01:00
Merge pull request #1256 from scm-manager/bugfix/proxy_exclusion
ignore ports on proxy exclusions
This commit is contained in:
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Fixed error in update step ([#1237](https://github.com/scm-manager/scm-manager/issues/1237) and [#1244](https://github.com/scm-manager/scm-manager/issues/1244))
|
||||
- Fix incorrect trimming of whitespaces in helm chart templates
|
||||
- Fixed error on empty diff expand response ([#1247](https://github.com/scm-manager/scm-manager/pull/1247))
|
||||
- Ignore ports on proxy exclusions ([#1256](https://github.com/scm-manager/scm-manager/pull/1256))
|
||||
|
||||
## [2.2.0] - 2020-07-03
|
||||
### Added
|
||||
|
||||
@@ -91,6 +91,13 @@ public final class Proxies
|
||||
url = url.substring(0, index);
|
||||
}
|
||||
|
||||
index = url.indexOf(':');
|
||||
|
||||
if (index > 0)
|
||||
{
|
||||
url = url.substring(0, index);
|
||||
}
|
||||
|
||||
for (String exclude : configuration.getProxyExcludes())
|
||||
{
|
||||
if (GlobUtil.matches(exclude, url))
|
||||
|
||||
@@ -21,99 +21,65 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.net;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import sonia.scm.config.ScmConfiguration;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class ProxiesTest
|
||||
{
|
||||
public class ProxiesTest {
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testDisabledWithoutExcludes()
|
||||
{
|
||||
public void testDisabledWithoutExcludes() {
|
||||
ScmConfiguration config = createConfiguration(false);
|
||||
|
||||
assertFalse(Proxies.isEnabled(config, "localhost"));
|
||||
assertFalse(Proxies.isEnabled(config, "localhost:8082"));
|
||||
assertFalse(Proxies.isEnabled(config, "download.scm-manager.org"));
|
||||
assertFalse(Proxies.isEnabled(config, "http://127.0.0.1"));
|
||||
assertFalse(Proxies.isEnabled(config, "http://127.0.0.1/test/ka"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testEnabledWithoutExcludes()
|
||||
{
|
||||
public void testEnabledWithoutExcludes() {
|
||||
ScmConfiguration config = createConfiguration(true);
|
||||
|
||||
assertTrue(Proxies.isEnabled(config, "localhost"));
|
||||
assertTrue(Proxies.isEnabled(config, "localhost:8082"));
|
||||
assertTrue(Proxies.isEnabled(config, "download.scm-manager.org"));
|
||||
assertTrue(Proxies.isEnabled(config, "http://127.0.0.1"));
|
||||
assertTrue(Proxies.isEnabled(config, "http://127.0.0.1/test/ka"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testWithExcludes()
|
||||
{
|
||||
public void testWithExcludes() {
|
||||
ScmConfiguration config = createConfiguration(true, "127.0.0.1",
|
||||
"localhost");
|
||||
"localhost");
|
||||
|
||||
assertFalse(Proxies.isEnabled(config, "localhost"));
|
||||
assertFalse(Proxies.isEnabled(config, "localhost:8082"));
|
||||
assertTrue(Proxies.isEnabled(config, "download.scm-manager.org"));
|
||||
assertFalse(Proxies.isEnabled(config, "http://127.0.0.1"));
|
||||
assertFalse(Proxies.isEnabled(config, "http://127.0.0.1/test/ka"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testWithGlobExcludes()
|
||||
{
|
||||
public void testWithGlobExcludes() {
|
||||
ScmConfiguration config = createConfiguration(true, "127.*", "*host");
|
||||
|
||||
assertFalse(Proxies.isEnabled(config, "localhost"));
|
||||
assertFalse(Proxies.isEnabled(config, "localhost:8082"));
|
||||
assertTrue(Proxies.isEnabled(config, "download.scm-manager.org"));
|
||||
assertFalse(Proxies.isEnabled(config, "http://127.0.0.1"));
|
||||
assertFalse(Proxies.isEnabled(config, "http://127.0.0.1/test/ka"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param enabled
|
||||
* @param excludes
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private ScmConfiguration createConfiguration(boolean enabled,
|
||||
String... excludes)
|
||||
{
|
||||
String... excludes) {
|
||||
ScmConfiguration configuration = new ScmConfiguration();
|
||||
|
||||
configuration.setEnableProxy(enabled);
|
||||
|
||||
Reference in New Issue
Block a user