This is an automated email from the ASF dual-hosted git repository.
abeizn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new d404a9bc2 Zentao test connection fix (#5500)
d404a9bc2 is described below
commit d404a9bc2c78f040307f473d5106ca81a533808f
Author: mappjzc <[email protected]>
AuthorDate: Thu Jun 15 18:27:53 2023 +0800
Zentao test connection fix (#5500)
* fix: fix typemapping
Fix story typemapping.
Fix story statusmapping.
Fix task typemapping.
Nddtfjiang <[email protected]>
* feat: add e2e for mapping
Add e2e test for ScopeConfig mapping.
Nddtfjiang <[email protected]>
* fix: fix zentao 500 error
Fix 500 error if failed to get token.
Fix 500 error if decode input failed.
Nddtfjiang <[email protected]>
---
backend/plugins/zentao/api/connection.go | 5 +++--
backend/plugins/zentao/models/connection.go | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/backend/plugins/zentao/api/connection.go
b/backend/plugins/zentao/api/connection.go
index 52450e3a0..ccf5cf2de 100644
--- a/backend/plugins/zentao/api/connection.go
+++ b/backend/plugins/zentao/api/connection.go
@@ -19,9 +19,10 @@ package api
import (
"context"
- "github.com/apache/incubator-devlake/server/api/shared"
"net/http"
+ "github.com/apache/incubator-devlake/server/api/shared"
+
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/plugin"
helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
@@ -46,7 +47,7 @@ func TestConnection(input *plugin.ApiResourceInput)
(*plugin.ApiResourceOutput,
var connection models.ZentaoConn
err := helper.Decode(input.Body, &connection, vld)
if err != nil {
- return nil, err
+ return nil, errors.BadInput.Wrap(err, "failed to decode input
to be zentao connection")
}
// try to create apiClient
diff --git a/backend/plugins/zentao/models/connection.go
b/backend/plugins/zentao/models/connection.go
index cd39e6fbd..6e8ed4771 100644
--- a/backend/plugins/zentao/models/connection.go
+++ b/backend/plugins/zentao/models/connection.go
@@ -48,7 +48,7 @@ func (connection ZentaoConn) PrepareApiClient(apiClient
apihelperabstract.ApiCli
return err
}
if tokenResBody.Token == "" {
- return errors.Default.New("failed to request access token")
+ return errors.HttpStatus(http.StatusBadRequest).New("failed to
request access token")
}
apiClient.SetHeaders(map[string]string{
"Token": fmt.Sprintf("%v", tokenResBody.Token),