|
| 1 | +import os |
| 2 | +from random import choice |
| 3 | +from string import ascii_letters |
| 4 | + |
| 5 | +from expects import expect, contain |
| 6 | +from mamba import before, description, after, it, context |
| 7 | + |
| 8 | +from sdcclient import SdcClient |
| 9 | +from specs import be_successful_api_call |
| 10 | + |
| 11 | +with description("User Provisioning", "integration") as self: |
| 12 | + with before.each: |
| 13 | + self.client = SdcClient(sdc_url=os.getenv("SDC_MONITOR_URL", "https://app.sysdigcloud.com"), |
| 14 | + token=os.getenv("SDC_MONITOR_TOKEN")) |
| 15 | + self. user_name = "[email protected]" |
| 16 | + |
| 17 | + with after.each: |
| 18 | + self.client.delete_user(self.user_name) |
| 19 | + |
| 20 | + with it("is able to provision the user with only the username"): |
| 21 | + ok, res = self.client.create_user(self.user_name) |
| 22 | + expect((ok, res)).to(be_successful_api_call) |
| 23 | + |
| 24 | + with it("is able to provision the user with name and lastname"): |
| 25 | + ok, res = self.client.create_user(self.user_name, "Name", "LastName") |
| 26 | + expect((ok, res)).to(be_successful_api_call) |
| 27 | + |
| 28 | + with it("is able to provision the user with password"): |
| 29 | + random_password = "".join(choice(ascii_letters) for _ in range(20)) |
| 30 | + ok, res = self.client.create_user(self.user_name, password=random_password) |
| 31 | + expect((ok, res)).to(be_successful_api_call) |
| 32 | + |
| 33 | + with it("is able to provision the user with name, lastname and password"): |
| 34 | + random_password = "".join(choice(ascii_letters) for _ in range(20)) |
| 35 | + ok, res = self.client.create_user(self.user_name, "Name", "LastName", random_password) |
| 36 | + expect((ok, res)).to(be_successful_api_call) |
| 37 | + |
| 38 | + with context("when the customer already exists"): |
| 39 | + with it("returns an error saying it already exists"): |
| 40 | + ok, res = self.client.create_user(self.user_name) |
| 41 | + expect((ok, res)).to(be_successful_api_call) |
| 42 | + |
| 43 | + ok, res = self.client.create_user(self.user_name) |
| 44 | + expect((ok, res)).not_to(be_successful_api_call) |
| 45 | + expect(res).to(contain(f"User {self.user_name} already exists")) |
0 commit comments