Search in sources :

Example 6 with TestURLBuilder

use of com.mercedesbenz.sechub.test.TestURLBuilder in project sechub by mercedes-benz.

the class TestAPI method changeScanMappingDirectly.

/**
 * Changes scan mapping DIRECTLY ! Means without administration domain, but
 * directly in scan domain - interesting for testing only,
 *
 * @param json
 */
public static void changeScanMappingDirectly(String mappingId, MappingEntry... entries) {
    MappingData data = new MappingData();
    for (MappingEntry entry : entries) {
        data.getEntries().add(entry);
    }
    TestURLBuilder urlBuilder = IntegrationTestContext.get().getUrlBuilder();
    String url = urlBuilder.buildIntegrationTestChangeMappingDirectlyURL(mappingId);
    IntegrationTestContext.get().getRestHelper(ANONYMOUS).putJSON(url, data.toJSON());
}
Also used : MappingEntry(com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry) TestURLBuilder(com.mercedesbenz.sechub.test.TestURLBuilder) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData)

Example 7 with TestURLBuilder

use of com.mercedesbenz.sechub.test.TestURLBuilder in project sechub by mercedes-benz.

the class TestAPI method fetchMappingDataDirectlyOrNull.

public static MappingData fetchMappingDataDirectlyOrNull(String mappingId) {
    TestURLBuilder urlBuilder = IntegrationTestContext.get().getUrlBuilder();
    String url = urlBuilder.buildIntegrationTestFetchMappingDirectlyURL(mappingId);
    String result = IntegrationTestContext.get().getRestHelper(ANONYMOUS).getJSON(url);
    if (result == null) {
        return null;
    }
    MappingData data = MappingData.fromString(result);
    return data;
}
Also used : TestURLBuilder(com.mercedesbenz.sechub.test.TestURLBuilder) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData)

Example 8 with TestURLBuilder

use of com.mercedesbenz.sechub.test.TestURLBuilder in project sechub by mercedes-benz.

the class DeveloperAdministration method getUrlBuilder.

public TestURLBuilder getUrlBuilder() {
    if (urlBuilder == null) {
        int port = provider.getPort();
        String server = provider.getServer();
        urlBuilder = new TestURLBuilder(provider.getProtocol(), port, server);
    }
    return urlBuilder;
}
Also used : TestURLBuilder(com.mercedesbenz.sechub.test.TestURLBuilder)

Example 9 with TestURLBuilder

use of com.mercedesbenz.sechub.test.TestURLBuilder in project sechub by mercedes-benz.

the class TestAPI method getFileUploaded.

/**
 * Get uploaded file (means download former uploaded file) from integration test
 * server
 *
 * @param project
 * @param jobUUID
 * @param fileName
 * @return file or <code>null</code> when not found
 * @throws IllegalStateException when other problems are occurring
 */
public static File getFileUploaded(TestProject project, UUID jobUUID, String fileName) {
    TestURLBuilder urlBuilder = IntegrationTestContext.get().getUrlBuilder();
    String url = urlBuilder.buildGetFileUpload(project.getProjectId(), jobUUID.toString(), fileName);
    try {
        File file = as(ANONYMOUS).downloadAsTempFileFromURL(url, jobUUID);
        return file;
    } catch (HttpStatusCodeException e) {
        if (HttpStatus.NOT_FOUND.equals(e.getStatusCode())) {
            /* okay, just not existing ... */
            return null;
        }
        throw new IllegalStateException("Odd status code:" + e.getStatusCode() + ", message:" + e.getMessage(), e);
    }
}
Also used : TestURLBuilder(com.mercedesbenz.sechub.test.TestURLBuilder) HttpStatusCodeException(org.springframework.web.client.HttpStatusCodeException) File(java.io.File)

Example 10 with TestURLBuilder

use of com.mercedesbenz.sechub.test.TestURLBuilder in project sechub by mercedes-benz.

the class TestAPI method clearMetaDataInspection.

public static void clearMetaDataInspection() {
    TestURLBuilder urlBuilder = IntegrationTestContext.get().getUrlBuilder();
    String url = urlBuilder.buildClearMetaDataInspectionURL();
    IntegrationTestContext.get().getSuperAdminRestHelper().delete(url);
}
Also used : TestURLBuilder(com.mercedesbenz.sechub.test.TestURLBuilder)

Aggregations

TestURLBuilder (com.mercedesbenz.sechub.test.TestURLBuilder)11 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 TestRestHelper (com.mercedesbenz.sechub.integrationtest.internal.TestRestHelper)2 MappingData (com.mercedesbenz.sechub.sharedkernel.mapping.MappingData)2 HttpStatusCodeException (org.springframework.web.client.HttpStatusCodeException)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectReader (com.fasterxml.jackson.databind.ObjectReader)1 TestJSONHelper (com.mercedesbenz.sechub.integrationtest.internal.TestJSONHelper)1 MappingEntry (com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry)1 File (java.io.File)1 IOException (java.io.IOException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)1 RestClientException (org.springframework.web.client.RestClientException)1