1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.owasp.dependencycheck.data.update;
19
20 import java.time.ZonedDateTime;
21 import java.util.Map;
22 import java.util.Properties;
23 import org.junit.After;
24 import org.junit.AfterClass;
25 import org.junit.Before;
26 import org.junit.BeforeClass;
27 import org.junit.Test;
28 import static org.junit.Assert.*;
29 import org.owasp.dependencycheck.Engine;
30
31
32
33
34
35 public class NvdApiDataSourceTest {
36
37
38
39
40 @Test
41 public void testExtractUrlData() {
42 String nvdDataFeedUrl = "https://internal.server/nist/nvdcve-{0}.json.gz";
43 NvdApiDataSource instance = new NvdApiDataSource();
44 String expectedUrl = "https://internal.server/nist/";
45 String expectedPattern = "nvdcve-{0}.json.gz";
46 NvdApiDataSource.UrlData result = instance.extractUrlData(nvdDataFeedUrl);
47
48 nvdDataFeedUrl = "https://internal.server/nist/";
49 expectedUrl = "https://internal.server/nist/";
50 result = instance.extractUrlData(nvdDataFeedUrl);
51
52 assertEquals(expectedUrl, result.getUrl());
53 assertNull(result.getPattern());
54
55 nvdDataFeedUrl = "https://internal.server/nist";
56 expectedUrl = "https://internal.server/nist/";
57 result = instance.extractUrlData(nvdDataFeedUrl);
58
59 assertEquals(expectedUrl, result.getUrl());
60 assertNull(result.getPattern());
61 }
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77 }