@@ -73,7 +73,8 @@ type MissingToken struct {
7373 } `json:"errors"`
7474}
7575
76- const JWSRegex = "[a-zA-Z0-9\\ -_]+?\\ .?[a-zA-Z0-9\\ -_]+?\\ .?([a-zA-Z0-9\\ -_]+)?"
76+ const jwsRegex = "[a-zA-Z0-9\\ -_]+?\\ .?[a-zA-Z0-9\\ -_]+?\\ .?([a-zA-Z0-9\\ -_]+)?"
77+ const userNameRegex = "[a-zA-Z\\ -0-9]+"
7778
7879// AuthAPIUserByNameConsumer defines contract of /api/users?filter[username]=<user_name> endpoint
7980func AuthAPIUserByNameConsumer (t * testing.T , pact * dsl.Pact ) {
@@ -106,7 +107,7 @@ func AuthAPIUserByNameConsumer(t *testing.T, pact *dsl.Pact) {
106107 Query : dsl.MapMatcher {
107108 "filter[username]" : dsl .Term (
108109 userName ,
109- ".*" ,
110+ userNameRegex ,
110111 ),
111112 },
112113 Headers : dsl.MapMatcher {"Content-Type" : dsl .String ("application/json" )},
@@ -152,7 +153,7 @@ func AuthAPIUserByIDConsumer(t *testing.T, pact *dsl.Pact) {
152153 Method : "GET" ,
153154 Path : dsl .Term (
154155 fmt .Sprintf ("/api/users/%s" , userID ),
155- "/api/users/.*" ,
156+ fmt . Sprintf ( "/api/users/%s" , userNameRegex ) ,
156157 ),
157158 Headers : dsl.MapMatcher {"Content-Type" : dsl .String ("application/json" )},
158159 }).
@@ -203,7 +204,7 @@ func AuthAPIUserInvalidToken(t *testing.T, pact *dsl.Pact) {
203204 "Content-Type" : dsl .String ("application/json" ),
204205 "Authorization" : dsl .Term (
205206 fmt .Sprintf ("Bearer %s" , invalidToken ),
206- fmt .Sprintf ("^Bearer %s$" , JWSRegex ),
207+ fmt .Sprintf ("^Bearer %s$" , jwsRegex ),
207208 ),
208209 },
209210 }).
0 commit comments