Пример #1
0
    def testLdapAdminRole(self):
        """Test LdapAdminRole"""
        _project_name = _random_name("test_private")
        result = self.product_api.configurations_put(
            configurations=Configurations(
                ldap_group_admin_dn=
                "cn=harbor_users,ou=groups,dc=example,dc=com"))

        # Create a private project
        result = self.product_api.projects_post(project=ProjectReq(
            project_name=_project_name))

        # query project with ldap user mike
        projects = self.mike_product_api.projects_get(name=_project_name)

        print("=================", projects)
        self.assertTrue(len(projects) == 1)
        self.project_id = projects[0].project_id

        # check the mike is not admin in Database
        user_list = self.product_api.users_get(username="******")
        pprint(user_list[0])
        self.assertFalse(user_list[0].sysadmin_flag)

        pass
    def setUp(self):
        self.projectv2 = ProjectV2()

        #login with admin, create a project and assign role to ldap group
        result = self.product_api.configurations_put(
            configurations=Configurations(
                ldap_filter="",
                ldap_group_attribute_name="cn",
                ldap_group_base_dn="ou=groups,dc=example,dc=com",
                ldap_group_search_filter="objectclass=groupOfNames",
                ldap_group_search_scope=2))
        pprint(result)
        cfgs = self.product_api.configurations_get()
        pprint(cfgs)
        req = ProjectReq()
        req.project_name = self._project_name
        req.metadata = ProjectMetadata(public="false")
        result = self.product_api.projects_post(req)
        pprint(result)

        projs = self.product_api.projects_get(name=self._project_name)
        if len(projs) > 0:
            project = projs[0]
            self.project_id = project.project_id

        # asign role to project with dn
        group_dn = "cn=harbor_admin,ou=groups,dc=example,dc=com"
        projectmember = ProjectMember()
        projectmember.role_id = 1
        projectmember.member_group = UserGroup(ldap_group_dn=group_dn)

        result = self.product_api.projects_project_id_members_post(
            project_id=self.project_id, project_member=projectmember)
        pprint(result)

        group_dn = "cn=harbor_dev,ou=groups,dc=example,dc=com"
        projectmember = ProjectMember()
        projectmember.role_id = 2
        projectmember.member_group = UserGroup(ldap_group_dn=group_dn)

        result = self.product_api.projects_project_id_members_post(
            project_id=self.project_id, project_member=projectmember)
        pprint(result)

        group_dn = "cn=harbor_guest,ou=groups,dc=example,dc=com"
        projectmember = ProjectMember()
        projectmember.role_id = 3
        projectmember.member_group = UserGroup(ldap_group_dn=group_dn)

        result = self.product_api.projects_project_id_members_post(
            project_id=self.project_id, project_member=projectmember)
        pprint(result)
        pass
Пример #3
0
    def testLdapAdminRole(self):
        """Test LdapAdminRole"""
        result = self.product_api.configurations_put(
            configurations=Configurations(
                ldap_group_admin_dn=
                "cn=harbor_users,ou=groups,dc=example,dc=com"))
        pprint(result)

        # Create a private project
        result = self.product_api.projects_post(project=ProjectReq(
            project_name="test_private"))
        pprint(result)

        # query project with ldap user mike
        projects = self.mike_product_api.projects_get(name="test_private")
        self.assertTrue(projects.count > 1)
        self.project_id = projects[0].project_id
        pass
Пример #4
0
 def setUp(self):
     result = self.product_api.configurations_put(configurations=Configurations(ldap_group_attribute_name="cn", ldap_group_base_dn="ou=groups,dc=example,dc=com", ldap_group_search_filter="objectclass=groupOfNames", ldap_group_search_scope=2))
     pprint(result)
     pass