https://www.codurance.com/katalyst/password-validation
Design and implement a software that validates a password applying TDD.
The password will be introduced by the user (as an argument of the method) and should return if the password is valid or not.
A valid password should meet the following requirements:
- Have more than 8 characters
- Contains a capital letter
- Contains a lowercase
- Contains a number
- Contains an underscore
We want a method that answers if the password is valid or not. We don't want to know the reason when the password is invalid (the return value is a boolean)
#Iteration 2 - Rules abstraction
Design and implement software that can adapt to different password validation rules TDD and focus on the OOP principles.
Let's pretend that now we want to create another type of password validations because on our app we need different type of passwords, such as:
Validation 2:
- Have more than 6 characters
- Contains a capital letter
- Contains a lowercase
- Contains a number
Validation 3:
- Have more than 16 characters
- Contains a capital letter
- Contains a lowercase
- Contains an underscore
In this iteration, we should try to identify a good abstraction and try to work on OOP principles as well as on design patterns like Builder and Factory
Configuración básica para empezar a hacer una kata o aprender a hacer tests en los siguientes lenguajes:
- PHP y PHPUnit
- Javascript con Jest
- Java, Junit y Mockito
- Scala, Munit y Scalacheck
- Kotlin, JUnit5 y MockK
- C#, xUnit (con FluentAsertion) y NSubstitute (para mock)
- Instalar composer
curl -sS https://getcomposer.org/installer | php
composer install
(estando en la carpeta php)./vendor/bin/phpunit
- Instalar Node
npm install
(Estando en la carpeta javascript)npm test
- Instalar las dependencias y tests con Maven [mvn test]
- Ejecutar los tests con el IDE
sbt
(en la carpeta scala)~test
para ejecutar los test en hot reload
- Instalar SDKMan
sdk install java 11.0.12-open
instala OpenJDKsdk install sbt
una vez instalado SDKMan
- Descargar Visual Studio Code
- Instalar para VS Code Metals
- Por consola: Puedes instalar dependencias y lanzar los tests con
gradlew test
- Usando IDE: Simplemente abre el proyecto desde el raiz de la plantilla Kotlin
- Instalar Microsoft Visual Studio Community 2022
- Abre el proyecto y se descargaran automáticamente los paquetes Nuguet necesarios
- Instalar python 3.x
- Una vez descargado el código fuente dentro de la carpeta */python/ creamos un virtual enviroment:
python3 -m venv env
- Activamos en virtual environment:
- windows:
.\env\Scripts\activate.bat
- linux/mac:
source env/bin/activate
pytest
para ejecutar los tests.
Prophecy para dobles de prueba
Scalacheck para testing basado en propiedades