organizations: add endpoint list_roots
This commit is contained in:
parent
c40d2be646
commit
6c0c6148f1
6 changed files with 122 additions and 8 deletions
|
|
@ -9,9 +9,11 @@ from moto import organizations as orgs
|
|||
|
||||
# utils
|
||||
print(orgs.utils.make_random_org_id())
|
||||
print(orgs.utils.make_random_root_id())
|
||||
root_id = orgs.utils.make_random_root_id()
|
||||
print(root_id)
|
||||
print(orgs.utils.make_random_ou_id(root_id))
|
||||
print(orgs.utils.make_random_account_id())
|
||||
print(orgs.utils.make_random_create_account_id())
|
||||
print(orgs.utils.make_random_create_account_status_id())
|
||||
|
||||
# models
|
||||
my_org = orgs.models.FakeOrganization(feature_set='ALL')
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from __future__ import unicode_literals
|
|||
import boto3
|
||||
import sure # noqa
|
||||
import datetime
|
||||
import yaml
|
||||
|
||||
from moto import mock_organizations
|
||||
from moto.organizations.models import (
|
||||
|
|
@ -11,6 +12,7 @@ from moto.organizations.models import (
|
|||
ORGANIZATION_ARN_FORMAT,
|
||||
MASTER_ACCOUNT_ARN_FORMAT,
|
||||
ACCOUNT_ARN_FORMAT,
|
||||
ROOT_ARN_FORMAT,
|
||||
)
|
||||
from .test_organizations_utils import (
|
||||
ORG_ID_REGEX,
|
||||
|
|
@ -111,6 +113,28 @@ def test_describe_organization():
|
|||
#assert False
|
||||
|
||||
|
||||
@mock_organizations
|
||||
def test_list_roots():
|
||||
client = boto3.client('organizations', region_name='us-east-1')
|
||||
org = client.create_organization(FeatureSet='ALL')['Organization']
|
||||
response = client.list_roots()
|
||||
#print(yaml.dump(response, default_flow_style=False))
|
||||
response.should.have.key('Roots').should.be.a(list)
|
||||
response['Roots'].should_not.be.empty
|
||||
root = response['Roots'][0]
|
||||
root.should.have.key('Id').should.match(ROOT_ID_REGEX)
|
||||
root.should.have.key('Arn').should.equal(ROOT_ARN_FORMAT.format(
|
||||
org['MasterAccountId'],
|
||||
org['Id'],
|
||||
root['Id'],
|
||||
))
|
||||
root.should.have.key('Name').should.be.a(str)
|
||||
root.should.have.key('PolicyTypes').should.be.a(list)
|
||||
root['PolicyTypes'][0].should.have.key('Type').should.equal('SERVICE_CONTROL_POLICY')
|
||||
root['PolicyTypes'][0].should.have.key('Status').should.equal('ENABLED')
|
||||
#assert False
|
||||
|
||||
|
||||
mockname = 'mock-account'
|
||||
mockdomain = 'moto-example.org'
|
||||
mockemail = '@'.join([mockname, mockdomain])
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ from moto.organizations import utils
|
|||
|
||||
ORG_ID_REGEX = r'o-[a-z0-9]{%s}' % utils.ORG_ID_SIZE
|
||||
ROOT_ID_REGEX = r'r-[a-z0-9]{%s}' % utils.ROOT_ID_SIZE
|
||||
OU_ID_REGEX = r'ou-[a-z0-9]{%s}-[a-z0-9]{%s}' % (utils.ROOT_ID_SIZE, utils.OU_ID_SUFFIX_SIZE)
|
||||
ACCOUNT_ID_REGEX = r'[0-9]{%s}' % utils.ACCOUNT_ID_SIZE
|
||||
CREATE_ACCOUNT_STATUS_ID_REGEX = r'car-[a-z0-9]{%s}' % utils.CREATE_ACCOUNT_STATUS_ID_SIZE
|
||||
|
||||
|
|
@ -15,8 +16,14 @@ def test_make_random_org_id():
|
|||
|
||||
|
||||
def test_make_random_root_id():
|
||||
org_id = utils.make_random_root_id()
|
||||
org_id.should.match(ROOT_ID_REGEX)
|
||||
root_id = utils.make_random_root_id()
|
||||
root_id.should.match(ROOT_ID_REGEX)
|
||||
|
||||
|
||||
def test_make_random_ou_id():
|
||||
root_id = utils.make_random_root_id()
|
||||
ou_id = utils.make_random_ou_id(root_id)
|
||||
ou_id.should.match(OU_ID_REGEX)
|
||||
|
||||
|
||||
def test_make_random_account_id():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue