Skip to content
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
47 changes: 37 additions & 10 deletions tests/local/input_entra_id.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ run "entra_id_extension_and_identity_type_should_be_created" {

variables {
extensions = []

entra_id_login = {
enabled = true
admin_login_principal_ids = ["00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000001"]
}

}

assert {
Expand All @@ -22,23 +22,24 @@ run "entra_id_extension_and_identity_type_should_be_created" {

assert {
condition = local.identity_type == "SystemAssigned"
error_message = "It is not possible to install the EntraID-Extension without setting the Idenity to 'SystemAssigned' OR 'SystemAssigned, UserAssigned'."
error_message = "It is not possible to install the EntraID-Extension without setting the Identity to 'SystemAssigned' OR 'SystemAssigned, UserAssigned'."
}

}

run "entra_id_extension_and_add_identity_type_should_be_created" {
command = plan

variables {
extensions = []

identity = {
type = "UserAssigned" }
type = "UserAssigned"
}

entra_id_login = {
enabled = true
admin_login_principal_ids = ["00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000001"]
}

}

assert {
Expand All @@ -48,9 +49,8 @@ run "entra_id_extension_and_add_identity_type_should_be_created" {

assert {
condition = local.identity_type == "SystemAssigned, UserAssigned"
error_message = "It is not possible to install the EntraID-Extension without setting the Idenity to 'SystemAssigned' OR 'SystemAssigned, UserAssigned'."
error_message = "It is not possible to install the EntraID-Extension without setting the Identity to 'SystemAssigned' OR 'SystemAssigned, UserAssigned'."
}

}

run "nothing_should_be_created_regarding_entra_id_login" {
Expand All @@ -74,26 +74,53 @@ run "nothing_should_be_created_regarding_entra_id_login" {
condition = local.identity_type == var.identity
error_message = "No identity type should be created when 'entra_id_login' is disabled."
}

}

run "entra_id_extension_and_identity_type_is_given" {
command = plan

variables {
extensions = []

identity = {
type = "SystemAssigned, UserAssigned" }
type = "SystemAssigned, UserAssigned"
}

entra_id_login = {
enabled = true
admin_login_principal_ids = ["00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000001"]
}

}

assert {
condition = local.identity_type == "SystemAssigned, UserAssigned"
error_message = "Keep 'SystemAssigned, UserAssigned' in case of usage."
}
}

run "entra_id_extension_created_without_principal_ids_and_no_role_assignments" {
command = plan

variables {
extensions = []

entra_id_login = {
enabled = true
}
}

assert {
condition = length(azurerm_virtual_machine_extension.entra_id_login) == 1
error_message = "The EntraID extension should be created even if no principal IDs are provided."
}

assert {
condition = length(azurerm_role_assignment.entra_id_login_user) == 0
error_message = "No user role assignments should be created when no principal IDs are provided for EntraID login."
}

assert {
condition = length(azurerm_role_assignment.entra_id_login_admin) == 0
error_message = "No admin role assignments should be created when no principal IDs are provided for EntraID login."
}
}
11 changes: 0 additions & 11 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -342,17 +342,6 @@ variable "entra_id_login" {
!contains(["Standard_B1ls", "Basic_A0", "Standard_A0"], var.size))
error_message = "Entra ID Extension requires at least 1GB of memory; set var.size to an SKU that meets this requirement."
}

validation {
condition = anytrue([
!var.entra_id_login.enabled,
length(var.entra_id_login.principal_ids) > 0,
length(var.entra_id_login.admin_login_principal_ids) > 0,
length(var.entra_id_login.user_login_principal_ids) > 0
])
error_message = "When 'entra_id_login.enabled' is 'true', 'admin_login_principal_ids' or 'user_login_principal_ids' must contain at least one valid principal ID."
}

}

variable "extensions" {
Expand Down
Loading