test(e2e): Add test for LDAP (#4061)
* test(e2e): Add test for LDAP This adds the infrastructure and a test for an LDAP workflow * test(e2e): Refactor test packages This reduces the number of scenarios needed * CR * fixup! test(e2e): Add test for LDAP
This commit is contained in:
1 parent
a89573b35f
commit
093f889333
13 files changed
+451
-41
No files matched your search
@@ -0,0 +1,4 @@
|
||||
dn: cn=${group_name},${domain_dn}
|
||||
objectClass: groupOfUniqueNames
|
||||
cn: ${group_name}
|
||||
uniqueMember: cn=${user_name},${domain_dn}
|
||||
@@ -0,0 +1,6 @@
|
||||
dn: cn=${user_name},${domain_dn}
|
||||
objectClass: inetOrgPerson
|
||||
cn: ${user_name}
|
||||
sn: ${user_name}
|
||||
uid: ${user_name}
|
||||
userPassword: ${user_password}
|
||||
@@ -0,0 +1,131 @@
|
||||
# Copyright (c) HashiCorp, Inc.
|
||||
# SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
docker = {
|
||||
source = "kreuzwerker/docker"
|
||||
version = "3.0.1"
|
||||
}
|
||||
|
||||
enos = {
|
||||
source = "app.terraform.io/hashicorp-qti/enos"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
variable "image_name" {
|
||||
description = "Name of Docker Image"
|
||||
type = string
|
||||
default = "docker.mirror.hashicorp.services/osixia/openldap:latest"
|
||||
}
|
||||
variable "network_name" {
|
||||
description = "Name of Docker Networks to join"
|
||||
type = list(string)
|
||||
}
|
||||
variable "container_name" {
|
||||
description = "Name of Docker Container"
|
||||
type = string
|
||||
default = "ldap"
|
||||
}
|
||||
|
||||
locals {
|
||||
user_name = "einstein"
|
||||
user_password = "password"
|
||||
group_name = "scientists"
|
||||
domain = "example.org"
|
||||
domain_dn = "dc=example,dc=org"
|
||||
admin_dn = "cn=admin,${local.domain_dn}"
|
||||
admin_password = "admin"
|
||||
}
|
||||
|
||||
resource "docker_image" "ldap" {
|
||||
name = var.image_name
|
||||
keep_locally = true
|
||||
}
|
||||
|
||||
resource "docker_container" "ldap" {
|
||||
image = docker_image.ldap.image_id
|
||||
name = var.container_name
|
||||
env = [
|
||||
"LDAP_DOMAIN=${local.domain}",
|
||||
"LDAP_ADMIN_PASSWORD=${local.admin_password}",
|
||||
]
|
||||
upload {
|
||||
content = templatefile("${abspath(path.module)}/entries/user.ldif", {
|
||||
user_name = local.user_name
|
||||
user_password = local.user_password
|
||||
domain_dn = local.domain_dn
|
||||
})
|
||||
file = "/tmp/ldap/user.ldif"
|
||||
}
|
||||
upload {
|
||||
content = templatefile("${abspath(path.module)}/entries/group.ldif", {
|
||||
group_name = local.group_name
|
||||
user_name = local.user_name
|
||||
domain_dn = local.domain_dn
|
||||
})
|
||||
file = "/tmp/ldap/group.ldif"
|
||||
}
|
||||
|
||||
|
||||
healthcheck {
|
||||
test = ["CMD", "ldapsearch", "-H", "ldap://localhost", "-b", "${local.domain_dn}", "-D", "${local.admin_dn}", "-w", "${local.admin_password}"]
|
||||
}
|
||||
wait = true
|
||||
must_run = true
|
||||
dynamic "networks_advanced" {
|
||||
for_each = var.network_name
|
||||
content {
|
||||
name = networks_advanced.value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "enos_local_exec" "create_ldap_user" {
|
||||
depends_on = [
|
||||
docker_container.ldap
|
||||
]
|
||||
|
||||
inline = ["docker exec ${var.container_name} ldapadd -x -H ldap://localhost -D \"${local.admin_dn}\" -w ${local.admin_password} -f /tmp/ldap/user.ldif"]
|
||||
}
|
||||
|
||||
resource "enos_local_exec" "create_ldap_group" {
|
||||
depends_on = [
|
||||
docker_container.ldap,
|
||||
enos_local_exec.create_ldap_user,
|
||||
]
|
||||
|
||||
inline = ["docker exec ${var.container_name} ldapadd -x -H ldap://localhost -D \"${local.admin_dn}\" -w ${local.admin_password} -f /tmp/ldap/group.ldif"]
|
||||
}
|
||||
|
||||
output "address" {
|
||||
value = "ldap://${var.container_name}"
|
||||
}
|
||||
|
||||
output "domain_dn" {
|
||||
value = local.domain_dn
|
||||
}
|
||||
|
||||
output "admin_dn" {
|
||||
value = local.admin_dn
|
||||
}
|
||||
output "admin_password" {
|
||||
value = local.admin_password
|
||||
}
|
||||
|
||||
output "container_name" {
|
||||
value = var.container_name
|
||||
}
|
||||
|
||||
output "user_name" {
|
||||
value = local.user_name
|
||||
}
|
||||
|
||||
output "user_password" {
|
||||
value = local.user_password
|
||||
}
|
||||
|
||||
output "group_name" {
|
||||
value = local.group_name
|
||||
}
|
||||
@@ -161,28 +161,69 @@ variable "aws_bucket_name" {
|
||||
default = ""
|
||||
}
|
||||
variable "worker_tag_ingress" {
|
||||
type = string
|
||||
default = ""
|
||||
description = "Worker tag for the ingress worker"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
variable "worker_tag_egress" {
|
||||
type = string
|
||||
default = ""
|
||||
description = "Worker tag for the egress worker"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
variable "worker_tag_collocated" {
|
||||
type = string
|
||||
default = ""
|
||||
description = "Worker tag for the collocated worker"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
variable "postgres_user" {
|
||||
type = string
|
||||
default = ""
|
||||
description = "Username for accessing the postgres database"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
variable "postgres_password" {
|
||||
type = string
|
||||
default = ""
|
||||
description = "Password for accessing the postgres database"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
variable "postgres_database_name" {
|
||||
type = string
|
||||
default = ""
|
||||
description = "Name of postgres database"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
variable "ldap_address" {
|
||||
description = "URL to LDAP server"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
variable "ldap_domain_dn" {
|
||||
description = "Distinguished Name to the LDAP domain"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
variable "ldap_admin_dn" {
|
||||
description = "Distinguished Name to the LDAP admin user"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
variable "ldap_admin_password" {
|
||||
description = "Password for the LDAP admin user"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
variable "ldap_user_name" {
|
||||
description = "Username of an LDAP user"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
variable "ldap_user_password" {
|
||||
description = "Password for an LDAP user"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
variable "ldap_group_name" {
|
||||
description = "Name of LDAP group"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
variable "test_timeout" {
|
||||
type = string
|
||||
@@ -246,6 +287,13 @@ resource "enos_local_exec" "run_e2e_test" {
|
||||
E2E_WORKER_TAG_INGRESS = var.worker_tag_ingress
|
||||
E2E_WORKER_TAG_EGRESS = var.worker_tag_egress
|
||||
E2E_WORKER_TAG_COLLOCATED = var.worker_tag_collocated
|
||||
E2E_LDAP_ADDR = var.ldap_address
|
||||
E2E_LDAP_DOMAIN_DN = var.ldap_domain_dn
|
||||
E2E_LDAP_ADMIN_DN = var.ldap_admin_dn
|
||||
E2E_LDAP_ADMIN_PASSWORD = var.ldap_admin_password
|
||||
E2E_LDAP_USER_NAME = var.ldap_user_name
|
||||
E2E_LDAP_USER_PASSWORD = var.ldap_user_password
|
||||
E2E_LDAP_GROUP_NAME = var.ldap_group_name
|
||||
BOUNDARY_DIR = abspath(var.local_boundary_src_dir)
|
||||
BOUNDARY_CLI_DIR = abspath(var.local_boundary_dir)
|
||||
MODULE_DIR = abspath(path.module)
|
||||
|
||||
@@ -39,6 +39,13 @@ docker run \
|
||||
-e "E2E_WORKER_TAG_INGRESS=$E2E_WORKER_TAG_INGRESS" \
|
||||
-e "E2E_WORKER_TAG_EGRESS=$E2E_WORKER_TAG_EGRESS" \
|
||||
-e "E2E_WORKER_TAG_COLLOCATED=$E2E_WORKER_TAG_COLLOCATED" \
|
||||
-e "E2E_LDAP_ADDR=$E2E_LDAP_ADDR" \
|
||||
-e "E2E_LDAP_DOMAIN_DN=$E2E_LDAP_DOMAIN_DN" \
|
||||
-e "E2E_LDAP_ADMIN_DN=$E2E_LDAP_ADMIN_DN" \
|
||||
-e "E2E_LDAP_ADMIN_PASSWORD=$E2E_LDAP_ADMIN_PASSWORD" \
|
||||
-e "E2E_LDAP_USER_NAME=$E2E_LDAP_USER_NAME" \
|
||||
-e "E2E_LDAP_USER_PASSWORD=$E2E_LDAP_USER_PASSWORD" \
|
||||
-e "E2E_LDAP_GROUP_NAME=$E2E_LDAP_GROUP_NAME" \
|
||||
--mount type=bind,src=$BOUNDARY_DIR,dst=/src/boundary/ \
|
||||
--mount type=bind,src=$MODULE_DIR/../..,dst=/testlogs \
|
||||
--mount type=bind,src=$(go env GOCACHE),dst=/root/.cache/go-build \
|
||||
|
||||
Reference in new issue
Block a user