|
49 | 49 | import org.openqa.selenium.support.ui.ExpectedConditions; |
50 | 50 |
|
51 | 51 | import java.io.IOException; |
| 52 | +import java.io.StringReader; |
| 53 | +import java.time.ZonedDateTime; |
| 54 | +import java.time.format.DateTimeFormatter; |
52 | 55 | import java.util.Arrays; |
53 | 56 | import java.util.Collections; |
54 | 57 | import java.util.HashSet; |
55 | 58 | import java.util.List; |
| 59 | +import java.util.Properties; |
56 | 60 | import java.util.Set; |
57 | 61 |
|
58 | 62 | import static org.junit.Assert.assertEquals; |
@@ -122,6 +126,28 @@ protected void doCleanup(boolean afterTest) throws TestTimeoutException |
122 | 126 | DbLoginUtils.resetDbLoginConfig(cn); |
123 | 127 | } |
124 | 128 |
|
| 129 | + @Test |
| 130 | + public void testSecurityTxt() throws IOException |
| 131 | + { |
| 132 | + getDriver().navigate().to(WebTestHelper.getBaseURL() + "/.well-known/security.txt"); |
| 133 | + |
| 134 | + String body = getBodyText(); |
| 135 | + |
| 136 | + Properties props = new Properties(); |
| 137 | + props.load(new StringReader(body)); |
| 138 | + |
| 139 | + assertTrue("security.txt missing Contact", props.containsKey("Contact")); |
| 140 | + assertTrue("security.txt missing Policy", props.containsKey("Policy")); |
| 141 | + assertTrue("security.txt missing Expires", props.containsKey("Expires")); |
| 142 | + |
| 143 | + String expiresStr = props.getProperty("Expires"); |
| 144 | + ZonedDateTime expires = ZonedDateTime.parse(expiresStr, DateTimeFormatter.ISO_INSTANT.withZone(java.time.ZoneId.of("UTC"))); |
| 145 | + ZonedDateTime nextYear = ZonedDateTime.now(java.time.ZoneId.of("UTC")).plusYears(1); |
| 146 | + |
| 147 | + // If this assert fails, edit security.txt to use something more than a year in the future |
| 148 | + assertTrue("security.txt 'Expires' value should be more than a year in the future: " + expiresStr, expires.isAfter(nextYear)); |
| 149 | + } |
| 150 | + |
125 | 151 | @Test |
126 | 152 | public void testSteps() throws IOException |
127 | 153 | { |
|
0 commit comments