mirror of
https://github.com/goharbor/harbor.git
synced 2024-10-31 23:59:32 +01:00
0e752d8cf8
1. Move LDAP API test out of robot script, LDAP API test will be triggered in Jenkins job independently; 2. Docker api returned from function before analyze the return message for expected error. Signed-off-by: danfengliu <danfengl@vmware.com>
65 lines
1.8 KiB
Python
65 lines
1.8 KiB
Python
# coding: utf-8
|
|
|
|
"""
|
|
Harbor API
|
|
|
|
These APIs provide services for manipulating Harbor project.
|
|
|
|
OpenAPI spec version: 1.4.0
|
|
|
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
|
"""
|
|
|
|
|
|
from __future__ import absolute_import
|
|
|
|
import os
|
|
import sys
|
|
sys.path.append(os.environ["SWAGGER_CLIENT_PATH"])
|
|
|
|
import unittest
|
|
import testutils
|
|
import swagger_client
|
|
from swagger_client.models.project_req import ProjectReq
|
|
from swagger_client.models.access_log import AccessLog
|
|
from swagger_client.models.configurations import Configurations
|
|
from swagger_client.rest import ApiException
|
|
from swagger_client.models.configurations import Configurations
|
|
from pprint import pprint
|
|
|
|
|
|
#Testcase
|
|
# Define a LDAP group with harbor admin
|
|
class TestLdapAdminRole(unittest.TestCase):
|
|
"""AccessLog unit test stubs"""
|
|
product_api = testutils.GetProductApi("admin", "Harbor12345")
|
|
mike_product_api = testutils.GetProductApi("mike", "zhu88jie")
|
|
project_id = 0
|
|
def setUp(self):
|
|
pass
|
|
|
|
def tearDown(self):
|
|
if self.project_id > 0 :
|
|
self.mike_product_api.projects_project_id_delete(project_id=self.project_id)
|
|
pass
|
|
|
|
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")
|
|
print(projects)
|
|
self.assertTrue(len(projects) == 1)
|
|
self.project_id = projects[0].project_id
|
|
pass
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|