Question

Junit testing for password validity. Password need to be of length 10 - 25. Password need...

Junit testing for password validity.

Password need to be of length 10 - 25.

Password need to have at least one uppercase letter.

Password need to have at least one lowercase letter.

Password must have at least one symbol.

Password must not have consecutive uppercase letters, lowercase letters, numbers or symbols.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Following is the answer:

TestPassword.java

import org.junit.Test;
import static org.junit.Assert.*;

public class TestPassword {

@Test
public void missingNumber() {
// setup
String password = "Abcdefg#";

// execute
boolean actual = main.validatePassword(password);

// assert
assertFalse(actual);
}

@Test
public void missingUppercase() {
// setup
String password = "abcdefg5#";

// execute
boolean actual = main.validatePassword(password);

// assert
assertFalse(actual);
}

@Test
public void missingLowercase() {
// setup
String password = "ABCDEFG5#";

// execute
boolean actual = main.validatePassword(password);

// assert
assertFalse(actual);
}

@Test
public void missingSymbol() {
// setup
String password = "Abcdefg5";

// execute
boolean actual = main.validatePassword(password);

// assert
assertFalse(actual);
}

@Test
public void allRullesMet() {
// setup
String password = "Abcdefg5#";

// execute
boolean actual = main.validatePassword(password);

// assert
assertTrue(actual);
}

@Test
public void LengthTooLong() {
// setup
String password = "Abcdefg5#abcdefgabcdabcg1234aabcdef";

// execute
boolean actual = main.validatePassword(password);

// assert
assertFalse(actual);
}

}

Add a comment
Know the answer?
Add Answer to:
Junit testing for password validity. Password need to be of length 10 - 25. Password need...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in C++, Design a program that asks the user to enter a password, and then analyze...

    in C++, Design a program that asks the user to enter a password, and then analyze the password, and then analyze the password for the following weaknesses: 1. Fewer than 8 characters 2. Does not contain at least one uppercase letter and one lowercase latter 3. Does not contain at least one numeric digit 4. Does not contain at least one special character( a character that is not a letter or numeric digit) 5. Is a sequence of consecutive uppercase...

  • Lang: Python Create code that will generate a random password for a user following the constraints...

    Lang: Python Create code that will generate a random password for a user following the constraints below... Password Generator: Must have a length of 20 Must contain 2 lowercase letters Must contain 2 uppercase letters Must contain 2 numbers Must contain 2 valid symbols These symbols are allowed !@#$%^&*()? Chose the characters with replacement

  • Please make this Python code execute properly. User needs to create a password with at least...

    Please make this Python code execute properly. User needs to create a password with at least one digit, one uppercase, one lowercase, one symbol (see code), and the password has to be atleast 8 characters long. try1me is the example I used, but I couldn't get the program to execute properly. PLEASE INDENT PROPERLY. def policy(password): digit = 0 upper = 0 lower = 0 symbol = 0 length = 0 for i in range(0, len(password)): if password[i].isdigit(): # checks...

  • 5. A hacker is trying to guess a password. They have worked out that the password has length 8, being a mix of 1 upperc...

    5. A hacker is trying to guess a password. They have worked out that the password has length 8, being a mix of 1 uppercase letter (from {A. . . . ,7), 5 lowercase letters (from {a, . . . ,:) and 2 digits (from 10,...,91). They do not know in which order these symbols occur in the password. [In this question, answers may be given as a product of integers, without evaluating further.] a) How many passwords fit this...

  • Write a program that inputs a string from the user representing a password, and checks its...

    Write a program that inputs a string from the user representing a password, and checks its validity. A valid password must contain: -At least 1 lowercase letter (between 'a' and 'z') and 1 uppercase letter (between 'A' and 'Z'). -At least 1 digit (between '0' and '9' and not between 0 and 9). At least 1 special character (hint: use an else to count all the characters that are not letters or digits). -A minimum length 6 characters. -No spaces...

  • Python Create a function that checks user input in an attempt to create a password. The...

    Python Create a function that checks user input in an attempt to create a password. The valid_password function accepts a password as an argument and returns either true or false to indicate whether the password is valid. A valid password must be at least 7 characters in length, have at least one uppercase letter, one lowercase letter, and one digit. Respond with output to the user as to whether the password is valid or not, and allow the user to...

  • 3. A computer system uses passwords that contain exactly eight characters, and each character is one...

    3. A computer system uses passwords that contain exactly eight characters, and each character is one of the 26 lowercase letter (a -z) or 26 uppercase letters (A - Z) or 10 integers (0-9). Let Ω denote the set of all possible passwords. Suppose that all passwords in Ω are equally likely. Determine the probability for each of the following: (a) Password contains all lowercase letters given that it contains only letters (b) Password contains at least 1 uppercase letter...

  • (10 marks) Create a small chart that summarizes the number of unique passwords of length 4, 8 and...

    (10 marks) Create a small chart that summarizes the number of unique passwords of length 4, 8 and 12 using the following conditions: Only numbers. Only lowercase letters. Only numbers and lowercase letters. Only numbers and lowercase letters and uppercase letters. Numbers, lowercase letters, uppercase letters and visible punctuation (ignore spaces and tabs - consult an ASCII chart if you need to). Be sure to note how you came to these numbers. (10 marks) Create a small chart that summarizes...

  • Create a Python Program that will ask the user for a password (use input) Verify that...

    Create a Python Program that will ask the user for a password (use input) Verify that the password meets the following conditions: -must be 12 characters long -must have uppercase and lowercase -must contain at least 1 special character (!~#$%^&*{}+_) -must be a mix of numbers and letters You must do this only using regular expressions so for instance this will not be accepted if len(password) <12: At the end of the program tell the user their password is ok...

  • Create a Python Program that will ask the user for a password (use input) Verify that...

    Create a Python Program that will ask the user for a password (use input) Verify that the password meets the following conditions: -must be 12 characters long -must have uppercase and lowercase -must contain at least 1 special character (!~#$%^&*{}+_) -must be a mix of numbers and letters You must do this only using regular expressions so for instance this will not be accepted if len(password) <12: At the end of the program tell the user their password is ok...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT