Read misc.httpmethod, misc.protocol and misc.port from their IANA registries #26
+32
-24
@@ -95,30 +95,38 @@ func TestShippedMiscCategories(t *testing.T) {
|
|||||||
func TestShippedMiscReferenceData(t *testing.T) {
|
func TestShippedMiscReferenceData(t *testing.T) {
|
||||||
f := newGenerator(t, "data/misc", WithSeed(1))
|
f := newGenerator(t, "data/misc", WithSeed(1))
|
||||||
re := map[string]*regexp.Regexp{
|
re := map[string]*regexp.Regexp{
|
||||||
"currency": regexp.MustCompile(`^[A-Z]{3}$`),
|
"currency": regexp.MustCompile(`^[A-Z]{3}$`),
|
||||||
"currency.name": regexp.MustCompile(`\p{L}`),
|
"currency.name": regexp.MustCompile(`\p{L}`),
|
||||||
"currency.symbol": regexp.MustCompile(`^\S+$`),
|
"currency.symbol": regexp.MustCompile(`^\S+$`),
|
||||||
"territory": regexp.MustCompile(`\p{L}`),
|
"territory": regexp.MustCompile(`\p{L}`),
|
||||||
"territory.alpha2": regexp.MustCompile(`^[A-Z]{2}$`),
|
"territory.alpha2": regexp.MustCompile(`^[A-Z]{2}$`),
|
||||||
"territory.alpha3": regexp.MustCompile(`^[A-Z]{3}$`),
|
"territory.alpha3": regexp.MustCompile(`^[A-Z]{3}$`),
|
||||||
"territory.country": regexp.MustCompile(`^[A-Z]{2}$`),
|
"territory.country": regexp.MustCompile(`^[A-Z]{2}$`),
|
||||||
"language": regexp.MustCompile(`\p{L}`),
|
"language": regexp.MustCompile(`\p{L}`),
|
||||||
"language.code": regexp.MustCompile(`^[a-z]{2}$`),
|
"language.code": regexp.MustCompile(`^[a-z]{2}$`),
|
||||||
"language.code3": regexp.MustCompile(`^[a-z]{3}$`),
|
"language.code3": regexp.MustCompile(`^[a-z]{3}$`),
|
||||||
"timezone": regexp.MustCompile(`^[A-Za-z]+(/[A-Za-z0-9_+-]+)+$`),
|
"timezone": regexp.MustCompile(`^[A-Za-z]+(/[A-Za-z0-9_+-]+)+$`),
|
||||||
"timezone.offset": regexp.MustCompile(`^[+-](0\d|1[0-4]):[0-5]\d$`),
|
"timezone.offset": regexp.MustCompile(`^[+-](0\d|1[0-4]):[0-5]\d$`),
|
||||||
"timezone.territory": regexp.MustCompile(`^[A-Z]{2}$`),
|
"timezone.territory": regexp.MustCompile(`^[A-Z]{2}$`),
|
||||||
"timezone.weight": regexp.MustCompile(`^[1-9]\d*$`),
|
"timezone.weight": regexp.MustCompile(`^[1-9]\d*$`),
|
||||||
"mimetype": regexp.MustCompile(`^[a-z]+/[a-z0-9.+-]+$`),
|
"mimetype": regexp.MustCompile(`^[a-z]+/[a-z0-9.+-]+$`),
|
||||||
"mimetype.ext": regexp.MustCompile(`^\.[a-z0-9_-]+$`),
|
"mimetype.ext": regexp.MustCompile(`^\.[a-z0-9_-]+$`),
|
||||||
"httpstatus": regexp.MustCompile(`^[1-5]\d{2} \S.*$`),
|
"httpmethod": regexp.MustCompile(`^[A-Za-z][A-Za-z-]*$`),
|
||||||
"httpstatus.code": regexp.MustCompile(`^[1-5]\d{2}$`),
|
"httpmethod.safe": regexp.MustCompile(`^(yes|no)$`),
|
||||||
"useragent": regexp.MustCompile(`^Mozilla/5\.0 .+`),
|
"httpmethod.idempotent": regexp.MustCompile(`^(yes|no)$`),
|
||||||
"useragent.browser": regexp.MustCompile(`^(Chrome|Edge|Firefox|Opera|Safari|Samsung Internet)$`),
|
"port": regexp.MustCompile(`^[1-9]\d{0,4}$`),
|
||||||
"useragent.device": regexp.MustCompile(`^(desktop|mobile)$`),
|
"port.name": regexp.MustCompile(`^\S+$`),
|
||||||
"useragent.os": regexp.MustCompile(`^(Android|ChromeOS|Linux|Windows|iOS|macOS)$`),
|
"protocol": regexp.MustCompile(`^\S+( \S+)*$`),
|
||||||
"car": regexp.MustCompile(`^\S.* \S`),
|
"protocol.name": regexp.MustCompile(`\S`),
|
||||||
"car.make": regexp.MustCompile(`^\S`),
|
"protocol.number": regexp.MustCompile(`^\d{1,3}$`),
|
||||||
|
"httpstatus": regexp.MustCompile(`^[1-5]\d{2} \S.*$`),
|
||||||
|
"httpstatus.code": regexp.MustCompile(`^[1-5]\d{2}$`),
|
||||||
|
"useragent": regexp.MustCompile(`^Mozilla/5\.0 .+`),
|
||||||
|
"useragent.browser": regexp.MustCompile(`^(Chrome|Edge|Firefox|Opera|Safari|Samsung Internet)$`),
|
||||||
|
"useragent.device": regexp.MustCompile(`^(desktop|mobile)$`),
|
||||||
|
"useragent.os": regexp.MustCompile(`^(Android|ChromeOS|Linux|Windows|iOS|macOS)$`),
|
||||||
|
"car": regexp.MustCompile(`^\S.* \S`),
|
||||||
|
"car.make": regexp.MustCompile(`^\S`),
|
||||||
}
|
}
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
for p, rx := range re {
|
for p, rx := range re {
|
||||||
|
|||||||
@@ -701,6 +701,18 @@ func TestShippedTables(t *testing.T) {
|
|||||||
"timezone[Asia/Kathmandu].offset": "+05:45",
|
"timezone[Asia/Kathmandu].offset": "+05:45",
|
||||||
"timezone[America/New_York].offset": "-05:00",
|
"timezone[America/New_York].offset": "-05:00",
|
||||||
"territory[SE].timezone": "Europe/Stockholm",
|
"territory[SE].timezone": "Europe/Stockholm",
|
||||||
|
"httpmethod[GET].safe": "yes",
|
||||||
|
"httpmethod[GET].idempotent": "yes",
|
||||||
|
"httpmethod[POST].safe": "no",
|
||||||
|
"httpmethod[POST].idempotent": "no",
|
||||||
|
"httpmethod[PUT].idempotent": "yes",
|
||||||
|
"protocol[TCP].number": "6",
|
||||||
|
"protocol[UDP].number": "17",
|
||||||
|
"protocol[ICMP].name": "Internet Control Message",
|
||||||
|
"port[443]": "443",
|
||||||
|
"port[443].name": "https",
|
||||||
|
"port[22].name": "ssh",
|
||||||
|
"port[3306].name": "mysql",
|
||||||
"territory[NP].timezone.offset": "+05:45",
|
"territory[NP].timezone.offset": "+05:45",
|
||||||
} {
|
} {
|
||||||
if got := fake(t, f, path); got != want {
|
if got := fake(t, f, path); got != want {
|
||||||
|
|||||||
Reference in New Issue
Block a user