Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/org/labkey/test/tests/SecurityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@
import org.openqa.selenium.support.ui.ExpectedConditions;

import java.io.IOException;
import java.io.StringReader;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;

import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -122,6 +126,28 @@ protected void doCleanup(boolean afterTest) throws TestTimeoutException
DbLoginUtils.resetDbLoginConfig(cn);
}

@Test
public void testSecurityTxt() throws IOException
{
getDriver().navigate().to(WebTestHelper.getBaseURL() + "/.well-known/security.txt");

String body = getBodyText();

Properties props = new Properties();
props.load(new StringReader(body));

assertTrue("security.txt missing Contact", props.containsKey("Contact"));
assertTrue("security.txt missing Policy", props.containsKey("Policy"));
assertTrue("security.txt missing Expires", props.containsKey("Expires"));

String expiresStr = props.getProperty("Expires");
ZonedDateTime expires = ZonedDateTime.parse(expiresStr, DateTimeFormatter.ISO_INSTANT.withZone(java.time.ZoneId.of("UTC")));
ZonedDateTime nextYear = ZonedDateTime.now(java.time.ZoneId.of("UTC")).plusYears(1);

// If this assert fails, edit security.txt to use something more than a year in the future
assertTrue("security.txt 'Expires' value should be more than a year in the future: " + expiresStr, expires.isAfter(nextYear));
}

@Test
public void testSteps() throws IOException
{
Expand Down