Remove the permission checking for getcert API (#6436)

The Harbor root cert can be downloaded by all users now, so the permission checking is not needed anymore

Signed-off-by: Wenkai Yin <yinw@vmware.com>
This commit is contained in:
Wenkai Yin 2018-12-05 12:15:23 +08:00 committed by Yan
parent 481bdb01a2
commit 538082ceb6
3 changed files with 4 additions and 8 deletions

View File

@ -2279,10 +2279,6 @@ paths:
responses:
'200':
description: Get default root certificate successfully.
'401':
description: User need to log in first.
'403':
description: User does not have permission of admin role.
'404':
description: Not found the default root certificate.
'500':

View File

@ -140,7 +140,6 @@ func (sia *SystemInfoAPI) GetVolumeInfo() {
// GetCert gets default self-signed certificate.
func (sia *SystemInfoAPI) GetCert() {
sia.validate()
if _, err := os.Stat(defaultRootCert); err == nil {
sia.Ctx.Output.Header("Content-Type", "application/octet-stream")
sia.Ctx.Output.Header("Content-Disposition", "attachment; filename=ca.crt")

View File

@ -73,15 +73,16 @@ func TestGetCert(t *testing.T) {
apiTest := newHarborAPI()
// case 1: get cert without admin role
code, _, err := apiTest.CertGet(*testUser)
code, content, err := apiTest.CertGet(*testUser)
if err != nil {
t.Error("Error occurred while get system cert")
t.Log(err)
} else {
assert.Equal(403, code, "Get system cert should be 403")
assert.Equal(200, code, "Get system cert should be 200")
assert.Equal("test for ca.crt.\n", string(content), "Get system cert content should be equal")
}
// case 2: get cert with admin role
code, content, err := apiTest.CertGet(*admin)
code, content, err = apiTest.CertGet(*admin)
if err != nil {
t.Error("Error occurred while get system cert")
t.Log(err)