|
26 | 26 | public class ImageStoreUtilTest { |
27 | 27 |
|
28 | 28 | @Test |
29 | | - public void testgeneratePostUploadUrl() throws MalformedURLException { |
| 29 | + public void testgenerateHttpsPostUploadUrl() throws MalformedURLException { |
30 | 30 | String ssvmdomain = "*.realhostip.com"; |
31 | 31 | String ipAddress = "10.147.28.14"; |
32 | 32 | String uuid = UUID.randomUUID().toString(); |
| 33 | + String protocol = "https"; |
33 | 34 |
|
34 | 35 | //ssvm domain is not set |
35 | | - String url = ImageStoreUtil.generatePostUploadUrl(null, ipAddress, uuid); |
36 | | - assertPostUploadUrl(url, ipAddress, uuid); |
| 36 | + String url = ImageStoreUtil.generatePostUploadUrl(null, ipAddress, uuid, protocol); |
| 37 | + assertPostUploadUrl(url, ipAddress, uuid, protocol); |
37 | 38 |
|
38 | 39 | //ssvm domain is set to empty value |
39 | | - url = ImageStoreUtil.generatePostUploadUrl("", ipAddress, uuid); |
40 | | - assertPostUploadUrl(url, ipAddress, uuid); |
| 40 | + url = ImageStoreUtil.generatePostUploadUrl("", ipAddress, uuid, protocol); |
| 41 | + assertPostUploadUrl(url, ipAddress, uuid, protocol); |
41 | 42 |
|
42 | 43 | //ssvm domain is set to a valid value |
43 | | - url = ImageStoreUtil.generatePostUploadUrl(ssvmdomain, ipAddress, uuid); |
44 | | - assertPostUploadUrl(url, ipAddress.replace(".", "-") + ssvmdomain.substring(1), uuid); |
| 44 | + url = ImageStoreUtil.generatePostUploadUrl(ssvmdomain, ipAddress, uuid, protocol); |
| 45 | + assertPostUploadUrl(url, ipAddress.replace(".", "-") + ssvmdomain.substring(1), uuid, protocol); |
45 | 46 | } |
46 | 47 |
|
47 | | - private void assertPostUploadUrl(String urlStr, String domain, String uuid) throws MalformedURLException { |
| 48 | + @Test |
| 49 | + public void testgenerateHttpPostUploadUrl() throws MalformedURLException { |
| 50 | + String ssvmdomain = "*.realhostip.com"; |
| 51 | + String ipAddress = "10.147.28.14"; |
| 52 | + String uuid = UUID.randomUUID().toString(); |
| 53 | + String protocol = "http"; |
| 54 | + |
| 55 | + //ssvm domain is not set |
| 56 | + String url = ImageStoreUtil.generatePostUploadUrl(null, ipAddress, uuid, protocol); |
| 57 | + assertPostUploadUrl(url, ipAddress, uuid, protocol); |
| 58 | + |
| 59 | + //ssvm domain is set to empty value |
| 60 | + url = ImageStoreUtil.generatePostUploadUrl("", ipAddress, uuid, protocol); |
| 61 | + assertPostUploadUrl(url, ipAddress, uuid, protocol); |
| 62 | + |
| 63 | + //ssvm domain is set to a valid value |
| 64 | + url = ImageStoreUtil.generatePostUploadUrl(ssvmdomain, ipAddress, uuid, protocol); |
| 65 | + assertPostUploadUrl(url, ipAddress.replace(".", "-") + ssvmdomain.substring(1), uuid, protocol); |
| 66 | + } |
| 67 | + |
| 68 | + private void assertPostUploadUrl(String urlStr, String domain, String uuid, String protocol) throws MalformedURLException { |
48 | 69 | URL url = new URL(urlStr); |
49 | 70 | Assert.assertNotNull(url); |
50 | 71 | Assert.assertEquals(url.getHost(), domain); |
51 | 72 | Assert.assertEquals(url.getPath(), "/upload/" + uuid); |
| 73 | + Assert.assertEquals(url.getProtocol(), protocol); |
52 | 74 | } |
53 | 75 |
|
| 76 | + |
54 | 77 | } |
0 commit comments