Skip to content

Commit

Permalink
Add: ubuntu_sso_email assertion when provisioning UC via zapper_kvm
Browse files Browse the repository at this point in the history
  • Loading branch information
p-gentili committed Aug 5, 2024
1 parent 0512b27 commit 9558ac7
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Unless specified via _autoinstall_ storage filter, the tool will select the larg
- __cmdline_append__ (optional): kernel parameters to append at the end of GRUB entry cmdline
- __base_user_data__ (optional): a string containing base64 encoded autoinstall user-data to use as base for provisioning, it should be validated against [this schema](https://canonical-subiquity.readthedocs-hosted.com/en/latest/reference/autoinstall-schema.html)
- __autoinstall_oem__: (optional): set to "true" to install OEM meta-packages and the reset partition (Desktop 24.04+)
- __ubuntu_sso_email__: (optional): a valid Ubuntu SSO email to which the DUT provisioned with a non-dangerous grade UC image will be linked

## Ubuntu Desktop 22.04 OEM

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ def _validate_configuration(
)
retries = self.job_data["provision_data"].get("robot_retries", 1)

# If a SSO email is specified, e.g. UC, username must match
# the local-part because that would be the only user available
# on the DUT after provisioning.
if "ubuntu_sso_email" in self.job_data["provision_data"]:
email = self.job_data["provision_data"]["ubuntu_sso_email"]
if username != email.split("@")[0]:
raise ProvisioningError(
"Test username doesn't match the provided "
"ubuntu_sso_email."
)

provisioning_data = {
"url": url,
"username": username,
Expand All @@ -119,6 +130,7 @@ def _validate_configuration(
"skip_download",
"wait_until_ssh",
"live_image",
"ubuntu_sso_email",
]
provisioning_data.update(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def test_validate_configuration_w_opt(self):
"skip_download": True,
"wait_until_ssh": True,
"live_image": False,
"ubuntu_sso_email": "username@domain.com",
},
"test_data": {
"test_username": "username",
Expand All @@ -115,10 +116,49 @@ def test_validate_configuration_w_opt(self):
"skip_download": True,
"wait_until_ssh": True,
"live_image": False,
"ubuntu_sso_email": "username@domain.com",
}
self.assertEqual(args, ())
self.assertDictEqual(kwargs, expected)

def test_validate_configuration_raises_sso(self):
"""
Test whether the validate_configuration raises an exception
if the provided test_username doesn't match with the SSO email.
"""

connector = DeviceConnector()
connector.config = {
"device_ip": "1.1.1.1",
"control_host": "1.1.1.2",
"reboot_script": ["cmd1", "cmd2"],
}
connector.job_data = {
"job_queue": "queue",
"provision_data": {
"url": "http://example.com/image.iso",
"robot_tasks": [
"job.robot",
"another.robot",
],
"storage_layout": "lvm",
"robot_retries": 3,
"cmdline_append": "more arguments",
"skip_download": True,
"wait_until_ssh": True,
"live_image": False,
"ubuntu_sso_email": "realuser@domain.com",
},
"test_data": {
"test_username": "username",
"test_password": "password",
},
}

connector._get_autoinstall_conf = Mock()
with self.assertRaises(ProvisioningError):
connector._validate_configuration()

def test_validate_configuration_alloem(self):
"""
Test whether the validate_configuration function returns
Expand Down
2 changes: 2 additions & 0 deletions docs/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ SecureBoot
SKU
SQA
SSID
SSO
subdirectories
subfolders
subtree
Expand All @@ -97,6 +98,7 @@ txt
Ubuntu
ubuntu
url
UC
UI
URI
USB
Expand Down
5 changes: 4 additions & 1 deletion docs/reference/device-connector-types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ The ``zapper_kvm`` device connector, depending on the target image, supports the
path from the ``robot/snippets`` path in the Zapper repository.
* - ``storage_layout``
- When provisioning an image supporting *autoinstall*, the storage_layout can
be either ``lvm`` (default), ``direct``, ``zfs`` or ``hybrid`` (Core, Desktop 23.10+)
be either ``lvm`` (default), ``direct``, ``zfs`` or ``hybrid`` (Desktop 23.10+, UC24)
* - ``cmdline_append``
- (Optional) When provisioning an image supporting *autoinstall*, the cmdline_append can
be used to append Kernel parameters to the standard GRUB entry.
Expand All @@ -295,6 +295,9 @@ The ``zapper_kvm`` device connector, depending on the target image, supports the
on this topic
* - ``autoinstall_oem``:
- (Optional) Set to "true" to install OEM meta-packages and the reset partition (Desktop 24.04+).
* - ``ubuntu_sso_email``:
- (Optional) A valid Ubuntu SSO email to which the DUT provisioned with a non-dangerous grade UC image will be linked (UC24).
.

.. list-table:: Supported ``provision_data`` keys for ``zapper_kvm`` with target Ubuntu OEM 22.04
:header-rows: 1
Expand Down

0 comments on commit 9558ac7

Please sign in to comment.