Skip to content
Snippets Groups Projects
Select Git revision
  • 69596c39c8aed38ac565f3d8837b32c6611702d0
  • main default protected
  • f-xlsx-list-file
  • f-yaml-parser-enums
  • dev protected
  • f-fix-paths
  • f-fix-validate-to-dict
  • f-labfolder-converter
  • f-state-machine-script
  • f-xlsx-converter-warnings-errors
  • f-rename
  • f-extra-deps
  • f-more-jsonschema-export
  • f-henrik
  • f-fix-89
  • f-trigger-advanced-user-tools
  • f-real-rename-test
  • f-linkahead-rename
  • f-register-integrationtests
  • f-fix-id
  • f-h5-files
  • v0.14.0
  • v0.13.0
  • v0.12.0
  • v0.11.0
  • v0.10.0-numpy2
  • v0.10.0
  • v0.9.0
  • v0.8.0
  • v0.7.0
  • v0.6.1
  • v0.6.0
  • v0.5.0
  • v0.4.1
  • v0.4.0
  • v0.3.1
  • v0.3.0
37 results

parser.py

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    test_authentication_plain.py 2.10 KiB
    # -*- coding: utf-8 -*-
    #
    # ** header v3.0
    # This file is a part of the CaosDB Project.
    #
    # Copyright (C) 2018 Research Group Biomedical Physics,
    # Max-Planck-Institute for Dynamics and Self-Organization Göttingen
    #
    # This program is free software: you can redistribute it and/or modify
    # it under the terms of the GNU Affero General Public License as
    # published by the Free Software Foundation, either version 3 of the
    # License, or (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU Affero General Public License for more details.
    #
    # You should have received a copy of the GNU Affero General Public License
    # along with this program. If not, see <https://www.gnu.org/licenses/>.
    #
    # ** end header
    #
    """test_authentication_plain.
    
    Unit tests for the modul caosdb.connection.authentication.plain.
    """
    
    from __future__ import unicode_literals
    from pytest import raises
    from caosdb.connection.authentication.plain import PlainTextCredentialsProvider
    
    def test_subclass_configure():
        """Test the correct passing of the password argument."""
        class SubClassOf(PlainTextCredentialsProvider):
            """A simple subclass of PlainTextCredentialsProvider."""
    
            def configure(self, **config):
                super(SubClassOf, self).configure(password="added in subclass", **config)
    
        instance = SubClassOf()
        instance.configure()
        assert instance.password == "added in subclass"
    
        instance.configure(**{"somearg": "BLA"})
        assert instance.password == "added in subclass"
    
        instance.configure(somearg="BLA")
        assert instance.password == "added in subclass"
    
        with raises(TypeError) as exc_info:
            instance.configure(password="OH NO!")
        assert exc_info.value.args[0] == ("configure() got multiple values for "
                                          "keyword argument 'password'")
    
    def test_plain_has_logger():
        p = PlainTextCredentialsProvider()
        assert hasattr(p, "logger")
        assert p.logger.name == "authentication"