Ejemplo n.º 1
0
    def test_hashFunction_when_messageIsNone(self):
        # Arrange
        message = ""
        expected_result = None

        # Act
        result = hash(message)

        # Assert
        self.assertEqual(result, expected_result)
Ejemplo n.º 2
0
    def insert(self):
        admin = self.find_by_username(self.username)
        if admin is None:
            # Hash the password
            self.password = utils.hash(self.password)
            # Add to DB
            database.db.session.add(self)
            database.db.session.commit()
            return True

        return False
Ejemplo n.º 3
0
    def test_hashFunction_when_messageIsNotEmpty3Of3(self):
        # Arrange
        message = "This is a Big MessAge"
        expected_result = (
            "69fcc28e2e974a4dda08b08b9145b21fa4d3c369432f1a93fc4d2c471eb78801")

        # Act
        result = hash(message)

        # Assert
        self.assertEqual(result, expected_result)
Ejemplo n.º 4
0
    def test_hashFunction_when_messageIsNotEmpty2Of3(self):
        # Arrange
        message = " This is a message "
        expected_result = (
            "1f6859fe5973f8411cc9c6f5555c6d43250662909660c0560e784ce0a1aca985")

        # Act
        result = hash(message)

        # Assert
        self.assertEqual(result, expected_result)
Ejemplo n.º 5
0
    def test_hashFunction_when_messageIsNotEmpty1Of3(self):
        # Arrange
        message = "This is a message"
        expected_result = (
            "a826c7e389ec9f379cafdc544d7e9a4395ff7bfb58917bbebee51b3d0b1c996a")

        # Act
        result = hash(message)

        # Assert
        self.assertEqual(result, expected_result)
Ejemplo n.º 6
0
    def post(cls):
        # Get data from parser
        data = cls.parser.parse_args()

        # Find admin from db
        admin = adm.AdminModel.find_by_username(data["username"])

        # Check password
        if admin and admin.password == utils.hash(data["password"]):
            # Create access token
            access_token = create_access_token(identity=admin.id, fresh=True)

            # Create refresh token
            refresh_token = create_refresh_token(admin.id)

            return Succ.SUCCESS_AUTHENTICATED(access_token, refresh_token)

        return Err.ERROR_INVALID_CREDS