Add basics checks for token validity in the autoinstall JSON schema
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
parent
d345cf999a
commit
81c67780ff
|
@ -264,7 +264,11 @@
|
|||
"type": "object",
|
||||
"properties": {
|
||||
"token": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"minLength": 24,
|
||||
"maxLength": 30,
|
||||
"pattern": "^C[1-9A-HJ-NP-Za-km-z]+$",
|
||||
"description": "A valid token starts with a C and is followed by 23 to 29 Base58 characters.\nSee https://pkg.go.dev/github.com/btcsuite/btcutil/base58#CheckEncode"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -43,7 +43,8 @@ snaps:
|
|||
updates: all
|
||||
timezone: Pacific/Guam
|
||||
ubuntu-advantage:
|
||||
token: "dummy-token"
|
||||
# Token that passes the basic format checking but is invalid (i.e. contains more than 16 bytes of random data)
|
||||
token: C1NWcZTHLteJXGVMM6YhvHDpGrhyy7
|
||||
storage:
|
||||
config:
|
||||
- {type: disk, ptable: gpt, path: /dev/vdb, wipe: superblock, preserve: false, grub_device: true, id: disk-1}
|
||||
|
|
|
@ -161,7 +161,7 @@ python3 scripts/check-yaml-fields.py .subiquity/var/log/installer/subiquity-curt
|
|||
python3 scripts/check-yaml-fields.py <(python3 scripts/check-yaml-fields.py .subiquity/etc/cloud/cloud.cfg.d/99-installer.cfg datasource.None.userdata_raw) \
|
||||
locale='"en_GB.UTF-8"' \
|
||||
timezone='"Pacific/Guam"' \
|
||||
ubuntu_advantage.token='"dummy-token"' \
|
||||
ubuntu_advantage.token='"C1NWcZTHLteJXGVMM6YhvHDpGrhyy7"' \
|
||||
'snap.commands=[snap install --channel=3.2/stable etcd]'
|
||||
grep -q 'finish: subiquity/Install/install/postinstall/install_package1: SUCCESS: installing package1' \
|
||||
.subiquity/subiquity-server-debug.log
|
||||
|
|
|
@ -22,6 +22,10 @@ from subiquity.server.controller import SubiquityController
|
|||
|
||||
log = logging.getLogger("subiquity.server.controllers.ubuntu_advantage")
|
||||
|
||||
TOKEN_DESC = """\
|
||||
A valid token starts with a C and is followed by 23 to 29 Base58 characters.
|
||||
See https://pkg.go.dev/github.com/btcsuite/btcutil/base58#CheckEncode"""
|
||||
|
||||
|
||||
class UbuntuAdvantageController(SubiquityController):
|
||||
""" Represent the server-side Ubuntu Advantage controller. """
|
||||
|
@ -35,6 +39,10 @@ class UbuntuAdvantageController(SubiquityController):
|
|||
"properties": {
|
||||
"token": {
|
||||
"type": "string",
|
||||
"minLength": 24,
|
||||
"maxLength": 30,
|
||||
"pattern": "^C[1-9A-HJ-NP-Za-km-z]+$",
|
||||
"description": TOKEN_DESC,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue