SCAutolib.controller

Classes

class Controller(config=None, params=None)[source]

Constructor will parse and check input configuration file. If some required fields in the configuration are missing, CLI parameters would be checked if missing values are there. If not, an exception would be raised. After parsing the configuration file and filling internal values of the Controller object, other related objects (users, cards, CAs, Authselect, etc.) would be initialised, but any real action that would affect the system wouldn’t be made.

Parameters:
  • config (pathlib.Path or str) – Path to configuration file with metadata for testing.

  • params (dict) – Parameters from CLI

Returns:

static _general_steps_for_ipa()[source]

General system preparation for installing IPA client on RHEL/Fedora

Returns:

name of the IPA client package for current Linux

static _general_steps_for_virtual_sc()[source]

Prepare the system for virtual smart card. Preparation means to configure pcscd service and opensc module to work correctly with virtual smart card. Also, repository for installing virt_cacard package is added in this method.

static _validate_configuration(conf, params=None)[source]

Validate schema of the configuration file. If some value is not present in the config file, this value would be looked in the CLI parameters

Parameters:
  • conf (dict) – Configuration to be parsed (e.g. data loaded from JSON file)

  • params (dict) – CLI arguments

Returns:

dictionary with parsed values from conf and params attributes. All values are retyped to specified type.

Return type:

dict

cleanup()[source]

Clean the system after setup. This method restores the SSSD config file, deletes created users with cards, remove CA’s (local and/or IPA Client)

enroll_card(card)[source]

Enroll the card - i.e. upload keys and certs to card. If private key and/or the certificate do not exist, new one’s would be requested from corresponding CA.

Parameters:

card (card.VirtualCard) – card object

get_user_dict(name)[source]

Get user dictionary from the config file.

Parameters:

name (str) – name of the user

Returns:

user dictionary

Return type:

dict

init_ca(local=False)[source]

Initialize CA.

Parameters:

local (bool) – if True, local CA is initialized, otherwise IPA

prepare(force, gdm, install_missing, graphical)[source]

Prepare system for testing. This method provides complex configuration of system under test for testing including creation of CAs, users and smart cards in the system and objects that represents them in SCAutolib. Configuration is based on config file and CLI options.

Parameters:
  • force (bool) – Defines if existing objects, files, users, services etc. should be erased or overwritten if they already exist. True stands for erase/overwrite. This parameter is forwarded to several methods and it can have slightly different meaning in each of them. For details see docstrings of the methods.

  • gdm (bool) – If True, GDM package would be installed

  • install_missing (bool) – If True, all missing packages would be installed

  • graphical (bool) – If True, GUI tests dependencies are installed

prepare_softhsm_config(card_dir=None)[source]

Prepare SoftHSM2 config for virtual card

prepare_user_cnf(card)[source]

Prepare user openssl cnf

setup_card(card_dict, force=False)[source]

Create card object. Card object should contain its root CA cert as it represents general card (i.e. including physical read-only cards).

Parameters:
  • card_dict (dict) – Dictionary containing card attributes

  • force (bool) – If its true and card directory exists it will be removed

setup_ipa_client(force=False)[source]

Configure IPA client for given IPA server on current host. IPA server should be already up and running for correct configuration of the IPA client

Parameters:

force (bool) – If IPA Client is already configured on the system, specifies if it should be removed before configuring a new client.

Raises:

SCAutolib.exceptions.SCAutolibWrongConfig

setup_local_ca(force=False)[source]

Setup local CA based on configuration from the configuration file. All necessary files for this operation (e.g. CNF file for self-signed root certificate) would be created along the way.

Parameters:

force (bool) – If local CA already exists in given directory, specifies if it should be overwritten

Raises:

SCAutolib.exceptions.SCAutolibWrongConfig

setup_system(install_missing, gdm, graphical)[source]

Do general system setup meaning package installation based on specifications in the configuration file, SSSD configuration, configurations for virtual smart cards, etc.

Parameters:
  • install_missing (bool) – If True, all missing packages would be installed

  • gdm (bool) – If True, GDM package would be installed

  • graphical (bool) – If True, GUI tests dependencies are installed

Returns:

setup_user(user_dict, force=False)[source]

Configure the user on the specified system (local machine/CA).

Parameters:
  • force (bool) – specify if the user should be re-created with its card directory

  • user_dict (dict) – set of values to initialise the user

Returns:

the user object