mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-23 00:57:44 +01:00
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:
parent
481bdb01a2
commit
538082ceb6
@ -2279,10 +2279,6 @@ paths:
|
|||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Get default root certificate successfully.
|
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':
|
'404':
|
||||||
description: Not found the default root certificate.
|
description: Not found the default root certificate.
|
||||||
'500':
|
'500':
|
||||||
|
@ -140,7 +140,6 @@ func (sia *SystemInfoAPI) GetVolumeInfo() {
|
|||||||
|
|
||||||
// GetCert gets default self-signed certificate.
|
// GetCert gets default self-signed certificate.
|
||||||
func (sia *SystemInfoAPI) GetCert() {
|
func (sia *SystemInfoAPI) GetCert() {
|
||||||
sia.validate()
|
|
||||||
if _, err := os.Stat(defaultRootCert); err == nil {
|
if _, err := os.Stat(defaultRootCert); err == nil {
|
||||||
sia.Ctx.Output.Header("Content-Type", "application/octet-stream")
|
sia.Ctx.Output.Header("Content-Type", "application/octet-stream")
|
||||||
sia.Ctx.Output.Header("Content-Disposition", "attachment; filename=ca.crt")
|
sia.Ctx.Output.Header("Content-Disposition", "attachment; filename=ca.crt")
|
||||||
|
@ -73,15 +73,16 @@ func TestGetCert(t *testing.T) {
|
|||||||
apiTest := newHarborAPI()
|
apiTest := newHarborAPI()
|
||||||
|
|
||||||
// case 1: get cert without admin role
|
// case 1: get cert without admin role
|
||||||
code, _, err := apiTest.CertGet(*testUser)
|
code, content, err := apiTest.CertGet(*testUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("Error occurred while get system cert")
|
t.Error("Error occurred while get system cert")
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
} else {
|
} 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
|
// case 2: get cert with admin role
|
||||||
code, content, err := apiTest.CertGet(*admin)
|
code, content, err = apiTest.CertGet(*admin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("Error occurred while get system cert")
|
t.Error("Error occurred while get system cert")
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user