|
8 | 8 | import org.owasp.dependencycheck.dependency.Dependency; |
9 | 9 | import org.owasp.dependencycheck.dependency.naming.Identifier; |
10 | 10 | import org.owasp.dependencycheck.dependency.naming.PurlIdentifier; |
11 | | -import org.owasp.dependencycheck.exception.InitializationException; |
12 | 11 | import org.owasp.dependencycheck.utils.Settings; |
13 | 12 | import org.owasp.dependencycheck.utils.Settings.KEYS; |
14 | 13 |
|
|
30 | 29 |
|
31 | 30 | import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; |
32 | 31 | import static org.junit.jupiter.api.Assertions.assertEquals; |
33 | | -import static org.junit.jupiter.api.Assertions.assertThrows; |
| 32 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
34 | 33 | import static org.junit.jupiter.api.Assertions.assertTrue; |
35 | 34 |
|
36 | 35 | class OssIndexAnalyzerTest extends BaseTest { |
@@ -252,18 +251,21 @@ void should_analyzeDependency_fail_when_socket_error_from_sonatype() throws Exce |
252 | 251 | } |
253 | 252 |
|
254 | 253 | @Test |
255 | | - void should_prepareAnalyzer_fail_when_credentials_not_set() throws Exception { |
| 254 | + void should_prepareAnalyzer_disable_when_credentials_not_set() throws Exception { |
| 255 | + // Given |
256 | 256 | OssIndexAnalyzer analyzer = new OssIndexAnalyzer(); |
257 | 257 | Settings settings = getSettings(); |
258 | 258 | Engine engine = new Engine(settings); |
259 | 259 | analyzer.initialize(settings); |
260 | | - try { |
261 | | - analyzer.prepareAnalyzer(engine); |
262 | | - assertThrows(InitializationException.class, () -> analyzer.prepareAnalyzer(engine)); |
263 | | - } catch (InitializationException e) { |
264 | | - analyzer.close(); |
265 | | - engine.close(); |
266 | | - } |
| 260 | + |
| 261 | + // When |
| 262 | + analyzer.prepareAnalyzer(engine); |
| 263 | + |
| 264 | + // Then |
| 265 | + boolean enabled = analyzer.isEnabled(); |
| 266 | + analyzer.close(); |
| 267 | + engine.close(); |
| 268 | + assertFalse(enabled); |
267 | 269 | } |
268 | 270 |
|
269 | 271 | private static void setCredentials(final Settings settings) { |
|
0 commit comments