sign_up_user method now requires password authentication

minor_adjustments
Selim Eser 2024-06-13 12:54:33 +02:00
parent a2e432119e
commit b66b2314d8
3 changed files with 10 additions and 7 deletions

View File

@ -111,7 +111,7 @@ public class System {
return false; return false;
} }
public boolean sign_up_user(String username, String password, String hometown, String zip, public boolean sign_up_user(String username, String password, String password_authentication, String hometown, String zip,
String car_name, String car_l_100kmS, String car_avg_kmhS, String bike_avg_kmhS){ String car_name, String car_l_100kmS, String car_avg_kmhS, String bike_avg_kmhS){
double car_l_100km; double car_l_100km;
@ -129,6 +129,9 @@ public class System {
if(username.equals("")||password.equals("")||hometown.equals("")||zip.equals("")) if(username.equals("")||password.equals("")||hometown.equals("")||zip.equals(""))
return false; return false;
if(!password.equals(password_authentication))
return false;
for(User user: this.all_user) for(User user: this.all_user)
if(user.getUsername().equals(username)) if(user.getUsername().equals(username))
return false; return false;

View File

@ -16,9 +16,9 @@ public class Application {
return running_system.sign_in_user(username, password); return running_system.sign_in_user(username, password);
} }
public boolean sign_up_user(String username, String password, String hometown, String zip, public boolean sign_up_user(String username, String password, String password_authentication, String hometown, String zip,
String car_name, String car_co2_km, String car_avg_kmh, String bike_avg_kmh){ String car_name, String car_co2_km, String car_avg_kmh, String bike_avg_kmh){
return running_system.sign_up_user(username, password, hometown, zip, car_name, car_co2_km, car_avg_kmh, bike_avg_kmh); return running_system.sign_up_user(username, password, password_authentication, hometown, zip, car_name, car_co2_km, car_avg_kmh, bike_avg_kmh);
} }
public void sign_out_user(){ public void sign_out_user(){

View File

@ -123,11 +123,11 @@ public class SystemTest {
@Test @Test
public void sign_up_user(){ public void sign_up_user(){
// Username darf nicht doppelt vorkommen! // Username darf nicht doppelt vorkommen!
assertEquals(false, current_system.sign_up_user("David","123Esel","Mannheim","68161","AMG","10","300","20")); assertEquals(false, current_system.sign_up_user("David","123Esel","123Esel","Mannheim","68161","AMG","10","300","20"));
assertEquals(true, current_system.sign_up_user("Selim","Penis69","Mannheim","68161","AMG","10","300","20")); assertEquals(true, current_system.sign_up_user("Selim","Penis69","Penis69","Mannheim","68161","AMG","10","300","20"));
// PLZ muss mit Stadt übereinstimmen // PLZ muss mit Stadt übereinstimmen
assertEquals(false, current_system.sign_up_user("Lukas","123Esel","Mannheim","11105","AMG","10","300","20")); assertEquals(false, current_system.sign_up_user("Lukas","123Esel","123Esel","Mannheim","11105","AMG","10","300","20"));
assertEquals(true, current_system.sign_up_user("Lukas","123Esel","Mannheim","68305","AMG","10","300","20")); assertEquals(true, current_system.sign_up_user("Lukas","123Esel","123Esel","Mannheim","68305","AMG","10","300","20"));
assertEquals("Lukas",current_system.getDetails()[0]); assertEquals("Lukas",current_system.getDetails()[0]);
current_system.sign_out_user(); current_system.sign_out_user();