@@ -119,6 +119,59 @@ func TestAnalyze_auth_jwt(t *testing.T) {
119119 }
120120}
121121
122+ func TestAnalyze_auth_jwt_require (t * testing.T ) {
123+ t .Parallel ()
124+ testcases := map [string ]struct {
125+ stmt * Directive
126+ ctx blockCtx
127+ wantErr bool
128+ }{
129+ "auth_jwt_require ok" : {
130+ & Directive {
131+ Directive : "auth_jwt_require" ,
132+ Args : []string {"$value1" , "$value2" },
133+ Line : 5 ,
134+ },
135+ blockCtx {"http" , "location" , "limit_except" },
136+ false ,
137+ },
138+ "auth_jwt_require with error code ok" : {
139+ & Directive {
140+ Directive : "auth_jwt_require" ,
141+ Args : []string {"$value1" , "$value2" , "error=403" },
142+ Line : 5 ,
143+ },
144+ blockCtx {"http" , "location" , "limit_except" },
145+ false ,
146+ },
147+ "auth_jwt_require not ok" : {
148+ & Directive {
149+ Directive : "auth_jwt_require" ,
150+ Args : []string {"$value" },
151+ Line : 5 ,
152+ },
153+ blockCtx {"stream" },
154+ true ,
155+ },
156+ }
157+
158+ for name , tc := range testcases {
159+ tc := tc
160+ t .Run (name , func (t * testing.T ) {
161+ t .Parallel ()
162+ err := analyze ("nginx.conf" , tc .stmt , ";" , tc .ctx , & ParseOptions {})
163+
164+ if ! tc .wantErr && err != nil {
165+ t .Fatal (err )
166+ }
167+
168+ if tc .wantErr && err == nil {
169+ t .Fatal ("expected error, got nil" )
170+ }
171+ })
172+ }
173+ }
174+
122175func TestAnalyze_njs (t * testing.T ) {
123176 t .Parallel ()
124177 testcases := map [string ]struct {
0 commit comments