password-checker

Story points 3
Tags tdd error-checking
Hard Prerequisites
  • PROJECTS: simple-calculator part 1

  • Set up your environment

    Javascript

    Please test your code using jasmine.

    Your directory structure should look like this.

        >node_modules    <---- make sure this is in your .gitignore
        >spec
            > support
                -jasmine.json
            - password_is_valid_spec.js
            - password_is_ok_spec.js
        >src
            - password_checker.js
        - package.json
    

    Python

    Your project is expected to be completed using pytest. You are expected to follow industry best practices in all things. This means that you need to have a directory structure that is in good shape. Please name your files and folders like this:

    ├── password_checker   the package under test
    │   └── password_checker.py
    ├── requirements.txt    installation requiremnts
    ├── setup.py            installation script for the package under test
    └── tests               all package tests go in this directory
        ├── test_password_is_valid.py
        └── test_password_is_ok.py
    

    Please take a look at this topic to see an explanation of the required directory structure. : [TODO] Umuzi Tech Department

    Java

    The code you push to git should have the following structure:

    ├── build.gradle
    ├── gradle
    │   └── wrapper
    │       ├── gradle-wrapper.jar
    │       └── gradle-wrapper.properties
    ├── gradlew
    ├── gradlew.bat
    ├── settings.gradle
    └── src
        ├── main
        |   └── java
        |       └── PasswordChecker.java <-------- names are important
        └── test
            └── java
                └── ???.java             <-------- names are important
    

    Please refer to the following to find out more: TOPICS: [TODO] Java project submission requirements

    Instructions

    Implement the following function by following a TDD methodology:

    // Javascript:
    passwordIsValid(password)
    
    // Java:
    passwordIsValid(password)
    
    # Python:
    password_is_valid(password)
    

    password_is_valid will check if the password meets a few different conditions. If one of the below conditions is not met then the relevant error/exception should be thrown/raised. Your error/exception message should match one of the following conditions exactly (word-for-word).

    1. password should exist
    2. password should be longer than than 8 characters
    3. password should have at least one lowercase letter
    4. password should have at least one uppercase letter
    5. password should at least have one digit
    6. password should have at least one special character

    In the case of (6) above, a special character is a character that is on the keyboard but is not a number or letter. Eg { % & * " ' etc

    Next, implement a function called password is ok:

    // Javascript:
    passwordIsOk(password)
    
    // Java:
    passwordIsOk(password)
    
    # Python:
    password_is_ok(password)
    

    If the given password meets at least three of the conditions listed above then this function should return true, otherwise it should return false.

    Add a feature: the password is never OK if conditions 1 and 2 are not met.

    JS Resources

    Python Resources

    Java Resources


    RAW CONTENT URL