Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
backoffice_server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
web-et-numerique
Factory
LLLE_Project
backoffice_server
Commits
bddfcd66
Commit
bddfcd66
authored
2 years ago
by
Rémi PAILHAREY
Browse files
Options
Downloads
Patches
Plain Diff
fix: getting consent with unknown id now returns 404
parent
c463107f
No related branches found
Branches containing commit
No related tags found
4 merge requests
!73
Deploy Openshift v2
,
!65
MEP: removed Meilisearch
,
!52
back-office SGE before canary release
,
!37
Fix/get consent by id 500
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
internal/models/consent.go
+6
-1
6 additions, 1 deletion
internal/models/consent.go
internal/rootmux/rootmux_test.go
+3
-1
3 additions, 1 deletion
internal/rootmux/rootmux_test.go
with
9 additions
and
2 deletions
internal/models/consent.go
+
6
−
1
View file @
bddfcd66
...
...
@@ -2,6 +2,7 @@ package models
import
(
"encoding/json"
"errors"
"fmt"
"log"
"net/http"
...
...
@@ -34,7 +35,11 @@ func (dh *DataHandler) GetConsentById(w http.ResponseWriter, r *http.Request) {
var
consent
Consent
err
=
dh
.
sqlClient
.
First
(
&
consent
,
id
)
.
Error
if
err
!=
nil
{
http
.
Error
(
w
,
"couldn't find consent"
,
http
.
StatusInternalServerError
)
if
errors
.
Is
(
err
,
gorm
.
ErrRecordNotFound
)
{
http
.
Error
(
w
,
"consent not found"
,
http
.
StatusNotFound
)
return
}
http
.
Error
(
w
,
"error while finding consent"
,
http
.
StatusInternalServerError
)
return
}
...
...
This diff is collapsed.
Click to expand it.
internal/rootmux/rootmux_test.go
+
3
−
1
View file @
bddfcd66
...
...
@@ -245,8 +245,10 @@ func sgeTests(t *testing.T) {
time
.
Sleep
(
1
*
time
.
Second
)
// Try to update a consent (must pass)
do
(
"PUT"
,
"/api/sge/consent/1"
,
sgeApiHeader
,
`{"serviceId":123456}`
,
http
.
StatusOK
,
`{"ID":1`
)
// Try to get a consent that doesn't exist (must fail not found)
do
(
"GET"
,
"/api/sge/consent/123456"
,
sgeApiHeader
,
""
,
http
.
StatusNotFound
,
`consent not found`
)
// Try to get a consent (must pass)
do
(
"GET"
,
"/api/sge/consent/1"
,
sgeApiHeader
,
`{"serviceId":123456}`
,
http
.
StatusOK
,
`{"ID":1`
)
do
(
"GET"
,
"/api/sge/consent/1"
,
sgeApiHeader
,
""
,
http
.
StatusOK
,
`{"ID":1`
)
// Try to login (must pass)
do
(
"GET"
,
"/OAuth2Login"
,
noH
,
""
,
http
.
StatusOK
,
""
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment