Commit Graph

262 Commits

Author SHA1 Message Date
danfengliu
c283a02e5f Update existing API tests for API V2.0
Signed-off-by: danfengliu <danfengl@vmware.com>
2020-02-26 21:38:39 +08:00
danfengliu
4933bb634f Upgrade repository API tests to V2.0
Enable _xsrf in cookies in swagger.yaml, so that scripts don't have to handle it.

Signed-off-by: danfengliu <danfengl@vmware.com>
2020-02-24 18:15:25 +08:00
He Weiwei
88fcacd4b7
feat(middleware): add blob middlewares (#10710)
1. Add middleware to record the accepted blob size for stream blob
upload.
2. Add middleware to create blob and associate it with project after blob upload
complete.
3. Add middleware to sync blobs, create blob for manifest and associate blobs
with the manifest after put manifest.
4. Add middleware to associate blob with project after mount blob.
5. Cleanup associations for the project when artifact deleted.

Signed-off-by: He Weiwei <hweiwei@vmware.com>
2020-02-20 23:20:34 +08:00
Ziming
0bc32410f3
Merge pull request #10742 from bitsf/oci_tag_retention
requirement(oci) implement tag retention for oci
not include ChartClient yet
2020-02-20 20:31:49 +08:00
danfengliu
03668ad372 Build python swagger client for V2.0
Add v2 swagger.yaml python library.

Signed-off-by: danfengliu <danfengl@vmware.com>
2020-02-20 18:06:54 +08:00
Ziming Zhang
94e23dc954 requirement(oci) implement tag retention for oci
Change-Id: Ib36660835d2666b35124e66254c33b5fc19aaf77
Signed-off-by: Ziming Zhang <zziming@vmware.com>
2020-02-20 00:43:20 +08:00
Wenkai Yin
94787ea60d Bump up the version of legacy APIs to v2.0
Bump up the version of legacy APIs to v2.0

Signed-off-by: Wenkai Yin <yinw@vmware.com>
2020-02-14 13:16:30 +08:00
danfengliu
d1b5bd5d9c Fix project quotas API test issue
In project quotas API test, pull images from goharbor namespace instead of library:
1. Replace image source in API test;
2. Modify criteria for verify project configuration modification.

Signed-off-by: danfengliu <danfengl@vmware.com>
2020-02-06 16:43:08 +08:00
danfengliu
66eff99c7f Fix description issue of test in robot account API test and issue of Helm3 test
1. Fix issue that test step descriton was mismatch with test step;
2. Wrong helm command was used in Helm3 test, replace helm with helm3;
3. In API test, images were pulled from docker-hub registry, images size changed sometime, so we like to use internal registry.

Signed-off-by: danfengliu <danfengl@vmware.com>
2020-02-04 17:26:52 +08:00
Daniel Jiang
2064a1cd6d Switch to basic authentication for registry
1. Add basic authorizer for registry which modify the request
to add basic authorization header to request based on configuration.
2. Set basic auth header for proxy when accessing registry
3. Switche the registry to use basic auth by default and use the basic
authorizer to access Harbor.
4. Make necessary change to test cases, particularly
"test_robot_account.py" and "docker_api.py", because the error is
changed after siwtched to basic auth from token auth.  #10604 is opened
to track the follow up work.

Signed-off-by: Daniel Jiang <jiangd@vmware.com>
2020-01-31 21:46:47 +09:00
Daniel Jiang
5f8acc3896 Add middlewares for permission checking for v2 API
When the registry shifts from token auth to basic auth, we'll use the middleware to check permission.
This commit add middlewares for populate the artifact info and check
permission based on request to /v2/* api via security context

Signed-off-by: Daniel Jiang <jiangd@vmware.com>
2020-01-27 12:53:15 +08:00
Ziming Zhang
9f1d538b5f feat(cicd): try fix sometimes docker push time out
Signed-off-by: Ziming Zhang <zziming@vmware.com>
Change-Id: I67193a7c5b80d169237a884895627f68a1f65933
2020-01-20 11:57:03 +08:00
Ziming Zhang
45113ea8e1 feat(cicd) use a smaller docker image for test
Change-Id: Ie8f365e7271bfda24ae965aaca0e55d1099c1d68
Signed-off-by: Ziming Zhang <zziming@vmware.com>
2020-01-17 13:09:31 +08:00
wang yan
a0f3709b3c add expiration data time when to create a robot account
Update API of creating robot accout, user can specify expiration time per account.

Signed-off-by: wang yan <wangyan@vmware.com>
2020-01-03 13:47:06 +08:00
stonezdj
6313a55219 Fix admin permission not revoked when removed from LDAP admin group
Seperate the HasAdminRole(In DB) with the privileges from external auth, and use user.HasAdminPrivilege to check

Signed-off-by: stonezdj <stonezdj@gmail.com>
2019-12-20 13:12:22 +08:00
Steven Zou
4b335b79d5
Merge pull request #9693 from steven-zou/fix/issue_#9606_update_API_swagger
update API swagger file
2019-11-06 11:06:02 +08:00
Steven Zou
0ebeaa10df update API swagger file
- add scanners mgmt related API
- add scan related API
  - trigger scan
  - get report
  - get log text stream
  - get scan all metrics
- update the scan_overview in the tag getting API
- fix #9606

Signed-off-by: Steven Zou <szou@vmware.com>
2019-11-05 22:20:14 +08:00
Wenkai Yin
e20b538141 Add e2e test case for health check API
Add e2e test case for health check API

Signed-off-by: Wenkai Yin <yinw@vmware.com>
2019-10-29 13:48:06 +08:00
wang yan
3e826c4e80 update query in the immutable delete manifest middleware
Signed-off-by: wang yan <wangyan@vmware.com>
2019-10-22 19:37:20 +08:00
He Weiwei
8964a8697a build(clair): internal clair adapter when install with clair
Signed-off-by: He Weiwei <hweiwei@vmware.com>
2019-10-17 12:00:51 +08:00
He Weiwei
4ce72e37c4 fix(robot): robot account improvement for policies
Signed-off-by: He Weiwei <hweiwei@vmware.com>
2019-09-27 03:07:58 +00:00
Ziming Zhang
afe81a8b3b adjust wait job timeout
Change-Id: I8f32f814158d4a7418c39edb7a781879db17a4d7
Signed-off-by: Ziming Zhang <zziming@vmware.com>
2019-09-20 16:18:03 +08:00
Wang Yan
6b5fd36bb3 add e2e test case for project quota
1. Create a new user(UA);
2. Create a new private project(PA) by user(UA);
3. Add user(UA) as a member of project(PA) with project-admin role;
4. Push an image to project(PA) by user(UA), then check the project quota usage;
5. Check quota change
6. Delete image, the quota should be changed to 0.

Signed-off-by: wang yan <wangyan@vmware.com>
2019-09-15 22:16:11 +08:00
Ziming Zhang
722e45b20b add swagger for tag retention
Signed-off-by: Ziming Zhang <zziming@vmware.com>
Change-Id: I0f3ed8085e231868de74c273ba85946826181d5b
2019-09-06 17:27:20 +08:00
danfengliu
841ac24ebc
Add API test case sign image back to travis, despite codacy block it when pulling a pr. (#8617)
Signed-off-by: wang yan <wangyan@vmware.com>
2019-08-19 13:35:45 +08:00
danfengliu
2aa6f1aed7
Merge branch 'master' into add-sign-api-back-to-travis-despite-codacy-1 2019-08-16 16:28:49 +08:00
wang yan
ddb913f8d0 Add API test case sign image back to travis, despite codacy block it when pulling a pr.
Signed-off-by: wang yan <wangyan@vmware.com>
2019-08-16 01:26:36 -07:00
Daniel Jiang
e4a78ba039 API test for project level CVE whitelist
This commit update test case to cover project level CVE whitelist.
It also fixes the swagger doc to add missing attributes

Signed-off-by: Daniel Jiang <jiangd@vmware.com>
2019-08-15 11:37:22 +08:00
Daniel Jiang
d01597ba23 API test for system level CVE whitelist
Signed-off-by: Daniel Jiang <jiangd@vmware.com>
2019-08-14 14:59:58 +08:00
danfengliu
1b0931c034 Since harbor 1.8 released, API test for replication was not update yet, so in this PR, replicaiton test will be adapt for harbor 1.8.
Signed-off-by: danfengliu <danfengl@vmware.com>
2019-08-08 17:06:37 +08:00
danfengliu
3eeb8cf355 After helm cli test was added to nightly, ca was get by reading from local file, but in helm nighly test, ca file was not in local, it has to be got from harbor api.
Signed-off-by: danfengliu <danfengl@vmware.com>
2019-08-06 11:28:54 +08:00
Daniel Jiang
737eaa396c Bump up to go 1.12.5 enable go.mod
This commit bumps up the version of Go to compile the code to v1.12.5,
and shifts to go.mod for managing depedency.
Some code from "harbor/tests" to "harbor/src/testing" to avoid depedency
loop of modules.

Note that in short term we will still vendor the dependency.

Signed-off-by: Daniel Jiang <jiangd@vmware.com>
2019-06-11 00:42:20 +08:00
danfengliu
9019864446
In API test, there is a dead loop in checking GC status, it's fixed in this PR and add log inmformation in the loop. (#7643)
Signed-off-by: danfengliu <danfengl@vmware.com>
2019-05-06 17:24:33 +08:00
danfengliu
e08c2e757e This API test script was blocked by a swagger error, now this error was fixed, so robot account script can be finished now. In swagger.yaml, robot account can be updated in "disbled" status, it's added into script. (#7636)
Signed-off-by: danfengliu <danfengl@vmware.com>
2019-05-06 11:34:11 +08:00
stonezdj
41a574e55c Fix issue 6450 Test LDAP server error without save configuration
Signed-off-by: stonezdj <stonezdj@gmail.com>
2019-04-18 14:24:21 +08:00
Wang Yan
a6af9e9972
Support well-formatted error returned from the REST APIs. (#6957)
Signed-off-by: wang yan <wangyan@vmware.com>
2019-04-17 16:43:06 +08:00
danfengliu
08b346ee1e
Add API test case for retag, create a user and 2 projects by this new user, push image to 1st project, and retag this image to 2nd project. (#7300)
Signed-off-by: danfengliu <danfengl@vmware.com>
2019-04-11 15:05:46 +08:00
Yan
8d3946a0e2
Refactor scan all api (#7120)
* Refactor scan all api

This commit is to let scan all api using admin job to handle schedule
management. After the PR, GC and scan all share unified code path.

Signed-off-by: wang yan <wangyan@vmware.com>

* update admin job api code according to review comments

Signed-off-by: wang yan <wangyan@vmware.com>

* Update test code and comments per review

Signed-off-by: wang yan <wangyan@vmware.com>
2019-03-22 17:52:21 +08:00
De Chen
41e290a17f
Merge pull request #6877 from yeya24/patch/fixtypo
fix some typos
2019-03-12 20:07:15 +08:00
He Weiwei
20556aebd2 Add users search API
Signed-off-by: He Weiwei <hweiwei@vmware.com>
2019-03-07 12:47:26 +08:00
danfengliu
eaedd89c25 add api test case for robot user, and modify swagger.yaml for wrong type of return value. (#6900)
Signed-off-by: danfengliu <danfengl@vmware.com>
2019-02-18 13:47:16 +08:00
wang yan
c77b387c53 Upgrade registry binary to v2.7.0
Signed-off-by: wang yan <wangyan@vmware.com>
2019-02-13 10:24:08 +08:00
yeya24
628b94db19 fix some typos
Signed-off-by: yeya24 <ben.ye@daocloud.io>
2019-02-05 12:03:52 +08:00
He Weiwei
8b5e68073d Implement api for get current user permissions
Signed-off-by: He Weiwei <hweiwei@vmware.com>
2019-01-28 18:06:52 +08:00
danfengliu
70016cc0eb
Change a small docker image to pull and make timeout value longer (#6543)
Signed-off-by: danfengliu <danfengl@vmware.com>
2018-12-18 10:21:03 +08:00
danfengliu
7c57864c99 Remove 2 redundant functions, pull_harbor_image_successfully and pull_harbor_image_unsuccessfully.
Signed-off-by: danfengliu <danfengl@vmware.com>
2018-12-04 13:46:07 +08:00
danfengliu
3356368bff Add API test case assign system admin role. (#6413)
Signed-off-by: danfengliu <danfengl@vmware.com>
2018-12-04 12:26:12 +08:00
danfengliu
b4c7663f5f
Add API test case scan all images and test case API test case list helm charts. (#6388)
Signed-off-by: danfengliu <danfengl@vmware.com>
2018-12-03 17:05:06 +08:00
Wenkai Yin
9d5cf57373 Check the existence of name when creating replication rule and fix bugs in testing library (#6381)
1. Fix #5102 by checking the existence of name when creating/editing replication rule
2. Add unique constraint to the name of replication policy and target
3. Fix bugs of testing library

Signed-off-by: Wenkai Yin <yinw@vmware.com>
2018-11-30 13:32:20 +08:00
danfengliu
04fd4d444d
Add API test case for user view logs. (#6370)
Add API test case for user view logs.
Signed-off-by: danfengliu <danfengl@vmware.com>
2018-11-29 18:27:53 +08:00
danfengliu
c4bf65162c
add api test case for garbage collection (#6366)
Add API test case for garbage collection, and add swagger.yaml, GC and chart feature were updated in swagger.yaml.
Signed-off-by: danfengliu <danfengl@vmware.com>
2018-11-27 19:17:41 +08:00
danfengliu
ad77098acf
add test case project level policy content trust. (#6309)
Add test case project level policy content trust.
Signed-off-by: danfengliu <danfengl@vmware.com>
2018-11-21 12:19:28 +08:00
danfengliu
5ceebcbb10
Add tese case of manage project memebers and modify (#6304)
Move admin_client to testutil.py as global parameter.
Change create_repository function name to push_image_to_project to make it reasonable.
Signed-off-by: danfengliu <danfengl@vmware.com>
2018-11-20 14:24:13 +08:00
danfengliu
dcd34a37a9 add test case scan a not scanned image
Modify for codacy issues.
Signed-off-by: danfengliu <danfengl@vmware.com>
2018-11-16 15:35:15 +08:00
danfengliu
1cc04183cb add test case for edit project creation;
fixed some space and import issues coddcy;
remove a lib;

Signed-off-by: danfengliu <danfengl@vmware.com>
2018-11-15 10:32:21 +08:00
danfengliu
90fda71e4a Recovery repository.py for calling wrong create function (#6268)
Signed-off-by: danfengliu <danfengl@vmware.com>
2018-11-13 12:53:46 +08:00
danfengliu
6289275118 Modify script call create project (#6263)
Signed-off-by: danfengliu <danfengl@vmware.com>
2018-11-12 23:39:16 +08:00
danfengliu
205a658afb Only modify lib-project for seq of return (#6261)
Signed-off-by: danfengliu <danfengl@vmware.com>
2018-11-12 16:59:55 +08:00
danfengliu
ce8a585858 modfiy repo
Signed-off-by: danfengliu <danfengl@vmware.com>
2018-11-08 10:33:14 +08:00
danfengliu
9265754936 modify codacy errors in target
Signed-off-by: danfengliu <danfengl@vmware.com>
2018-11-08 10:33:14 +08:00
danfengliu
a6151175e3 add lib for target
Signed-off-by: danfengliu <danfengl@vmware.com>
2018-11-08 10:33:14 +08:00
danfengliu
e6f5f62c53 Modify for codacy again
Signed-off-by: danfengliu <danfengl@vmware.com>
2018-11-08 10:33:14 +08:00
danfengliu
0b84ec84d9 Modify for codacy
Signed-off-by: danfengliu <danfengl@vmware.com>
2018-11-08 10:33:14 +08:00
danfengliu
660bfdf677 add test case of add a replication rule
Signed-off-by: danfengliu <danfengl@vmware.com>
2018-11-08 10:33:14 +08:00
danfengliu
1979d17550 add tc add-sys-label-to-tag and del-repo
Signed-off-by: danfengliu <danfengl@vmware.com>
2018-11-02 17:16:43 +08:00
danfengliu
894e0591bb add new api tests (#6127)
Add API test libraries which were based on swagger doc,
it's including user and project , also add one scenario
test case which is test_add_member_to_private_project to
verify a user can see a project when the uesr is the member of it.
Delete 2 old test case.Delete a quota.

Signed-off-by: danfengliu <danfengl@vmware.com>
2018-10-31 13:13:31 +08:00
陈德
a1b4729aa7 Add more unit tests
Signed-off-by: 陈德 <chende@caicloud.io>
2018-10-18 00:26:25 +08:00
Yan
002e5a2b70
Enable api tests in travis (#5900)
This commit is to enable parallel run jobs with travis, and add API for DB and API for LDAP in travis.

Signed-off-by: wang yan <wangyan@vmware.com>
2018-09-19 17:49:43 +08:00
Qian Deng
7873a0312a Rename harbor-ui to harbor-core
1. Update the nginx.conf
2. Update Makefile
3. Update docker-compose
4. Update image name
5. Rename folder ui to core
6. Change the harbor-ui's package name to core
7. Remove unused static file on harbor-core
8. Remove unused code for harbor-portal

Signed-off-by: Qian Deng <dengq@vmware.com>
2018-09-19 16:35:13 +08:00
Daniel Jiang
dcf4e2ee78 Update import path in go code
vmware -> goharbor

Signed-off-by: Daniel Jiang <jiangd@vmware.com>
2018-08-23 17:50:53 +08:00
Wenkai Yin
f71f02deee Fix module not found error in API test (#5647)
Reload the python path to fix the module not found error in API E2E test

Signed-off-by: Wenkai Yin <yinw@vmware.com>
2018-08-17 10:55:19 +08:00
Wenkai Yin
95c0c259ec Add E2E API test cases for replication based on labels (#5639)
This commit creates a new E2E API test case to verify the replication based on label

Signed-off-by: Wenkai Yin <yinw@vmware.com>
2018-08-16 18:36:27 +08:00
stonezdj
94f852b826 Fix testcase related to LDAP user can not see any logs 2018-08-10 16:17:18 +08:00
Yan
9c86d0b86f
Update ldap user pwd for nightly (#5571) 2018-08-09 16:38:27 +08:00
stonezdj
edcb2fbf05 Add Harbor API Test based on python API
Correct swagger.yaml format
Add make task swagger_client to gen and install python client.
Add LDAP related Test
2018-08-01 10:43:23 +08:00
Yan
efdb57548f
add admin job api (#5344)
It supports Harbor admin to trigger job either manual or
schedule. The job will be populated to job service to execute. 
The api includes:
1. POST /api/system/gc
2, GET /api/system/gc/:id 
3, GET /api/system/gc/:id/log
4, PUT/GET/POST /api/system/gc/schedule
2018-07-20 19:22:37 +08:00
Yan
ae257433cc
Fully migrate harbor db to postgresql (#4689)
* Merge harbor db to postgres
2018-04-27 02:27:12 -07:00
Steven Zou
bb292aab96 Fix the failure api test cases because API implementation changed 2018-04-16 15:39:19 +08:00
Wenkai Yin
a54b7dd4c0 Merge remote-tracking branch 'upstream/master' into 171219_merge 2017-12-15 08:48:57 +08:00
Steven Zou
bdb26139d7 change the hostname placeholder for the ldap concourse environment to 30.0.0.3 2017-12-17 15:15:05 +08:00
Steven Zou
d7f99d5604 add api testing suite for ldap scenario: no user creation and user deleting cases comparing to the general scenario 2017-12-15 18:56:20 +08:00
Steven Zou
42fb5c9f8e add proxy settings to the API client for the api-testing part 2017-12-15 13:19:03 +08:00
Wenkai Yin
665a54edc3 Merge remote-tracking branch 'upstream/master' into 171213_merge 2017-12-13 13:40:24 +08:00
Steven Zou
61eefbaf6c add api testing for harbor including image pull and push 2017-12-08 16:16:50 +08:00
Wenkai Yin
31cf6c078e Implement replication policy manager 2017-11-16 10:55:03 +08:00
Wenkai Yin
5cef58baa1 update according to the comments 2017-11-08 17:53:41 +08:00
Wenkai Yin
51d5df0849 Update replication policy API to support trigger and filter 2017-11-02 14:59:26 +08:00
Wenkai Yin
66b2d0d3f3 Apply project level policies to standalone Harbor
The following features are only enabled in integration mode, this commit moves
these to standalone Harbor:
 - Content trust policy: only signed images can be pulled
 - Vulnerability policy: only images whose severity is below the threshold can be pulled
 - Automatic scan policy: automatic scan pushed images
2017-10-19 17:33:28 +08:00
Wenkai Yin
6e9ec3f22c refactor statistics API 2017-06-26 14:15:01 +08:00
Wenkai Yin
6b4ae098db update 2017-06-09 18:24:52 +08:00
Wenkai Yin
20cf8de0f7 Merge remote-tracking branch 'upstream/master' into 170608_project 2017-06-09 16:41:13 +08:00
Wenkai Yin
e97d7dab85 refactor GET /projects 2017-06-09 16:41:02 +08:00
Wenkai Yin
b2380818fd support query logs according to conditions 2017-06-08 14:44:08 +08:00
Wenkai Yin
d6a6f67596 refactor search API to return more info 2017-03-06 17:47:05 +08:00
wemeya
7f949b1a95 add test for ldap.go (#1307)
LGTM
2017-01-19 10:09:56 +08:00
wemeya
ce0a44010d add test file for systeminfo.go (#1288)
LGTM
2017-01-06 15:41:07 +08:00
wemeya
c0f3d7d749 add test case for user 2016-09-22 16:28:12 +08:00
zgdxiaoxiao
bfb5db7c97 swagger bugfix 2016-09-21 10:43:04 +08:00
zgdxiaoxiao
198149599d update api test and swagger.yaml(updated) 2016-09-02 16:05:55 +08:00
zgdxiaoxiao
02d5281f0c project api test and bugfix
1.add project api test
2.bugfix:the type of public in project.go is fixed to int32
2016-08-30 18:26:41 +08:00
yhua
60cae7357f add new structs from swagger auto gen code 2016-08-15 14:36:42 +08:00
yhua
74702a0be7 add api testing framework 2016-08-10 14:34:56 +08:00
yhua123
c6f1d1f0b0 Update hbapisearch_test.go
go vet ./...
tests/apitests/hbapisearch_test.go:11: Println call ends with newline
2016-06-20 14:39:22 +08:00
yhua123
3157559c4e Update hbapidelrpo_test.go
fix go vet ./...
tests/apitests/hbapidelrpo_test.go:12: Println call ends with newline
tests/apitests/hbapidelrpo_test.go:20: Println call ends with newline
tests/apitests/hbapidelrpo_test.go:35: Println call ends with newline
tests/apitests/hbapidelrpo_test.go:42: Println call ends with newline
2016-06-20 14:38:55 +08:00
yhua123
5c500cf4a1 Update hbapiaddprj_test.go
fix go vet ./...
tests/apitests/hbapiaddprj_test.go:12: Println call ends with newline
2016-06-20 14:36:47 +08:00
yhua123
f1b5ee1522 Create hbapidelrpo_test.go
add new test case for delete repo API
2016-06-15 11:20:34 +08:00
Wenkai Yin
6c543e6cac Merge pull request #334 from yhua123/patch-1
Update harborapi.go
2016-06-14 17:38:47 +08:00
yhua123
21bd0ba9fa Update hbapiaddprj_test.go
fix one issue, project name should be lower case.
2016-06-14 14:31:35 +08:00
yhua123
97c78c635c Update harborapi.go
1 add one new API test interface: delete repository
2 fix one sling usage issue
2016-06-14 13:47:11 +08:00
yhua
bd8f311d1b test for travis and github lib(1) 2016-06-07 14:55:04 +08:00
yhua
2f8ec6461b test for travis and github lib 2016-06-07 14:40:37 +08:00
yhua
00f69eb327 automation testing 2016-06-07 12:19:48 +08:00