Added schema for msi to protectedSettings for CSE Linux

This commit is contained in:
Bhaskar Brahma 2019-07-19 13:38:07 -07:00
Родитель 1f9c51c15e
Коммит efcd9c6711
2 изменённых файлов: 29 добавлений и 1 удалений

Просмотреть файл

@ -73,7 +73,23 @@ const (
"description": "Key for the Azure Storage Account (a base64 encoded string)",
"type": "string",
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$"
}
},
"managedServiceIdentity": {
"description": "Setting to use Managed Service Identity to try to download fileUri from azure blob",
"type": "object",
"properties": {
"objectId": {
"description": "Object id that identifies the user created managed identity",
"type": "string",
"pattern": "^(?:[0-9A-Fa-f]{8}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{12})$"
},
"clientId": {
"description": "Client id that identifies the user created managed identity",
"type": "string",
"pattern": "^(?:[0-9A-Fa-f]{8}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{12})$"
}
}
}
},
"additionalProperties": false
}`

Просмотреть файл

@ -144,3 +144,15 @@ func TestValidateProtectedSettings_storageAccountKey(t *testing.T) {
require.Nil(t, validateProtectedSettings(`{"storageAccountKey": "A+hMRrsZQ6COPXTYX/EiKiF2HVtfhCfLDo3Dkc3ekKoX3jA58zXVG2QRe/C1+zdEFSrVX6FZsKyivsSlnwmWOw=="}`), "ok")
require.Nil(t, validateProtectedSettings(`{"storageAccountKey": "/yGnx6KyxQ8Pjzk0QXeY+66Du0BeTWaCt83la59w72hu/81e6TzskXXvL/IlO3q6g0k0kJrR9MYQNi+cNR3SXA=="}`), "ok")
}
func TestValidateProtectedSettings_managedServiceIdentity(t *testing.T) {
require.NoError(t, validateProtectedSettings(`{"managedServiceIdentity": { "clientId": "31b403aa-c364-4240-a7ff-d85fb6cd7232"}}`),
"couldn't parse msi proprety with lowercase guid")
require.NoError(t, validateProtectedSettings(`{"managedServiceIdentity": { "objectId": "31B403AA-C364-4240-A7FF-D85FB6CD7232"}}`),
"couldn't parse msi property with uppercase guid")
require.NoError(t, validateProtectedSettings(`{"managedServiceIdentity": { }}`),
"couldn't parse msi property without clientId or objectId")
require.Error(t, validateProtectedSettings(`{"managedServiceIdentity": { "clientId": "notaguid"}}`),
"guid validation succeded when expected to fail")
}