Search in sources :

Example 6 with CheckmarxAdapterContext

use of com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxAdapterContext in project sechub by mercedes-benz.

the class CheckmarxOAuthSupportTest method refreshBearerTokenWhenNecessary_leads_to_newer_oauth_data_object.

@Test
void refreshBearerTokenWhenNecessary_leads_to_newer_oauth_data_object() throws Exception {
    /* prepare */
    CheckmarxOAuthData alreadyExistingOauthData = new CheckmarxOAuthData();
    alreadyExistingOauthData.expiresInSeconds = 2;
    CheckmarxAdapterContext context = createContextWithRestSimulation(alreadyExistingOauthData);
    /* check precondition */
    assertTrue(supportToTest.isTokenRefreshNecessary(context));
    /* execute */
    // this will refresh, because 2 seconds
    supportToTest.refreshBearerTokenWhenNecessary(context);
    /* test */
    ArgumentCaptor<CheckmarxOAuthData> captor = ArgumentCaptor.forClass(CheckmarxOAuthData.class);
    // only one time for 2 calls!
    verify(context, times(1)).markAuthenticated(captor.capture());
    CheckmarxOAuthData newOauthData = captor.getValue();
    assertNotSame(newOauthData, alreadyExistingOauthData);
    assertEquals("mytoken1", newOauthData.getAccessToken());
    assertEquals(3600, newOauthData.getExpiresInSeconds());
}
Also used : CheckmarxAdapterContext(com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxAdapterContext) Test(org.junit.jupiter.api.Test)

Example 7 with CheckmarxAdapterContext

use of com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxAdapterContext in project sechub by mercedes-benz.

the class CheckmarxScanReportSupportTest method fetchReportResult__support_does_remove_nothing_when_plain_xml.

@Test
public void fetchReportResult__support_does_remove_nothing_when_plain_xml() throws Exception {
    /* prepare */
    CheckmarxAdapterContext context = prepareContent("<?xml bla");
    /* execute */
    supportToTest.fetchReportResult(oauthSupport, context);
    /* test */
    verify(context).setResult("<?xml bla");
}
Also used : CheckmarxAdapterContext(com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxAdapterContext) Test(org.junit.Test)

Example 8 with CheckmarxAdapterContext

use of com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxAdapterContext in project sechub by mercedes-benz.

the class CheckmarxScanReportSupportTest method fetchReportResult__support_does_use_result_as_is_when_empty.

@Test
public void fetchReportResult__support_does_use_result_as_is_when_empty() throws Exception {
    /* prepare */
    CheckmarxAdapterContext context = prepareContent("");
    /* execute */
    supportToTest.fetchReportResult(oauthSupport, context);
    /* test */
    verify(context).setResult("");
}
Also used : CheckmarxAdapterContext(com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxAdapterContext) Test(org.junit.Test)

Aggregations

CheckmarxAdapterContext (com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxAdapterContext)8 Test (org.junit.Test)3 Test (org.junit.jupiter.api.Test)2 ResponseEntity (org.springframework.http.ResponseEntity)2 RestOperations (org.springframework.web.client.RestOperations)2 CheckmarxAdapterConfig (com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxAdapterConfig)1