2022-03-02 17:01:30 +01:00
|
|
|
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
package pgp.wkd.test_suite;
|
|
|
|
|
|
|
|
import java.net.URI;
|
|
|
|
import java.nio.file.Path;
|
|
|
|
|
|
|
|
public class TestCase {
|
|
|
|
|
2022-04-02 17:31:38 +02:00
|
|
|
enum Expectation {
|
|
|
|
success,
|
|
|
|
failure,
|
|
|
|
unassertive
|
|
|
|
}
|
|
|
|
|
|
|
|
final Expectation expectation;
|
2022-03-02 17:01:30 +01:00
|
|
|
final String testTitle;
|
|
|
|
final String testDescription;
|
|
|
|
final String lookupMailAddress;
|
|
|
|
final String certificatePath;
|
|
|
|
final URI lookupUri;
|
|
|
|
|
2022-04-02 17:31:38 +02:00
|
|
|
public TestCase(Expectation expectation, String testTitle, String description, String lookupMailAddress, Path certificatePath, URI lookupUri) {
|
|
|
|
this.expectation = expectation;
|
2022-03-02 17:01:30 +01:00
|
|
|
this.testTitle = testTitle;
|
|
|
|
this.testDescription = description;
|
|
|
|
this.lookupMailAddress = lookupMailAddress;
|
|
|
|
this.certificatePath = certificatePath.toString();
|
|
|
|
this.lookupUri = lookupUri;
|
|
|
|
}
|
2022-03-02 18:01:12 +01:00
|
|
|
|
2022-03-13 16:08:04 +01:00
|
|
|
public static TestCase ok(String title, String description, String lookupMail, WkdDirectoryStructure structure) {
|
|
|
|
Path filePath = structure.getRelativeCertificatePath(lookupMail);
|
|
|
|
URI certUri = structure.getAddress(lookupMail);
|
2022-04-02 17:31:38 +02:00
|
|
|
return new TestCase(Expectation.success, title, description, lookupMail, filePath, certUri);
|
2022-03-13 16:08:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static TestCase fail(String title, String description, String lookupMail, WkdDirectoryStructure structure) {
|
|
|
|
Path filePath = structure.getRelativeCertificatePath(lookupMail);
|
|
|
|
URI certUri = structure.getAddress(lookupMail);
|
2022-04-02 17:31:38 +02:00
|
|
|
return new TestCase(Expectation.failure, title, description, lookupMail, filePath, certUri);
|
2022-03-13 16:08:04 +01:00
|
|
|
}
|
|
|
|
|
2022-03-02 18:01:12 +01:00
|
|
|
public boolean isExpectSuccess() {
|
2022-04-02 17:31:38 +02:00
|
|
|
return expectation == Expectation.success;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isExpectFailure() {
|
|
|
|
return expectation == Expectation.failure;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isUnassertive() {
|
|
|
|
return expectation == Expectation.unassertive;
|
2022-03-02 18:01:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getTestTitle() {
|
|
|
|
return testTitle;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getTestDescription() {
|
|
|
|
return testDescription;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getLookupMailAddress() {
|
|
|
|
return lookupMailAddress;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getCertificatePath() {
|
|
|
|
return certificatePath;
|
|
|
|
}
|
|
|
|
|
|
|
|
public URI getLookupUri() {
|
|
|
|
return lookupUri;
|
|
|
|
}
|
2022-03-02 17:01:30 +01:00
|
|
|
}
|