org.commonjava.indy.httprox.RetrievedPomWithoutUserSuffixUntrackedTest Maven / Gradle / Ivy
/**
* Copyright (C) 2011-2022 Red Hat, Inc. (https://github.com/Commonjava/indy)
*
* 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.
*/
package org.commonjava.indy.httprox;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import java.io.InputStream;
import java.util.Collection;
import java.util.Collections;
import org.apache.commons.io.IOUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.commonjava.indy.client.core.IndyClientModule;
import org.commonjava.indy.client.core.helper.HttpResources;
import org.commonjava.indy.folo.client.IndyFoloAdminClientModule;
import org.commonjava.indy.folo.model.TrackedContentRecord;
import org.junit.Test;
public class RetrievedPomWithoutUserSuffixUntrackedTest
extends AbstractHttproxFunctionalTest
{
private static final String USER = "user";
private static final String PASS = "password";
@Test
public void run()
throws Exception
{
final String testRepo = "test";
final PomRef pom = loadPom( "simple.pom", Collections. emptyMap() );
final String url = server.formatUrl( testRepo, pom.path );
server.expect( url, 200, pom.pom );
final HttpGet get = new HttpGet( url );
final CloseableHttpClient client = proxiedHttp();
CloseableHttpResponse response = null;
InputStream stream = null;
try
{
response = client.execute( get, proxyContext( USER, PASS ) );
assertThat( response.getStatusLine()
.getStatusCode(), equalTo( 200 ) );
stream = response.getEntity()
.getContent();
final String resultingPom = IOUtils.toString( stream );
assertThat( resultingPom, notNullValue() );
assertThat( resultingPom, equalTo( pom.pom ) );
}
finally
{
IOUtils.closeQuietly( stream );
HttpResources.cleanupResources( get, response, client );
}
//**/ Disabled test behavior because it is affecting auding logs for folo recorrds
// and it is using depriciated methods and event propagation for infinispan cache
// final TrackedContentRecord record = this.client.module( IndyFoloAdminClientModule.class )
// .getRawTrackingRecord( USER );
// assertThat( record, nullValue() );
}
@Override
protected Collection getAdditionalClientModules()
{
return Collections. singleton( new IndyFoloAdminClientModule() );
}
@Override
protected String getAdditionalHttproxConfig()
{
return "tracking.type=suffix";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy