(c *gin.Context)
| 203 | } |
| 204 | |
| 205 | func TestConnection(c *gin.Context) { |
| 206 | ctx, err := internalhandler.NewContextWithAuthorization(c) |
| 207 | defer func() { internalhandler.JSONResponse(c, ctx) }() |
| 208 | |
| 209 | if err != nil { |
| 210 | |
| 211 | ctx.RespErr = fmt.Errorf("authorization Info Generation failed: err %s", err) |
| 212 | ctx.UnAuthorized = true |
| 213 | return |
| 214 | } |
| 215 | |
| 216 | args := new(commonmodels.Proxy) |
| 217 | data, err := c.GetRawData() |
| 218 | if err != nil { |
| 219 | log.Errorf("TestConnection c.GetRawData() err : %v", err) |
| 220 | } |
| 221 | if err = json.Unmarshal(data, args); err != nil { |
| 222 | log.Errorf("TestConnection json.Unmarshal err : %v", err) |
| 223 | } |
| 224 | |
| 225 | c.Request.Body = io.NopCloser(bytes.NewBuffer(data)) |
| 226 | |
| 227 | if err := c.ShouldBindWith(&args, binding.JSON); err != nil { |
| 228 | ctx.RespErr = e.ErrInvalidParam.AddDesc("invalid proxy args") |
| 229 | return |
| 230 | } |
| 231 | |
| 232 | // authorization checks |
| 233 | if !ctx.Resources.IsSystemAdmin { |
| 234 | ctx.UnAuthorized = true |
| 235 | return |
| 236 | } |
| 237 | |
| 238 | ctx.RespErr = service.TestConnection(args, ctx.Logger) |
| 239 | } |
nothing calls this directly
no test coverage detected