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());
}
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");
}
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("");
}
Aggregations