def test_load_config_serverless(self):
        # Setup
        config_data = [
            'logging:\n',
            '  file: logfile-test.log\n',
            'security_server:\n'
        ]

        tmpfile = tempfile.NamedTemporaryFile(mode="w", prefix="xrdsst-", suffix='.yaml', delete=False)
        tmpfile.writelines(config_data)
        tmpfile.close()

        # Given
        config_file = tmpfile.name
        base_controller = BaseController()
        base_controller.app = Mock()
        base_controller.app.close = Mock(return_value=None)
        base_controller.is_output_tabulated = Mock(return_value=True)

        # When
        base_controller.load_config(config_file)

        # Cleanup
        os.remove(config_file)

        # Then
        out, err = self.capsys.readouterr()
        assert err.count("No security servers defined") > 0

        with self.capsys.disabled():
            sys.stdout.write(out)
            sys.stderr.write(err)

        base_controller.app.close.assert_called_once_with(os.EX_CONFIG)
    def test_load_config_servers_name_or_url_non_unique(self):
        # Setup
        config_data = [
            'logging:\n',
            '  file: logfile-test.log\n',
            'security_server:\n',
            '  - name: first\n',
            '    url: first_url\n',
            '  - name: second\n',
            '    url: second_url\n',
            '  - url: third_url\n',
            '    name: third\n',
            '  - name: fourth\n',
            '    url: third_url\n',
            '    security_server_code: QED\n',
            '  - name: fifth\n',
            '    url: second_url\n',
            '  - name: first\n',
            '    url: faraway.com\n'
        ]

        tmpfile = tempfile.NamedTemporaryFile(mode="w", prefix="xrdsst-", suffix='.yaml', delete=False)
        tmpfile.writelines(config_data)
        tmpfile.close()

        # Given
        config_file = tmpfile.name
        base_controller = BaseController()
        base_controller.app = Mock()
        base_controller.app.close = Mock(return_value=None)
        base_controller.is_output_tabulated = Mock(return_value=True)

        # When
        base_controller.load_config(config_file)

        # Cleanup
        os.remove(config_file)

        # Then
        out, err = self.capsys.readouterr()
        assert err.count("security_server[1] 'name' value 'first' is non-unique") == 1
        assert err.count("security_server[6] 'name' value 'first' is non-unique") == 1
        assert err.count("security_server[2] 'url' value 'second_url' is non-unique") == 1
        assert err.count("security_server[5] 'url' value 'second_url' is non-unique") == 1
        assert err.count("security_server[3] 'url' value 'third_url' is non-unique") == 1
        assert err.count("security_server[4] 'url' value 'third_url' is non-unique") == 1

        with self.capsys.disabled():
            sys.stdout.write(out)
            sys.stderr.write(err)

        base_controller.app.close.assert_called_once_with(os.EX_CONFIG)