mirror of
https://dev.azure.com/Foster-X/CMP329%20CW2/_git/CMP329%20CW2
synced 2025-07-27 05:23:32 +00:00
Added new credentials. Fixed CSVBuilder after ChatGPT made a dog's dinner out of it. Added a clause for unauthorised credentials (WIP)
This commit is contained in:
parent
9314fcea8f
commit
30519bfee4
5 changed files with 51 additions and 0 deletions
|
@ -1,2 +1,3 @@
|
|||
testuser,QUBsucks&UUisBetter
|
||||
subscriber,drewapicture(incrediblyfunnyjoke!)
|
||||
fakename,fakepass
|
||||
|
|
|
|
@ -1,2 +1,3 @@
|
|||
author,testuser,QUBsucks&UUisBetter
|
||||
subscriber,subscriber,drewapicture(incrediblyfunnyjoke!)
|
||||
unauthorised,fakename,fakepass
|
||||
|
|
|
|
@ -1,3 +1,4 @@
|
|||
test.fusil.uk
|
||||
author,testuser,QUBsucks&UUisBetter
|
||||
subscriber,subscriber,drewapicture(incrediblyfunnyjoke!)
|
||||
unauthorised,fakename,fakepass
|
|
|
@ -6,7 +6,50 @@ import java.time.format.DateTimeFormatter;
|
|||
|
||||
public class CsvBuilder {
|
||||
|
||||
private static final String inputFile = "src/csv/credentials.csv";
|
||||
private static final String reportDirectory = "src/csv/reports/";
|
||||
private static String reportFilePath = null;
|
||||
|
||||
private static String reportFile;
|
||||
public static void compileAll(String outputFile) {
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(inputFile));
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter("src/csv/built/" + outputFile + ".csv"))) {
|
||||
|
||||
// Skip the first line
|
||||
reader.readLine();
|
||||
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
String[] parts = line.split(",", 2);
|
||||
if (parts.length > 1) {
|
||||
writer.write(parts[1]);
|
||||
writer.newLine();
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("File processed successfully!");
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error processing file: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void compilePermissions(String outputFile) {
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(inputFile));
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter("src/csv/built/" + outputFile + ".csv"))) {
|
||||
|
||||
// Skip the first line
|
||||
reader.readLine();
|
||||
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
writer.write(line + "\n");
|
||||
}
|
||||
|
||||
System.out.println("File processed successfully!");
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error processing file: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static String createTestReportFile() {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss");
|
||||
|
@ -35,4 +78,8 @@ public class CsvBuilder {
|
|||
System.err.println("Failed to write to report file: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
CsvBuilder.compileAll("all_login_credentials");
|
||||
CsvBuilder.compilePermissions("credentials_permissions");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ public class TestPoster {
|
|||
|
||||
try {
|
||||
// Step 1: Login
|
||||
boolean loginaAllowed = (!role.equals("unauthorised"));
|
||||
WebElement username = driver.findElement(By.id(USERNAME_BOX_ID));
|
||||
WebElement password = driver.findElement(By.id(PASSWORD_BOX_ID));
|
||||
WebElement login = driver.findElement(By.id(LOGIN_BUTTON_ID));
|
||||
|
|
Loading…
Add table
Reference in a new issue