/tests/tpath/idem_aws/tool/org_test_util.py

https://gitlab.com/pgeorgiev_vmw/idem-aws · Python · 37 lines · 32 code · 5 blank · 0 comment · 0 complexity · 762b06cdcf7e0539d57d2745f6cb4ccc MD5 · raw file

  1. import re
  2. ORGANIZATION_ARN_FORMAT = "arn:aws:organizations::{0}:organization/{1}"
  3. MASTER_ACCOUNT_ARN_FORMAT = "arn:aws:organizations::{0}:account/{1}/{0}"
  4. ACCOUNT_ARN_FORMAT = "arn:aws:organizations::{0}:account/{1}/{2}"
  5. ORG_ID_SIZE = 10
  6. ORG_ID_REGEX = r"o-[a-z0-9]{%s}" % ORG_ID_SIZE
  7. def validate_organization(hub, response):
  8. org = response
  9. assert sorted(org.keys()) == (
  10. [
  11. "arn",
  12. "available_policy_types",
  13. "feature_set",
  14. "master_account_arn",
  15. "master_account_email",
  16. "master_account_id",
  17. "name",
  18. "resource_id",
  19. "roots",
  20. ]
  21. )
  22. assert re.compile(ORG_ID_REGEX).match(org["resource_id"])
  23. assert org["master_account_arn"] == MASTER_ACCOUNT_ARN_FORMAT.format(
  24. org["master_account_id"], org["resource_id"]
  25. )
  26. assert org["arn"] == ORGANIZATION_ARN_FORMAT.format(
  27. org["master_account_id"], org["resource_id"]
  28. )
  29. assert org["feature_set"] in ["ALL", "CONSOLIDATED_BILLING"]
  30. assert org["available_policy_types"] == [
  31. {"Type": "SERVICE_CONTROL_POLICY", "Status": "ENABLED"}
  32. ]