def METHOD_NAME(request, htpasswd_path):
    """
    Create a user factory.
    Args:
        request (obj): request fixture
        htpasswd_path (str): Path to htpasswd file
    Returns:
        func: User factory function
    """
    _users = []
    def _factory(
        username=None,
        password=None,
    ):
        """
        Create a new user.
        Args:
            username (str): Username of a new user. If not proided then
                set it to random string
            password (str): Password of a new user. If not provided then
                set it to random string
        Returns:
            tuple: username and password of a new user
        """
        if not username:
            # Generate random username from letters and numbers starting
            # with letter. Length is between 1 and 11 characters.
            username = random.choice(string.ascii_letters)
            username = username + "".join(
                random.choice(string.ascii_letters + string.digits)
                for _ in range(random.randint(0, 10))
            )
        if not password:
            # Generate random password from letters, numbers and special
            # characters. Length is between 6 and 15 characters.
            password = "".join(
                random.choice(string.ascii_letters + string.digits + string.punctuation)
                for _ in range(random.randint(6, 15))
            )
        add_htpasswd_user(username, password, htpasswd_path)
        if not _users:
            ocp_obj = ocp.OCP(
                kind=constants.SECRET, namespace=constants.OPENSHIFT_CONFIG_NAMESPACE
            )
            secret = ocp_obj.get(resource_name="htpass-secret", dont_raise=True) or None
            if secret:
                create_htpasswd_secret(htpasswd_path, replace=True)
            else:
                create_htpasswd_secret(htpasswd_path)
        else:
            create_htpasswd_secret(htpasswd_path, replace=True)
        # : is a delimiter in htpasswd file and it will ensure that only full
        # usernames are deleted
        _users.append(f"{username}:")
        return (username, password)
    def _finalizer():
        """
        Delete all users created by the factory
        """
        with open(htpasswd_path) as f:
            htpasswd = f.readlines()
        new_htpasswd = [line for line in htpasswd if not line.startswith(tuple(_users))]
        with open(htpasswd_path, "w+") as f:
            for line in new_htpasswd:
                f.write(line)
        create_htpasswd_secret(htpasswd_path, replace=True)
    request.addfinalizer(_finalizer)
    return _factory