コード例 #1
0
    def test_success(self, clean_mongo_tenant_migration):
        """
        Create a single organization and verify that the created user
        is able to log in.
        """
        tenantadm_cli = cli.CliTenantadm()
        self.logger.info("Starting `test_success`")

        tenant_id = tenantadm_cli.create_org(name="fooCorp",
                                             username="******",
                                             password="******")
        self.logger.debug("Tenant id: %s" % tenant_id)

        # Retry login every second for 3 min
        for i in range(60 * 3):
            rsp = self.api_mgmt_useradm.call("POST",
                                             api.useradm.URL_LOGIN,
                                             auth=("*****@*****.**",
                                                   "password"))
            if rsp.status_code == 200:
                break
            time.sleep(1)

        assert rsp.status_code == 200

        self.logger.info("`test_success` finished successfully.")
コード例 #2
0
    def test_success(self, clean_mongo_tenant_migration):
        """
        Create a single organization and verify that the created user
        is able to log in.
        """
        tenantadm_cli = cli.CliTenantadm()
        self.logger.info("Starting `test_success`")

        uuidv4 = str(uuid.uuid4())
        name, username, password = (
            "test.mender.io-" + uuidv4,
            "some.user+" + uuidv4 + "@example.com",
            "secretsecret",
        )
        tenant_id = tenantadm_cli.create_org(name=name,
                                             username=username,
                                             password=password)
        self.logger.debug("Tenant id: %s" % tenant_id)

        # Retry login every second for 3 min
        for i in range(60 * 3):
            rsp = self.api_mgmt_useradm.call("POST",
                                             api.useradm.URL_LOGIN,
                                             auth=(username, password))
            if rsp.status_code == 200:
                break
            time.sleep(1)

        assert rsp.status_code == 200

        self.logger.info("`test_success` finished successfully.")
コード例 #3
0
    def test_duplicate_organization(self, clean_mongo_tenant_migration):
        """
        It should be allowed to create duplicate organizations as long
        as the user e-mails (login credentials) differ.
        """
        self.logger.debug("Starting `test_duplicate_username`")
        tenantadm_cli = cli.CliTenantadm()

        uuidv4 = str(uuid.uuid4())
        name, username, password = (
            "test.mender.io-" + uuidv4,
            "some.user+" + uuidv4 + "@example.com",
            "secretsecret",
        )
        tenant_id = tenantadm_cli.create_org(name=name,
                                             username=username,
                                             password=password)
        self.logger.debug("Tenant id: %s" % tenant_id)

        # Retry login every second for 3 min
        for i in range(60 * 3):
            rsp = self.api_mgmt_useradm.call("POST",
                                             api.useradm.URL_LOGIN,
                                             auth=(username, password))
            if rsp.status_code == 200:
                self.logger.debug("Successfully logged into account")
                break
            time.sleep(1)

        assert rsp.status_code == 200

        name, username, password = (
            "test.mender.io-" + uuidv4,
            "some.other.user+" + uuidv4 + "@example.com",
            "secretsecret",
        )
        tenant_id = tenantadm_cli.create_org(name=name,
                                             username=username,
                                             password=password)
        self.logger.debug("Tenant id: %s" % tenant_id)

        # Retry login every second for 3 min
        for i in range(60 * 3):
            rsp = self.api_mgmt_useradm.call("POST",
                                             api.useradm.URL_LOGIN,
                                             auth=(username, password))
            if rsp.status_code == 200:
                break
            time.sleep(1)
        assert rsp.status_code == 200

        self.logger.info("`test_duplicate_username` finished successfully.")
コード例 #4
0
    def test_duplicate_organization(self, clean_mongo_tenant_migration):
        """
        It should be allowed to create duplicate organizations as long
        as the user e-mails (login credentials) differ.
        """
        self.logger.debug("Starting `test_duplicate_username`")
        tenantadm_cli = cli.CliTenantadm()

        tenant_id = tenantadm_cli.create_org(name="fooCorp",
                                             username="******",
                                             password="******")
        self.logger.debug("Tenant id: %s" % tenant_id)

        # Retry login every second for 3 min
        for i in range(60 * 3):
            rsp = self.api_mgmt_useradm.call("POST",
                                             api.useradm.URL_LOGIN,
                                             auth=("*****@*****.**",
                                                   "321password"))
            if rsp.status_code == 200:
                self.logger.debug("Successfully logged into account")
                break
            time.sleep(1)

        assert rsp.status_code == 200

        tenant_id = tenantadm_cli.create_org(name="fooCorp",
                                             username="******",
                                             password="******")
        self.logger.debug("Tenant id: %s" % tenant_id)

        # Retry login every second for 3 min
        for i in range(60 * 3):
            rsp = self.api_mgmt_useradm.call("POST",
                                             api.useradm.URL_LOGIN,
                                             auth=("*****@*****.**",
                                                   "password123"))
            if rsp.status_code == 200:
                break
            time.sleep(1)
        assert rsp.status_code == 200

        self.logger.info("`test_duplicate_username` finished successfully.")
コード例 #5
0
    def test_duplicate_username(self, clean_mongo_tenant_migration):
        """
        Duplicate username (e-mail) should not be allowed, as this
        leads to conflicting login credentials.
        """
        tenantadm_cli = cli.CliTenantadm()
        self.logger.debug("Starting `test_duplicate_username`")

        self.logger.debug("First tenant creation call")
        uuidv4 = str(uuid.uuid4())
        name, username, password = (
            "test.mender.io-" + uuidv4,
            "some.user+" + uuidv4 + "@example.com",
            "secretsecret",
        )
        tenant_id = tenantadm_cli.create_org(name=name,
                                             username=username,
                                             password=password)
        self.logger.debug("Tenant id: %s" % tenant_id)

        # Retry login every second for 3 min
        for i in range(60 * 3):
            rsp = self.api_mgmt_useradm.call("POST",
                                             api.useradm.URL_LOGIN,
                                             auth=(username, password))
            if rsp.status_code == 200:
                self.logger.debug("Successfully logged into account")
                break
            time.sleep(1)
        assert rsp.status_code == 200

        try:
            self.logger.debug("Second tenant creation call")
            tenant_id = tenantadm_cli.create_org(name=name,
                                                 username=username,
                                                 password="******")
            pytest.fail("Multiple users with the same username is not allowed")
        except subprocess.CalledProcessError:
            pass

        self.logger.info("`test_duplicate_username` finished successfully.")
コード例 #6
0
def clean_mongo_tenant_migration(mongo):
    mongo_cleanup(mongo)
    tenant_cli = cli.CliTenantadm()
    tenant_cli.migrate()
    yield mongo
    mongo_cleanup(mongo)