Skip to content
Snippets Groups Projects
Commit fc613ef9 authored by Martin Lowe's avatar Martin Lowe :flag_ca:
Browse files

Merge branch 'zacharysabourin/main/24' into 'main'

fix: Fix error where GH pre-load crashes app if not data found

Closes #24

See merge request !24
parents 52139ef6 c8915df5
No related branches found
No related tags found
1 merge request!24fix: Fix error where GH pre-load crashes app if not data found
Pipeline #13127 passed
......@@ -159,7 +159,9 @@ public class DefaultCveService implements CveService {
return om.readerFor(CveProjectData.class).readValue(githubApi.getCveDetails(params));
} catch (Exception e) {
throw new RuntimeException(String.format("Could not fetch CVE %s from GitHub", key), e);
// Catch and log so as to not block the pre-load if GH has issues
LOGGER.error(String.format("Could not fetch CVE %s from GitHub", key), e);
return null;
}
}
}
......@@ -53,6 +53,9 @@ class CveResourceTest {
public final static EndpointTestCase GET_BY_ID_SUCCESS = TestCaseHelper.buildSuccessCase(CVE_BASE_URL,
new String[] { "CVE-2022-0103" }, SchemaNamespaceHelper.CVE_SCHEMA_PATH);
public final static EndpointTestCase GET_BY_ID_NO_GH_SUCCESS = TestCaseHelper.buildSuccessCase(CVE_BASE_URL,
new String[] { "CVE-2022-0105" }, SchemaNamespaceHelper.CVE_SCHEMA_PATH);
public final static EndpointTestCase GET_BY_ID_INVALID_FORMAT = TestCaseHelper.buildInvalidFormatCase(CVE_BASE_URL,
new String[] { "CVE-2022-0103" }, ContentType.TEXT);
......@@ -123,6 +126,16 @@ class CveResourceTest {
RestAssuredTemplates.testGet_validateSchema(GET_BY_ID_SUCCESS);
}
@Test
void getByIdNoGH_success() {
RestAssuredTemplates.testGet(GET_BY_ID_NO_GH_SUCCESS);
}
@Test
void getByIdNoGH_success_matchingSpec() {
RestAssuredTemplates.testGet_validateSchema(GET_BY_ID_NO_GH_SUCCESS);
}
@Test
void getById_failure_invalidFormatTEXT() {
RestAssuredTemplates.testGet(GET_BY_ID_INVALID_FORMAT);
......
......@@ -27,7 +27,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@RestClient
@ApplicationScoped
public class StubbedGitlabCveAPI implements GitlabCveAPI {
@Inject
ObjectMapper om;
......@@ -61,6 +61,15 @@ public class StubbedGitlabCveAPI implements GitlabCveAPI {
.setRequestLink("https://bugs.eclipse.org/bugs/show_bug.cgi?id=2")
.setCvePullRequest(null)
.setStatus("RESERVED")
.build(),
CveData
.builder()
.setId("CVE-2022-0105")
.setDate(LocalDate.now())
.setProject("technology.test")
.setRequestLink("https://bugs.eclipse.org/bugs/show_bug.cgi?id=3")
.setCvePullRequest(null)
.setStatus("PUBLIC")
.build()
};
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment