Exemplo n.º 1
0
 def __set_name__(self, owner, name):
     self.attr_name = name
     self.config_attr_name = f"{self.config_section}_{name}"
     entry = ConfigEntry(
         name, self.dtype, default=self.default, required=self.required
     )
     self.registered_entries.append(entry)
Exemplo n.º 2
0
def test_config_extend(config):
    config.register([
        ConfigSection(
            "extra_plugin",
            [
                ConfigEntry("some", str),
                ConfigEntry("config", str),
                ConfigEntry("has_default", str, "iamdefault"),
            ],
        )
    ])

    assert config.extra_plugin_some == 'testvalue'
    assert config.extra_plugin_config == 'othervalue'
    assert config.extra_plugin_has_default == 'iamdefault'

    config._config_map.pop()
Exemplo n.º 3
0
def test_config_extend_require(config):
    with pytest.raises(ConfigError):
        config.register([
            ConfigSection(
                "other_plugin",
                [
                    ConfigEntry("some_config_value", str),
                ],
            )
        ])
    # remove last entry again
    config._config_map.pop()
Exemplo n.º 4
0
 def _make_config(self):
     section = ConfigSection(
         "pamauthenticator",
         [
             ConfigEntry("provider", str, default="pam", required=False),
             ConfigEntry("service", str, default="login", required=False),
             ConfigEntry("encoding", str, default="utf8", required=False),
             ConfigEntry(
                 "check_account", bool, default=True, required=False),
             ConfigEntry("admin_groups", list, default=list,
                         required=False),
             ConfigEntry(
                 "maintainer_groups", list, default=list, required=False),
             ConfigEntry(
                 "member_groups", list, default=list, required=False),
         ],
     )
     return [section]
Exemplo n.º 5
0
    def configure(self, config: Config):

        config.register([
            ConfigSection(
                "dictauthenticator",
                [
                    ConfigEntry("users", list, default=list),
                ],
            )
        ])

        if config.configured_section("dictauthenticator"):
            self.passwords = dict(
                user_pass.split(":")
                for user_pass in config.dictauthenticator_users)
            self.is_enabled = True
        else:
            self.passwords = {}

        # call the config of base class to configure default roles and
        # channels
        super().configure(config)