@@ -31,7 +31,7 @@ func (ts *PasskeyTestSuite) createTestPasskey(userID uuid.UUID, friendlyName str
3131
3232func (ts * PasskeyTestSuite ) TestPasskeyListEmpty () {
3333 token := ts .generateToken (ts .TestUser , & ts .TestSession .ID )
34- w := ts .makeAuthenticatedRequest (http .MethodGet , "http://localhost/passkeys" , token , nil )
34+ w := ts .makeRequest (http .MethodGet , "http://localhost/passkeys" , nil , withBearerToken ( token ) )
3535
3636 ts .Equal (http .StatusOK , w .Code )
3737
@@ -45,7 +45,7 @@ func (ts *PasskeyTestSuite) TestPasskeyListWithPasskeys() {
4545 pk2 := ts .createTestPasskey (ts .TestUser .ID , "My MacBook" )
4646
4747 token := ts .generateToken (ts .TestUser , & ts .TestSession .ID )
48- w := ts .makeAuthenticatedRequest (http .MethodGet , "http://localhost/passkeys" , token , nil )
48+ w := ts .makeRequest (http .MethodGet , "http://localhost/passkeys" , nil , withBearerToken ( token ) )
4949
5050 ts .Equal (http .StatusOK , w .Code )
5151
@@ -74,7 +74,7 @@ func (ts *PasskeyTestSuite) TestPasskeyListDoesNotReturnOtherUsersPasskeys() {
7474 ts .createTestPasskey (otherUser .ID , "Other User Passkey" )
7575
7676 token := ts .generateToken (ts .TestUser , & ts .TestSession .ID )
77- w := ts .makeAuthenticatedRequest (http .MethodGet , "http://localhost/passkeys" , token , nil )
77+ w := ts .makeRequest (http .MethodGet , "http://localhost/passkeys" , nil , withBearerToken ( token ) )
7878
7979 ts .Equal (http .StatusOK , w .Code )
8080
@@ -93,9 +93,9 @@ func (ts *PasskeyTestSuite) TestPasskeyUpdateFriendlyName() {
9393 cred := ts .createTestPasskey (ts .TestUser .ID , "Old Name" )
9494
9595 token := ts .generateToken (ts .TestUser , & ts .TestSession .ID )
96- w := ts .makeAuthenticatedRequest (http .MethodPatch , fmt .Sprintf ("http://localhost/passkeys/%s" , cred .ID ), token , map [string ]any {
96+ w := ts .makeRequest (http .MethodPatch , fmt .Sprintf ("http://localhost/passkeys/%s" , cred .ID ), map [string ]any {
9797 "friendly_name" : "New Name" ,
98- })
98+ }, withBearerToken ( token ) )
9999
100100 ts .Equal (http .StatusOK , w .Code )
101101
@@ -113,7 +113,7 @@ func (ts *PasskeyTestSuite) TestPasskeyUpdateMissingFriendlyName() {
113113 cred := ts .createTestPasskey (ts .TestUser .ID , "Name" )
114114
115115 token := ts .generateToken (ts .TestUser , & ts .TestSession .ID )
116- w := ts .makeAuthenticatedRequest (http .MethodPatch , fmt .Sprintf ("http://localhost/passkeys/%s" , cred .ID ), token , map [string ]any {})
116+ w := ts .makeRequest (http .MethodPatch , fmt .Sprintf ("http://localhost/passkeys/%s" , cred .ID ), map [string ]any {}, withBearerToken ( token ) )
117117
118118 ts .Equal (http .StatusBadRequest , w .Code )
119119}
@@ -122,9 +122,9 @@ func (ts *PasskeyTestSuite) TestPasskeyUpdateFriendlyNameTooLong() {
122122 cred := ts .createTestPasskey (ts .TestUser .ID , "Name" )
123123
124124 token := ts .generateToken (ts .TestUser , & ts .TestSession .ID )
125- w := ts .makeAuthenticatedRequest (http .MethodPatch , fmt .Sprintf ("http://localhost/passkeys/%s" , cred .ID ), token , map [string ]any {
125+ w := ts .makeRequest (http .MethodPatch , fmt .Sprintf ("http://localhost/passkeys/%s" , cred .ID ), map [string ]any {
126126 "friendly_name" : strings .Repeat ("a" , 121 ),
127- })
127+ }, withBearerToken ( token ) )
128128
129129 ts .Equal (http .StatusBadRequest , w .Code )
130130
@@ -139,9 +139,9 @@ func (ts *PasskeyTestSuite) TestPasskeyUpdateFriendlyNameAtMaxLength() {
139139
140140 token := ts .generateToken (ts .TestUser , & ts .TestSession .ID )
141141 longName := strings .Repeat ("a" , 120 )
142- w := ts .makeAuthenticatedRequest (http .MethodPatch , fmt .Sprintf ("http://localhost/passkeys/%s" , cred .ID ), token , map [string ]any {
142+ w := ts .makeRequest (http .MethodPatch , fmt .Sprintf ("http://localhost/passkeys/%s" , cred .ID ), map [string ]any {
143143 "friendly_name" : longName ,
144- })
144+ }, withBearerToken ( token ) )
145145
146146 ts .Equal (http .StatusOK , w .Code )
147147
@@ -157,9 +157,9 @@ func (ts *PasskeyTestSuite) TestPasskeyUpdateOtherUsersPasskey() {
157157 otherCred := ts .createTestPasskey (otherUser .ID , "Other Passkey" )
158158
159159 token := ts .generateToken (ts .TestUser , & ts .TestSession .ID )
160- w := ts .makeAuthenticatedRequest (http .MethodPatch , fmt .Sprintf ("http://localhost/passkeys/%s" , otherCred .ID ), token , map [string ]any {
160+ w := ts .makeRequest (http .MethodPatch , fmt .Sprintf ("http://localhost/passkeys/%s" , otherCred .ID ), map [string ]any {
161161 "friendly_name" : "Stolen Passkey" ,
162- })
162+ }, withBearerToken ( token ) )
163163
164164 ts .Equal (http .StatusNotFound , w .Code )
165165
@@ -171,18 +171,18 @@ func (ts *PasskeyTestSuite) TestPasskeyUpdateOtherUsersPasskey() {
171171
172172func (ts * PasskeyTestSuite ) TestPasskeyUpdateNonExistent () {
173173 token := ts .generateToken (ts .TestUser , & ts .TestSession .ID )
174- w := ts .makeAuthenticatedRequest (http .MethodPatch , fmt .Sprintf ("http://localhost/passkeys/%s" , uuid .Must (uuid .NewV4 ())), token , map [string ]any {
174+ w := ts .makeRequest (http .MethodPatch , fmt .Sprintf ("http://localhost/passkeys/%s" , uuid .Must (uuid .NewV4 ())), map [string ]any {
175175 "friendly_name" : "New Name" ,
176- })
176+ }, withBearerToken ( token ) )
177177
178178 ts .Equal (http .StatusNotFound , w .Code )
179179}
180180
181181func (ts * PasskeyTestSuite ) TestPasskeyUpdateInvalidID () {
182182 token := ts .generateToken (ts .TestUser , & ts .TestSession .ID )
183- w := ts .makeAuthenticatedRequest (http .MethodPatch , "http://localhost/passkeys/not-a-uuid" , token , map [string ]any {
183+ w := ts .makeRequest (http .MethodPatch , "http://localhost/passkeys/not-a-uuid" , map [string ]any {
184184 "friendly_name" : "New Name" ,
185- })
185+ }, withBearerToken ( token ) )
186186
187187 ts .Equal (http .StatusNotFound , w .Code )
188188}
@@ -199,7 +199,7 @@ func (ts *PasskeyTestSuite) TestPasskeyDelete() {
199199 cred := ts .createTestPasskey (ts .TestUser .ID , "To Delete" )
200200
201201 token := ts .generateToken (ts .TestUser , & ts .TestSession .ID )
202- w := ts .makeAuthenticatedRequest (http .MethodDelete , fmt .Sprintf ("http://localhost/passkeys/%s" , cred .ID ), token , nil )
202+ w := ts .makeRequest (http .MethodDelete , fmt .Sprintf ("http://localhost/passkeys/%s" , cred .ID ), nil , withBearerToken ( token ) )
203203
204204 ts .Equal (http .StatusOK , w .Code )
205205
@@ -219,7 +219,7 @@ func (ts *PasskeyTestSuite) TestPasskeyDeleteOtherUsersPasskey() {
219219 otherCred := ts .createTestPasskey (otherUser .ID , "Other Passkey" )
220220
221221 token := ts .generateToken (ts .TestUser , & ts .TestSession .ID )
222- w := ts .makeAuthenticatedRequest (http .MethodDelete , fmt .Sprintf ("http://localhost/passkeys/%s" , otherCred .ID ), token , nil )
222+ w := ts .makeRequest (http .MethodDelete , fmt .Sprintf ("http://localhost/passkeys/%s" , otherCred .ID ), nil , withBearerToken ( token ) )
223223
224224 ts .Equal (http .StatusNotFound , w .Code )
225225
@@ -230,7 +230,7 @@ func (ts *PasskeyTestSuite) TestPasskeyDeleteOtherUsersPasskey() {
230230
231231func (ts * PasskeyTestSuite ) TestPasskeyDeleteNonExistent () {
232232 token := ts .generateToken (ts .TestUser , & ts .TestSession .ID )
233- w := ts .makeAuthenticatedRequest (http .MethodDelete , fmt .Sprintf ("http://localhost/passkeys/%s" , uuid .Must (uuid .NewV4 ())), token , nil )
233+ w := ts .makeRequest (http .MethodDelete , fmt .Sprintf ("http://localhost/passkeys/%s" , uuid .Must (uuid .NewV4 ())), nil , withBearerToken ( token ) )
234234
235235 ts .Equal (http .StatusNotFound , w .Code )
236236}
@@ -246,16 +246,16 @@ func (ts *PasskeyTestSuite) TestPasskeyManageDisabled() {
246246 token := ts .generateToken (ts .TestUser , & ts .TestSession .ID )
247247
248248 // List
249- w := ts .makeAuthenticatedRequest (http .MethodGet , "http://localhost/passkeys/" , token , nil )
249+ w := ts .makeRequest (http .MethodGet , "http://localhost/passkeys/" , nil , withBearerToken ( token ) )
250250 ts .Equal (http .StatusNotFound , w .Code )
251251
252252 // Update
253- w = ts .makeAuthenticatedRequest (http .MethodPatch , fmt .Sprintf ("http://localhost/passkeys/%s" , uuid .Must (uuid .NewV4 ())), token , map [string ]any {
253+ w = ts .makeRequest (http .MethodPatch , fmt .Sprintf ("http://localhost/passkeys/%s" , uuid .Must (uuid .NewV4 ())), map [string ]any {
254254 "friendly_name" : "Name" ,
255- })
255+ }, withBearerToken ( token ) )
256256 ts .Equal (http .StatusNotFound , w .Code )
257257
258258 // Delete
259- w = ts .makeAuthenticatedRequest (http .MethodDelete , fmt .Sprintf ("http://localhost/passkeys/%s" , uuid .Must (uuid .NewV4 ())), token , nil )
259+ w = ts .makeRequest (http .MethodDelete , fmt .Sprintf ("http://localhost/passkeys/%s" , uuid .Must (uuid .NewV4 ())), nil , withBearerToken ( token ) )
260260 ts .Equal (http .StatusNotFound , w .Code )
261261}
0 commit comments