Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix E2E Extended tests by adding admin_username override. #4397

Merged
merged 9 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion e2e_tests/test_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ async def test_bulk_updates_to_ensure_each_resource_updated_in_series(verify) ->
"properties": {
"display_name": "Perf test VM",
"description": "",
"os_image": "Ubuntu 22.04 LTS"
"os_image": "Ubuntu 22.04 LTS",
"admin_username": "researcher"
}
}

Expand Down
3 changes: 2 additions & 1 deletion e2e_tests/test_workspace_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ async def test_create_guacamole_service_into_base_workspace(setup_test_workspace
"properties": {
"display_name": "My VM",
"description": "Will be using this VM for my research",
"os_image": "Windows 10"
"os_image": "Windows 10",
"admin_username": "researcher"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ parameters:
- name: os_image
type: string
default: "Ubuntu 22.04 LTS"
- name: admin_username
type: string
default: ""
- name: vm_size
type: string
default: "2 CPU | 8GB RAM"
Expand Down Expand Up @@ -166,6 +169,7 @@ install:
parent_service_id: ${ bundle.parameters.parent_service_id }
tre_resource_id: ${ bundle.parameters.id }
image: ${ bundle.parameters.os_image }
admin_username: ${ bundle.parameters.admin_username }
vm_size: ${ bundle.parameters.vm_size }
shared_storage_access: ${ bundle.parameters.shared_storage_access }
shared_storage_name: ${ bundle.parameters.shared_storage_name }
Expand Down Expand Up @@ -201,6 +205,7 @@ upgrade:
parent_service_id: ${ bundle.parameters.parent_service_id }
tre_resource_id: ${ bundle.parameters.id }
image: ${ bundle.parameters.os_image }
admin_username: ${ bundle.parameters.admin_username }
vm_size: ${ bundle.parameters.vm_size }
shared_storage_access: ${ bundle.parameters.shared_storage_access }
shared_storage_name: ${ bundle.parameters.shared_storage_name }
Expand Down Expand Up @@ -248,6 +253,7 @@ uninstall:
parent_service_id: ${ bundle.parameters.parent_service_id }
tre_resource_id: ${ bundle.parameters.id }
image: ${ bundle.parameters.os_image }
admin_username: ${ bundle.parameters.admin_username }
vm_size: ${ bundle.parameters.vm_size }
shared_storage_access: ${ bundle.parameters.shared_storage_access }
shared_storage_name: ${ bundle.parameters.shared_storage_name }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
"Ubuntu 22.04 LTS"
]
},
"admin_username": {
"type": "string",
"title": "Admin username",
"description": "Overide automatic admin username generation.",
"default": ""
},
"vm_size": {
"$id": "#/properties/vm_size",
"type": "string",
Expand Down Expand Up @@ -126,5 +132,10 @@
]
}
}
]
],
"uiSchema": {
"admin_username": {
"classNames": "tre-hidden"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@ data "azurerm_storage_account" "stg" {
}

data "azuread_user" "user" {
count = var.admin_username == "" ? 1 : 0
object_id = var.owner_id
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ locals {
keyvault_name = lower("kv-${substr(local.workspace_resource_name_suffix, -20, -1)}")
storage_name = lower(replace("stg${substr(local.workspace_resource_name_suffix, -8, -1)}", "-", ""))
admin_username = (
length(data.azuread_user.user.mail) > 0 && strcontains(data.azuread_user.user.user_principal_name, "#EXT#") ?
substr(element(split("@", data.azuread_user.user.mail), 0), 0, 20) :
substr(element(split("#EXT#", element(split("@", data.azuread_user.user.user_principal_name), 0)), 0), 0, 20)
var.admin_username == "" ?
(length(data.azuread_user.user[0].mail) > 0 && strcontains(data.azuread_user.user[0].user_principal_name, "#EXT#") ?
substr(element(split("@", data.azuread_user.user[0].mail), 0), 0, 20) :
substr(element(split("#EXT#", element(split("@", data.azuread_user.user[0].user_principal_name), 0)), 0), 0, 20)
) :
var.admin_username
)
vm_password_secret_name = "${local.vm_name}-admin-credentials"
tre_user_resources_tags = {
Expand All @@ -19,7 +22,7 @@ locals {
tre_workspace_service_id = var.parent_service_id
tre_user_resource_id = var.tre_resource_id
tre_user_id = var.owner_id
tre_user_username = data.azuread_user.user.user_principal_name
tre_user_username = var.admin_username == "" ? local.admin_username : var.admin_username
}
nexus_proxy_url = "https://nexus-${data.azurerm_public_ip.app_gateway_ip.fqdn}"
# Load VM SKU/image details from porter.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ variable "key_store_id" {
type = string
}
variable "auth_tenant_id" {
type = string
description = "Used to authenticate into the AAD Tenant to create the AAD App"
type = string
}
variable "auth_client_id" {
type = string
description = "Used to authenticate into the AAD Tenant to create the AAD App"
type = string
}
variable "auth_client_secret" {
type = string
description = "Used to authenticate into the AAD Tenant to create the AAD App"
type = string
}
variable "admin_username" {
type = string
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
schemaVersion: 1.0.0
name: tre-service-guacamole-windowsvm
version: 1.2.10
version: 1.2.14
description: "An Azure TRE User Resource Template for Guacamole (Windows 10)"
dockerfile: Dockerfile.tmpl
registry: azuretre
Expand Down Expand Up @@ -104,6 +104,9 @@ parameters:
- name: os_image
type: string
default: "Windows 10"
- name: admin_username
type: string
default: ""
- name: vm_size
type: string
default: "2 CPU | 8GB RAM"
Expand Down Expand Up @@ -164,6 +167,7 @@ install:
parent_service_id: ${ bundle.parameters.parent_service_id }
tre_resource_id: ${ bundle.parameters.id }
image: ${ bundle.parameters.os_image }
admin_username: ${ bundle.parameters.admin_username }
vm_size: ${ bundle.parameters.vm_size }
shared_storage_access: ${ bundle.parameters.shared_storage_access }
shared_storage_name: ${ bundle.parameters.shared_storage_name }
Expand Down Expand Up @@ -196,6 +200,7 @@ upgrade:
parent_service_id: ${ bundle.parameters.parent_service_id }
tre_resource_id: ${ bundle.parameters.id }
image: ${ bundle.parameters.os_image }
admin_username: ${ bundle.parameters.admin_username }
vm_size: ${ bundle.parameters.vm_size }
shared_storage_access: ${ bundle.parameters.shared_storage_access }
shared_storage_name: ${ bundle.parameters.shared_storage_name }
Expand Down Expand Up @@ -240,6 +245,7 @@ uninstall:
parent_service_id: ${ bundle.parameters.parent_service_id }
tre_resource_id: ${ bundle.parameters.id }
image: ${ bundle.parameters.os_image }
admin_username: ${ bundle.parameters.admin_username }
vm_size: ${ bundle.parameters.vm_size }
shared_storage_access: ${ bundle.parameters.shared_storage_access }
shared_storage_name: ${ bundle.parameters.shared_storage_name }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
"Server 2019 Data Science VM"
]
},
"admin_username": {
"type": "string",
"title": "Admin username",
"description": "Overide automatic admin username generation.",
"default": ""
},
"vm_size": {
"$id": "#/properties/vm_size",
"type": "string",
Expand All @@ -57,5 +63,10 @@
"default": true,
"description": "Enable access to shared storage"
}
},
"uiSchema": {
"admin_username": {
"classNames": "tre-hidden"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ data "azurerm_user_assigned_identity" "ws_encryption_identity" {
}

data "azuread_user" "user" {
count = var.admin_username == "" ? 1 : 0
object_id = var.owner_id
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ locals {
keyvault_name = lower("kv-${substr(local.workspace_resource_name_suffix, -20, -1)}")
storage_name = lower(replace("stg${substr(local.workspace_resource_name_suffix, -8, -1)}", "-", ""))
admin_username = (
length(data.azuread_user.user.mail) > 0 && strcontains(data.azuread_user.user.user_principal_name, "#EXT#") ?
substr(element(split("@", data.azuread_user.user.mail), 0), 0, 20) :
substr(element(split("#EXT#", element(split("@", data.azuread_user.user.user_principal_name), 0)), 0), 0, 20)
var.admin_username == "" ?
(length(data.azuread_user.user[0].mail) > 0 && strcontains(data.azuread_user.user[0].user_principal_name, "#EXT#") ?
substr(element(split("@", data.azuread_user.user[0].mail), 0), 0, 20) :
substr(element(split("#EXT#", element(split("@", data.azuread_user.user[0].user_principal_name), 0)), 0), 0, 20)
) :
var.admin_username
)
vm_password_secret_name = "${local.vm_name}-admin-credentials"
tre_user_resources_tags = {
Expand All @@ -19,7 +22,7 @@ locals {
tre_workspace_service_id = var.parent_service_id
tre_user_resource_id = var.tre_resource_id
tre_user_id = var.owner_id
tre_user_username = data.azuread_user.user.user_principal_name
tre_user_username = var.admin_username == "" ? local.admin_username : var.admin_username
}
nexus_proxy_url = "https://nexus-${data.azurerm_public_ip.app_gateway_ip.fqdn}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ variable "key_store_id" {
type = string
}
variable "auth_tenant_id" {
type = string
description = "Used to authenticate into the AAD Tenant to create the AAD App"
type = string
}
variable "auth_client_id" {
type = string
description = "Used to authenticate into the AAD Tenant to create the AAD App"
type = string
}
variable "auth_client_secret" {
type = string
description = "Used to authenticate into the AAD Tenant to create the AAD App"
type = string
}
variable "admin_username" {
type = string
}
Loading