def _make_tenant(self, plan, env): tname = "tenant-{}".format(plan) email = "user@{}.com".format(tname) cli = CliTenantadm(containers_namespace=env.name) tid = cli.create_org(tname, email, "correcthorse", plan) tenant = cli.get_tenant(tid) tenant = json.loads(tenant) ttoken = tenant["tenant_token"] # the cli now sets all addons to 'enabled' - # disable them for initial 'all disabled' state update_tenant( tenant["id"], addons=[], container_manager=get_container_manager(), ) auth = Authentication(name=tname, username=email, password="******") auth.create_org = False auth.reset_auth_token() devauth = DeviceAuthV2(auth) env.new_tenant_client("test-container-{}".format(plan), ttoken) device = MenderDevice(env.get_mender_clients()[0]) devauth.accept_devices(1) devices = list( set([ device["id"] for device in devauth.get_devices_status("accepted") ])) assert 1 == len(devices) tenant = Tenant(tname, tid, ttoken) u = User("", email, "correcthorse") tenant.users.append(u) tenant.device = device tenant.device_id = devices[0] tenant.auth = auth tenant.devauth = devauth return tenant
def _make_trial_tenant(self, env): tname = "tenant-{}".format("trial") email = "user@{}.com".format(tname) tadmm = ApiClient( host=get_container_manager().get_mender_gateway(), base_url=tenantadm_v2.URL_MGMT, ) args = { "organization": tname, "email": email, "password": "******", "name": "foo", "g-recaptcha-response": "dummy", "plan": "enterprise", } res = tadmm.call( "POST", tenantadm_v2.URL_CREATE_ORG_TRIAL, body=args, ) assert res.status_code == 202 # get tenant id tadmi = ApiClient( host=get_container_manager().get_ip_of_service("mender-tenantadm") [0] + ":8080", base_url=tenantadm.URL_INTERNAL, schema="http://", ) res = tadmi.call("GET", tenantadm.URL_INTERNAL_TENANTS, qs_params={"username": email}) assert res.status_code == 200 assert len(res.json()) == 1 apitenant = res.json()[0] cli = CliTenantadm(containers_namespace=env.name) tenant = cli.get_tenant(apitenant["id"]) tenant = json.loads(tenant) ttoken = tenant["tenant_token"] auth = Authentication(name=tname, username=email, password="******") auth.create_org = False auth.reset_auth_token() devauth = DeviceAuthV2(auth) env.new_tenant_client("test-container-trial", ttoken) device = MenderDevice(env.get_mender_clients()[0]) devauth.accept_devices(1) devices = list( set([ device["id"] for device in devauth.get_devices_status("accepted") ])) assert 1 == len(devices) tenant = Tenant(tname, apitenant["id"], ttoken) u = User("", email, "correcthorse") tenant.users.append(u) tenant.device = device tenant.device_id = devices[0] tenant.auth = auth tenant.devauth = devauth return tenant