@@ -61,6 +61,19 @@ function mockEntitlement (code, data, isError = false) {
61
61
isError ? base . replyWithError ( data ) : base . reply ( code , data )
62
62
}
63
63
64
+ /**
65
+ * @function
66
+ * @public
67
+ *
68
+ * Mock request to the api key service.
69
+ *
70
+ * @param {number } code The status code to be returned
71
+ * @param {Object } data The response object to be returned
72
+ */
73
+ function mockApiKey ( code , data ) {
74
+ nock ( 'http://barfoo.com' ) . get ( '/foo/bar' ) . reply ( code , data )
75
+ }
76
+
64
77
/**
65
78
* @function
66
79
* @public
@@ -108,7 +121,7 @@ function registerRoutes (server) {
108
121
{
109
122
method : 'GET' ,
110
123
path : '/' ,
111
- config : {
124
+ options : {
112
125
auth : 'keycloak-jwt' ,
113
126
handler ( req ) {
114
127
return req . auth . credentials . scope
@@ -118,7 +131,7 @@ function registerRoutes (server) {
118
131
{
119
132
method : 'GET' ,
120
133
path : '/role' ,
121
- config : {
134
+ options : {
122
135
auth : {
123
136
strategies : [ 'keycloak-jwt' ] ,
124
137
access : {
@@ -133,7 +146,7 @@ function registerRoutes (server) {
133
146
{
134
147
method : 'GET' ,
135
148
path : '/role/guest' ,
136
- config : {
149
+ options : {
137
150
auth : {
138
151
strategies : [ 'keycloak-jwt' ] ,
139
152
access : {
@@ -148,7 +161,7 @@ function registerRoutes (server) {
148
161
{
149
162
method : 'GET' ,
150
163
path : '/role/rpt' ,
151
- config : {
164
+ options : {
152
165
auth : {
153
166
strategies : [ 'keycloak-jwt' ] ,
154
167
access : {
@@ -159,6 +172,18 @@ function registerRoutes (server) {
159
172
return req . auth . credentials . scope
160
173
}
161
174
}
175
+ } ,
176
+ {
177
+ method : 'GET' ,
178
+ path : '/proxy' ,
179
+ options : {
180
+ handler ( req ) {
181
+ return {
182
+ headers : req . headers ,
183
+ query : req . query
184
+ }
185
+ }
186
+ }
162
187
}
163
188
] )
164
189
}
@@ -199,6 +224,7 @@ async function getServer (options) {
199
224
await server . initialize ( )
200
225
201
226
if ( options === false ) {
227
+ registerRoutes ( server )
202
228
return server
203
229
}
204
230
@@ -210,6 +236,7 @@ module.exports = {
210
236
mockIntrospect,
211
237
mockEntitlement,
212
238
mockRequest,
239
+ mockApiKey,
213
240
log,
214
241
getServer,
215
242
registerPlugin
0 commit comments