Skip to content

Commit

Permalink
Remove email configuration (#17712)
Browse files Browse the repository at this point in the history
Email related settings are deprecated
   Remove email ping API
   Fixes #17683

Signed-off-by: stonezdj <[email protected]>

Signed-off-by: stonezdj <[email protected]>
  • Loading branch information
stonezdj authored Nov 14, 2022
1 parent 484abd6 commit a47e175
Show file tree
Hide file tree
Showing 12 changed files with 1 addition and 348 deletions.
27 changes: 0 additions & 27 deletions api/v2.0/legacy_swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,6 @@ security:
- basic: []
- {}
paths:
/email/ping:
post:
summary: Test connection and authentication with email server.
description: |
Test connection and authentication with email server.
parameters:
- name: settings
in: body
description: 'Email server settings, if some of the settings are not assigned, they will be read from system configuration.'
required: false
schema:
$ref: '#/definitions/EmailServerSetting'
tags:
- Products
responses:
'200':
description: Ping email server successfully.
'400':
description: Inviald email server settings.
'401':
description: User need to login first.
'403':
description: Only admin has this authority.
'415':
$ref: '#/responses/UnsupportedMediaType'
'500':
description: Unexpected internal errors.
/chartrepo/{repo}/charts/{name}/{version}/labels:
get:
summary: Return the attached labels of chart.
Expand Down
61 changes: 0 additions & 61 deletions api/v2.0/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8477,27 +8477,6 @@ definitions:
auth_mode:
$ref: '#/definitions/StringConfigItem'
description: The auth mode of current system, such as "db_auth", "ldap_auth", "oidc_auth"
email_from:
$ref: '#/definitions/StringConfigItem'
description: The sender name for Email notification.
email_host:
$ref: '#/definitions/StringConfigItem'
description: The hostname of SMTP server that sends Email notification.
email_identity:
$ref: '#/definitions/StringConfigItem'
description: By default it's empty so the email_username is picked
email_insecure:
$ref: '#/definitions/BoolConfigItem'
description: Whether or not the certificate will be verified when Harbor tries to access the email server.
email_port:
$ref: '#/definitions/IntegerConfigItem'
description: The port of SMTP server
email_ssl:
$ref: '#/definitions/BoolConfigItem'
description: When it''s set to true the system will access Email server via TLS by default. If it''s set to false, it still will handle "STARTTLS" from server side.
email_username:
$ref: '#/definitions/StringConfigItem'
description: The username for authenticate against SMTP server
ldap_base_dn:
$ref: '#/definitions/StringConfigItem'
description: The Base DN for LDAP binding.
Expand Down Expand Up @@ -8660,46 +8639,6 @@ definitions:
description: The auth mode of current system, such as "db_auth", "ldap_auth", "oidc_auth"
x-omitempty: true
x-isnullable: true
email_from:
type: string
description: The sender name for Email notification.
x-omitempty: true
x-isnullable: true
email_host:
type: string
description: The hostname of SMTP server that sends Email notification.
x-omitempty: true
x-isnullable: true
email_identity:
type: string
description: By default it's empty so the email_username is picked
x-omitempty: true
x-isnullable: true
email_insecure:
type: boolean
description: Whether or not the certificate will be verified when Harbor tries to access the email server.
x-omitempty: true
x-isnullable: true
email_password:
type: string
description: Email password
x-omitempty: true
x-isnullable: true
email_port:
type: integer
description: The port of SMTP server
x-omitempty: true
x-isnullable: true
email_ssl:
type: boolean
description: When it''s set to true the system will access Email server via TLS by default. If it''s set to false, it still will handle "STARTTLS" from server side.
x-omitempty: true
x-isnullable: true
email_username:
type: string
description: The username for authenticate against SMTP server
x-omitempty: true
x-isnullable: true
ldap_base_dn:
type: string
description: The Base DN for LDAP binding.
Expand Down
4 changes: 0 additions & 4 deletions src/controller/config/test/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
var TestDBConfig = map[string]interface{}{
common.LDAPBaseDN: "dc=example,dc=com",
common.LDAPURL: "ldap.example.com",
common.EmailHost: "127.0.0.1",
}

var TestConfigWithScanAll = map[string]interface{}{
Expand All @@ -42,7 +41,6 @@ var TestConfigWithScanAll = map[string]interface{}{
"postgresql_sslmode": "disable",
"ldap_base_dn": "dc=example,dc=com",
"ldap_url": "ldap.example.com",
"email_host": "127.0.0.1",
"scan_all_policy": `{"parameter":{"daily_time":0},"type":"daily"}`,
}

Expand All @@ -65,7 +63,6 @@ func (c *controllerTestSuite) TestGetUserCfg() {
c.Error(err, "failed to get user config")
}
c.Equal("dc=example,dc=com", resp["ldap_base_dn"].Val)
c.Equal("127.0.0.1", resp["email_host"].Val)
c.Equal("ldap.example.com", resp["ldap_url"].Val)
}

Expand Down Expand Up @@ -107,7 +104,6 @@ func (c *controllerTestSuite) TestGetAll() {
c.Error(err, "failed to get user config")
}
c.Equal("dc=example,dc=com", resp["ldap_base_dn"])
c.Equal("127.0.0.1", resp["email_host"])
c.Equal("ldap.example.com", resp["ldap_url"])
}

Expand Down
120 changes: 0 additions & 120 deletions src/core/api/email.go

This file was deleted.

76 changes: 0 additions & 76 deletions src/core/api/email_test.go

This file was deleted.

11 changes: 0 additions & 11 deletions src/core/api/harborapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package api

import (
"bytes"
"io/ioutil"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -88,8 +87,6 @@ func init() {
beego.BConfig.WebConfig.Session.SessionOn = true
beego.TestBeegoInit(apppath)

beego.Router("/api/email/ping", &EmailAPI{}, "post:Ping")

// Charts are controlled under projects
chartRepositoryAPIType := &ChartRepositoryAPI{}
beego.Router("/api/chartrepo/health", chartRepositoryAPIType, "get:GetHealthStatus")
Expand Down Expand Up @@ -146,11 +143,3 @@ func request(_sling *sling.Sling, acceptHeader string, authInfo ...usrInfo) (int
code, _, body, err := request0(_sling, acceptHeader, authInfo...)
return code, body, err
}

func (a testapi) PingEmail(authInfo usrInfo, settings []byte) (int, string, error) {
_sling := sling.New().Base(a.basePath).Post("/api/email/ping").Body(bytes.NewReader(settings))

code, body, err := request(_sling, jsonAcceptHeader, authInfo)

return code, string(body), err
}
Loading

0 comments on commit a47e175

Please sign in to comment.