Skip to content

Commit

Permalink
Merge pull request #307 from xmidt-org/wrp-validator
Browse files Browse the repository at this point in the history
Wrp validator
  • Loading branch information
maurafortino authored Oct 11, 2023
2 parents 498d124 + de67d28 commit 34f3ea8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion WRPHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ func TestFanoutRequest(t *testing.T) {
Entity: testCase.Entity,
}

mockWRPAccessAuthority.On("authorizeWRP", r.Context(), &testCase.Entity.Message).Return(testCase.Modify, testCase.Err)
testEntity := testCase.Entity.Message
mockWRPAccessAuthority.On("authorizeWRP", r.Context(), &testEntity).Return(testCase.Modify, testCase.Err)

wrpFanoutHandler.ServeWRP(wrpResponseWriter, wrpRequest)

Expand Down
4 changes: 2 additions & 2 deletions primaryHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,7 @@ func ValidateWRP() func(http.Handler) http.Handler {
return func(delegate http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

ctx := r.Context()
if msg, ok := wrpcontext.Get[*wrp.Message](ctx); ok {
if msg, ok := wrpcontext.Get[*wrp.Message](r.Context()); ok {
validators := wrp.SpecValidators()
var err error
for _, v := range validators {
Expand All @@ -586,6 +585,7 @@ func ValidateWRP() func(http.Handler) http.Handler {
return
}
}

delegate.ServeHTTP(w, r)
})
}
Expand Down

0 comments on commit 34f3ea8

Please sign in to comment.