Skip to content

Commit ed6851a

Browse files
committed
added failing tests for lua scenarios
1 parent 78fe669 commit ed6851a

File tree

4 files changed

+168
-0
lines changed

4 files changed

+168
-0
lines changed

lex_test.go

+67
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,73 @@ var lexFixtures = []lexFixture{
315315
{"}", 39},
316316
{"}", 40},
317317
}},
318+
{"lua-block-cert-slim", []tokenLine{
319+
{"http", 1},
320+
{"{", 1},
321+
{"server", 2},
322+
{"{", 2},
323+
{"ssl_certificate_by_lua_block", 3},
324+
{"{", 3},
325+
{"print(\"Test lua ssl certificate!\")", 4},
326+
{"}", 5},
327+
{"}", 6},
328+
{"}", 7},
329+
}},
330+
{"lua-block-cert-double-server", []tokenLine{
331+
{"http", 1},
332+
{"{", 1},
333+
{"server", 2},
334+
{"{", 2},
335+
{"listen", 3},
336+
{"443", 3},
337+
{"ssl", 3},
338+
{";", 3},
339+
{"server_name", 4},
340+
{"lua.example.com", 4},
341+
{";", 4},
342+
{"location", 6},
343+
{"/", 6},
344+
{"{", 6},
345+
{"root", 7},
346+
{"/usr/share/nginx/html", 7},
347+
{";", 7},
348+
{"index", 8},
349+
{"index.html", 8},
350+
{"index.htm", 8},
351+
{";", 8},
352+
{"}", 9},
353+
{"error_page", 11},
354+
{"500", 11},
355+
{"502", 11},
356+
{"503", 11},
357+
{"504", 11},
358+
{"/50x.html", 11},
359+
{";", 11},
360+
{"location", 12},
361+
{"=", 12},
362+
{"/50x.html", 12},
363+
{"{", 12},
364+
{"root", 13},
365+
{"/usr/share/nginx/html", 13},
366+
{";", 13},
367+
{"}", 14},
368+
{"ssl_certificate", 16},
369+
{"/etc/nginx/ssl/cert1.crt", 16},
370+
{";", 16},
371+
{"ssl_certificate_key", 17},
372+
{"/etc/nginx/ssl/key1.key", 17},
373+
{";", 17},
374+
{"ssl_certificate_by_lua_block", 19},
375+
{"{", 19},
376+
{"\n print(\"Test lua ssl certificate!\")\n ", 19},
377+
{")", 20},
378+
{"}", 21},
379+
{"}", 22},
380+
{"server", 24},
381+
{"{", 24},
382+
{"}", 25},
383+
{"}", 26},
384+
}},
318385
{"lua-block-larger", []tokenLine{
319386
{"http", 1},
320387
{"{", 1},

parse_test.go

+68
Original file line numberDiff line numberDiff line change
@@ -1834,6 +1834,74 @@ var parseFixtures = []parseFixture{
18341834
},
18351835
},
18361836
}},
1837+
{"lua-block-cert-slim", "", ParseOptions{
1838+
SingleFile: true,
1839+
ErrorOnUnknownDirectives: true,
1840+
DirectiveSources: []MatchFunc{MatchNginxPlusLatest, MatchLuaLatest},
1841+
LexOptions: LexOptions{
1842+
Lexers: []RegisterLexer{lua.RegisterLexer()},
1843+
},
1844+
}, Payload{
1845+
Status: "ok",
1846+
Errors: []PayloadError{},
1847+
Config: []Config{
1848+
{
1849+
File: getTestConfigPath("lua-block-cert-slim", "nginx.conf"),
1850+
Status: "ok",
1851+
Parsed: Directives{
1852+
{
1853+
Directive: "http",
1854+
Line: 1,
1855+
Args: []string{},
1856+
Block: Directives{
1857+
{
1858+
Directive: "server",
1859+
Line: 2,
1860+
Args: []string{},
1861+
Block: Directives{
1862+
// TODO
1863+
},
1864+
},
1865+
},
1866+
},
1867+
},
1868+
},
1869+
},
1870+
}},
1871+
{"lua-block-cert-double-server", "", ParseOptions{
1872+
SingleFile: true,
1873+
ErrorOnUnknownDirectives: true,
1874+
DirectiveSources: []MatchFunc{MatchNginxPlusLatest, MatchLuaLatest},
1875+
LexOptions: LexOptions{
1876+
Lexers: []RegisterLexer{lua.RegisterLexer()},
1877+
},
1878+
}, Payload{
1879+
Status: "ok",
1880+
Errors: []PayloadError{},
1881+
Config: []Config{
1882+
{
1883+
File: getTestConfigPath("lua-block-cert-double-server", "nginx.conf"),
1884+
Status: "ok",
1885+
Parsed: Directives{
1886+
{
1887+
Directive: "http",
1888+
Line: 1,
1889+
Args: []string{},
1890+
Block: Directives{
1891+
{
1892+
Directive: "server",
1893+
Line: 2,
1894+
Args: []string{},
1895+
Block: Directives{
1896+
// TODO
1897+
},
1898+
},
1899+
},
1900+
},
1901+
},
1902+
},
1903+
},
1904+
}},
18371905
{"lua-block-larger", "", ParseOptions{
18381906
SingleFile: true,
18391907
ErrorOnUnknownDirectives: true,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
http {
2+
server {
3+
listen 443 ssl;
4+
server_name lua.example.com;
5+
6+
location / {
7+
root /usr/share/nginx/html;
8+
index index.html index.htm;
9+
}
10+
11+
error_page 500 502 503 504 /50x.html;
12+
location = /50x.html {
13+
root /usr/share/nginx/html;
14+
}
15+
16+
ssl_certificate /etc/nginx/ssl/cert1.crt;
17+
ssl_certificate_key /etc/nginx/ssl/key1.key;
18+
19+
ssl_certificate_by_lua_block {
20+
print("Test lua ssl certificate!")
21+
}
22+
}
23+
24+
server {
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
http {
2+
server {
3+
ssl_certificate_by_lua_block {
4+
print("Test lua ssl certificate!")
5+
}
6+
}
7+
}

0 commit comments

Comments
 (0)