Browse Source

update dependancies

Mark deVilliers 2 years ago
parent
commit
d1fd8755a5
49 changed files with 4316 additions and 71 deletions
  1. 30 0
      vendor/github.com/Pallinder/go-randomdata/.gitignore
  2. 8 0
      vendor/github.com/Pallinder/go-randomdata/.travis.yml
  3. 20 0
      vendor/github.com/Pallinder/go-randomdata/LICENSE
  4. 166 0
      vendor/github.com/Pallinder/go-randomdata/README.md
  5. 151 0
      vendor/github.com/Pallinder/go-randomdata/fullprofile.go
  6. 49 0
      vendor/github.com/Pallinder/go-randomdata/fullprofile_test.go
  7. 2616 0
      vendor/github.com/Pallinder/go-randomdata/jsondata.go
  8. 244 0
      vendor/github.com/Pallinder/go-randomdata/postalcodes.go
  9. 54 0
      vendor/github.com/Pallinder/go-randomdata/postalcodes_test.go
  10. 364 0
      vendor/github.com/Pallinder/go-randomdata/random_data.go
  11. 100 0
      vendor/github.com/Pallinder/go-randomdata/random_data_example_test.go
  12. 387 0
      vendor/github.com/Pallinder/go-randomdata/random_data_test.go
  13. 33 3
      vendor/github.com/emicklei/go-restful-openapi/build_path.go
  14. 7 2
      vendor/github.com/emicklei/go-restful-openapi/build_path_test.go
  15. 4 3
      vendor/github.com/emicklei/go-restful-openapi/examples/user-resource.go
  16. 1 1
      vendor/github.com/emicklei/go-restful-openapi/lookup.go
  17. 1 1
      vendor/github.com/emicklei/go-restful-openapi/property_ext.go
  18. 2 1
      vendor/github.com/emicklei/go-restful/README.md
  19. 4 4
      vendor/github.com/emicklei/go-restful/compressors.go
  20. 3 3
      vendor/github.com/emicklei/go-restful/container.go
  21. 1 1
      vendor/github.com/emicklei/go-restful/examples/google_app_engine/datastore/main.go
  22. 1 1
      vendor/github.com/emicklei/go-restful/examples/google_app_engine/restful-user-service.go
  23. 1 1
      vendor/github.com/emicklei/go-restful/examples/msgpack/msgpack_entity_test.go
  24. 1 1
      vendor/github.com/emicklei/go-restful/examples/restful-CORS-filter.go
  25. 1 1
      vendor/github.com/emicklei/go-restful/examples/restful-NCSA-logging.go
  26. 4 4
      vendor/github.com/emicklei/go-restful/examples/restful-basic-authentication.go
  27. 1 1
      vendor/github.com/emicklei/go-restful/examples/restful-curly-router.go
  28. 1 1
      vendor/github.com/emicklei/go-restful/examples/restful-curly-router_test.go
  29. 2 2
      vendor/github.com/emicklei/go-restful/examples/restful-encoding-filter.go
  30. 3 3
      vendor/github.com/emicklei/go-restful/examples/restful-filters.go
  31. 2 1
      vendor/github.com/emicklei/go-restful/examples/restful-form-handling.go
  32. 2 1
      vendor/github.com/emicklei/go-restful/examples/restful-hello-world.go
  33. 1 1
      vendor/github.com/emicklei/go-restful/examples/restful-html-template.go
  34. 1 1
      vendor/github.com/emicklei/go-restful/examples/restful-multi-containers.go
  35. 2 1
      vendor/github.com/emicklei/go-restful/examples/restful-no-cache-filter.go
  36. 1 1
      vendor/github.com/emicklei/go-restful/examples/restful-options-filter.go
  37. 3 2
      vendor/github.com/emicklei/go-restful/examples/restful-path-tail.go
  38. 1 1
      vendor/github.com/emicklei/go-restful/examples/restful-resource-functions.go
  39. 1 1
      vendor/github.com/emicklei/go-restful/examples/restful-serve-static.go
  40. 2 2
      vendor/github.com/emicklei/go-restful/examples/restful-swagger.go
  41. 2 2
      vendor/github.com/emicklei/go-restful/examples/restful-user-resource.go
  42. 2 2
      vendor/github.com/emicklei/go-restful/examples/restful-user-service.go
  43. 1 1
      vendor/github.com/emicklei/go-restful/logger.go
  44. 1 1
      vendor/github.com/emicklei/go-restful/response.go
  45. 1 1
      vendor/github.com/emicklei/go-restful/route.go
  46. 26 7
      vendor/github.com/emicklei/go-restful/route_builder.go
  47. 5 1
      vendor/github.com/emicklei/go-restful/route_builder_test.go
  48. 1 1
      vendor/github.com/emicklei/go-restful/web_service.go
  49. 1 9
      vendor/github.com/go-openapi/spec/ref.go

+ 30 - 0
vendor/github.com/Pallinder/go-randomdata/.gitignore

@@ -0,0 +1,30 @@
1
+# git ignore for idea (IntelliJ, Gogland,...)
2
+.idea/
3
+
4
+# Compiled Object files, Static and Dynamic libs (Shared Objects)
5
+*.o
6
+*.a
7
+*.so
8
+
9
+# Folders
10
+_obj
11
+_test
12
+
13
+# Architecture specific extensions/prefixes
14
+*.[568vq]
15
+[568vq].out
16
+
17
+*.cgo1.go
18
+*.cgo2.c
19
+_cgo_defun.c
20
+_cgo_gotypes.go
21
+_cgo_export.*
22
+
23
+_testmain.go
24
+
25
+*.exe
26
+
27
+# Testing specific
28
+*.out
29
+*.prof
30
+*.test

+ 8 - 0
vendor/github.com/Pallinder/go-randomdata/.travis.yml

@@ -0,0 +1,8 @@
1
+language: go
2
+
3
+go:
4
+  - 1.0
5
+  - 1.1
6
+  - 1.2
7
+  - 1.3
8
+  - tip

+ 20 - 0
vendor/github.com/Pallinder/go-randomdata/LICENSE

@@ -0,0 +1,20 @@
1
+The MIT License (MIT)
2
+
3
+Copyright (c) 2013 David Pallinder
4
+
5
+Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+this software and associated documentation files (the "Software"), to deal in
7
+the Software without restriction, including without limitation the rights to
8
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+the Software, and to permit persons to whom the Software is furnished to do so,
10
+subject to the following conditions:
11
+
12
+The above copyright notice and this permission notice shall be included in all
13
+copies or substantial portions of the Software.
14
+
15
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 166 - 0
vendor/github.com/Pallinder/go-randomdata/README.md

@@ -0,0 +1,166 @@
1
+
2
+go-randomdata
3
+==============
4
+[![Build Status](https://travis-ci.org/Pallinder/go-randomdata.png)](https://travis-ci.org/Pallinder/go-randomdata)
5
+
6
+randomdata is a tiny help suite for generating random data such as 
7
+* first names (male or female)
8
+* last names
9
+* full names (male or female) 
10
+* country names (full name or iso 3166.1 alpha-2 or alpha-3)
11
+* random email address
12
+* city names
13
+* American state names (two chars or full)
14
+* random numbers (in an interval)
15
+* random paragraphs 
16
+* random bool values
17
+* postal- or zip-codes formatted for a range of different countries.
18
+* american sounding addresses / street names
19
+* silly names - suitable for names of things
20
+* random days
21
+* random months
22
+* random full date
23
+* random full profile
24
+* random date inside range
25
+
26
+### Installation
27
+```go get github.com/Pallinder/go-randomdata```
28
+
29
+### Documentation
30
+http://godoc.org/github.com/Pallinder/go-randomdata
31
+
32
+### Usage
33
+```go
34
+
35
+package main
36
+
37
+import (
38
+	"fmt"
39
+	"github.com/Pallinder/go-randomdata"
40
+)
41
+
42
+func main() {
43
+	// Print a random silly name
44
+	fmt.Println(randomdata.SillyName())
45
+
46
+	// Print a male title
47
+    	fmt.Println(randomdata.Title(randomdata.Male))
48
+
49
+    	// Print a female title
50
+    	fmt.Println(randomdata.Title(randomdata.Female))
51
+
52
+    	// Print a title with random gender
53
+   	fmt.Println(randomdata.Title(randomdata.RandomGender))
54
+
55
+	// Print a male first name
56
+	fmt.Println(randomdata.FirstName(randomdata.Male))
57
+
58
+	// Print a female first name
59
+	fmt.Println(randomdata.FirstName(randomdata.Female))
60
+
61
+	// Print a last name
62
+	fmt.Println(randomdata.LastName())
63
+
64
+	// Print a male name
65
+	fmt.Println(randomdata.FullName(randomdata.Male))
66
+
67
+	// Print a female name
68
+	fmt.Println(randomdata.FullName(randomdata.Female))
69
+
70
+	// Print a name with random gender
71
+	fmt.Println(randomdata.FullName(randomdata.RandomGender))
72
+
73
+	// Print an email
74
+	fmt.Println(randomdata.Email())
75
+
76
+	// Print a country with full text representation
77
+	fmt.Println(randomdata.Country(randomdata.FullCountry))
78
+
79
+	// Print a country using ISO 3166-1 alpha-2
80
+	fmt.Println(randomdata.Country(randomdata.TwoCharCountry))
81
+
82
+	// Print a country using ISO 3166-1 alpha-3
83
+	fmt.Println(randomdata.Country(randomdata.ThreeCharCountry))
84
+
85
+	// Print a currency using ISO 4217
86
+	fmt.Println(randomdata.Currency())
87
+
88
+	// Print the name of a random city
89
+	fmt.Println(randomdata.City())
90
+
91
+	// Print the name of a random american state
92
+	fmt.Println(randomdata.State(randomdata.Large))
93
+	
94
+	// Print the name of a random american state using two chars
95
+	fmt.Println(randomdata.State(randomdata.Small))
96
+
97
+	// Print an american sounding street name
98
+	fmt.Println(randomdata.Street())
99
+	
100
+	// Print an american sounding address
101
+	fmt.Println(randomdata.Address())
102
+
103
+	// Print a random number >= 10 and <= 20
104
+	fmt.Println(randomdata.Number(10, 20))
105
+
106
+	// Print a number >= 0 and <= 20
107
+	fmt.Println(randomdata.Number(20))
108
+
109
+	// Print a random float >= 0 and <= 20 with decimal point 3
110
+	fmt.Println(randomdata.Decimal(0, 20, 3))
111
+
112
+	// Print a random float >= 10 and <= 20
113
+	fmt.Println(randomdata.Decimal(10, 20))
114
+
115
+	// Print a random float >= 0 and <= 20
116
+	fmt.Println(randomdata.Decimal(20))
117
+
118
+	// Print a bool
119
+	fmt.Println(randomdata.Boolean())
120
+	
121
+	// Print a paragraph
122
+	fmt.Println(randomdata.Paragraph())
123
+	
124
+	// Print a postal code 
125
+	fmt.Println(randomdata.PostalCode("SE"))
126
+
127
+	// Print a set of 2 random numbers as a string
128
+	fmt.Println(randomdata.StringNumber(2, "-")) 
129
+	
130
+	// Print a set of 2 random 3-Digits numbers as a string
131
+	fmt.Println(randomdata.StringNumberExt(2, "-", 3)) 
132
+	
133
+	// Print a valid random IPv4 address
134
+	fmt.Println(randomdata.IpV4Address())
135
+
136
+	// Print a valid random IPv6 address
137
+	fmt.Println(randomdata.Ipv6Address())
138
+
139
+	// Print a day
140
+	fmt.Println(randomdata.Day())
141
+  
142
+	// Print a month
143
+	fmt.Println(randomdata.Month())
144
+  
145
+	// Print full date like Monday 22 Aug 2016
146
+	fmt.Println(randomdata.FullDate())
147
+
148
+	// Print full date <= Monday 22 Aug 2016
149
+	fmt.Println(randomdata.FullDateInRange("2016-08-22"))
150
+
151
+	// Print full date >= Monday 01 Aug 2016 and <= Monday 22 Aug 2016
152
+	fmt.Println(randomdata.FullDateInRange("2016-08-01", "2016-08-22"))
153
+
154
+	// Get a complete and randomised profile of data generally used for users
155
+	// There are many fields in the profile to use check the Profile struct definition in fullprofile.go
156
+	profile := randomdata.GenerateProfile(randomdata.Male | randomdata.Female | randomdata.RandomGender)
157
+	fmt.Printf("The new profile's username is: %s and password (md5)", profile.Login.Username, profile.Login.Md5)
158
+}
159
+
160
+```
161
+
162
+### Contributors
163
+* https://github.com/jteeuwen
164
+
165
+
166
+

+ 151 - 0
vendor/github.com/Pallinder/go-randomdata/fullprofile.go

@@ -0,0 +1,151 @@
1
+package randomdata
2
+
3
+import (
4
+	"math/rand"
5
+	"time"
6
+	"fmt"
7
+	"strconv"
8
+	"strings"
9
+	"crypto/md5"
10
+	"encoding/hex"
11
+	"encoding/base64"
12
+	"crypto/sha1"
13
+	"crypto/sha256"
14
+)
15
+
16
+var letterRunes = []rune("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
17
+var portrait_dirs = []string{"men", "women"}
18
+
19
+type Profile struct {
20
+	Gender string `json:"gender"`
21
+	Name struct {
22
+		First string `json:"first"`
23
+		Last  string `json:"last"`
24
+		Title string `json:"title"`
25
+	} `json:"name"`
26
+	Location struct {
27
+		Street   string `json:"street"`
28
+		City     string `json:"city"`
29
+		State    string `json:"state"`
30
+		Postcode int    `json:"postcode"`
31
+	} `json:"location"`
32
+
33
+	Email  string `json:"email"`
34
+	Login struct {
35
+		Username string `json:"username"`
36
+		Password string `json:"password"`
37
+		Salt     string `json:"salt"`
38
+		Md5      string `json:"md5"`
39
+		Sha1     string `json:"sha1"`
40
+		Sha256   string `json:"sha256"`
41
+	} `json:"login"`
42
+
43
+	Dob    string `json:"dob"`
44
+	Registered string `json:"registered"`
45
+	Phone   string `json:"phone"`
46
+	Cell   string `json:"cell"`
47
+
48
+	ID     struct {
49
+		Name  string      `json:"name"`
50
+		Value interface{} `json:"value"`
51
+	} `json:"id"`
52
+
53
+	Picture struct {
54
+		Large     string `json:"large"`
55
+		Medium    string `json:"medium"`
56
+		Thumbnail string `json:"thumbnail"`
57
+	} `json:"picture"`
58
+	Nat     string `json:"nat"`
59
+}
60
+
61
+func RandStringRunes(n int) string {
62
+	b := make([]rune, n)
63
+	for i := range b {
64
+		b[i] = letterRunes[rand.Intn(len(letterRunes))]
65
+	}
66
+	return string(b)
67
+}
68
+
69
+func getMD5Hash(text string) string {
70
+	hasher := md5.New()
71
+	hasher.Write([]byte(text))
72
+	return hex.EncodeToString(hasher.Sum(nil))
73
+}
74
+
75
+func getSha1(text string) string {
76
+	hasher := sha1.New()
77
+	hasher.Write([]byte(text))
78
+	sha := base64.URLEncoding.EncodeToString(hasher.Sum(nil))
79
+	return sha
80
+}
81
+
82
+
83
+func getSha256(text string) string {
84
+	hasher := sha256.New()
85
+	hasher.Write([]byte(text))
86
+	sha := base64.URLEncoding.EncodeToString(hasher.Sum(nil))
87
+	return sha
88
+}
89
+
90
+func GenerateProfile(gender int) *Profile {
91
+	rand.Seed(time.Now().UnixNano())
92
+	profile := &Profile{}
93
+	if gender == RandomGender {
94
+		gender = rand.Intn(2)
95
+		if gender == Male {
96
+			profile.Gender = "male"
97
+		} else {
98
+			profile.Gender = "female"
99
+		}
100
+	} else if gender == Male {
101
+		profile.Gender = "male"
102
+	} else {
103
+		profile.Gender = "female"
104
+	}
105
+	profile.Name.Title = Title(gender)
106
+	profile.Name.First = FirstName(gender)
107
+	profile.Name.Last = LastName()
108
+	profile.ID.Name = "SSN"
109
+	profile.ID.Value = fmt.Sprintf("%d-%d-%d",
110
+		Number(101, 999),
111
+		Number(01, 99),
112
+		Number(100, 9999),
113
+	)
114
+
115
+	profile.Email = strings.ToLower(profile.Name.First) + "." + strings.ToLower(profile.Name.Last) + "@example.com"
116
+	profile.Cell = fmt.Sprintf("%d-%d-%d",
117
+		Number(201, 999),
118
+		Number(201, 999),
119
+		Number(1000, 9999),
120
+	)
121
+	profile.Phone = fmt.Sprintf("%d-%d-%d",
122
+		Number(201, 999),
123
+		Number(201, 999),
124
+		Number(1000, 9999),
125
+	)
126
+	profile.Dob = FullDate()
127
+	profile.Registered = FullDate()
128
+	profile.Nat = "US"
129
+
130
+	profile.Location.City = City()
131
+	i, _ := strconv.Atoi(PostalCode("US"))
132
+	profile.Location.Postcode = i
133
+	profile.Location.State = State(2)
134
+	profile.Location.Street = StringNumber(1, "") + " " + Street()
135
+
136
+	profile.Login.Username = SillyName()
137
+	pass := SillyName()
138
+	salt := RandStringRunes(16)
139
+	profile.Login.Password = pass
140
+	profile.Login.Salt = salt
141
+	profile.Login.Md5 = getMD5Hash(pass+salt)
142
+	profile.Login.Sha1 = getSha1(pass+salt)
143
+	profile.Login.Sha256 = getSha256(pass+salt)
144
+
145
+	pic := rand.Intn(35)
146
+	profile.Picture.Large = fmt.Sprintf("https://randomuser.me/api/portraits/%s/%d.jpg", portrait_dirs[gender], pic)
147
+	profile.Picture.Medium = fmt.Sprintf("https://randomuser.me/api/portraits/med/%s/%d.jpg", portrait_dirs[gender], pic)
148
+	profile.Picture.Thumbnail = fmt.Sprintf("https://randomuser.me/api/portraits/thumb/%s/%d.jpg", portrait_dirs[gender], pic)
149
+
150
+	return profile
151
+}

+ 49 - 0
vendor/github.com/Pallinder/go-randomdata/fullprofile_test.go

@@ -0,0 +1,49 @@
1
+package randomdata
2
+
3
+import (
4
+	"testing"
5
+)
6
+
7
+func Test_FullProfileGenerator(t *testing.T) {
8
+	profile := GenerateProfile(1)
9
+
10
+	if profile.Gender != "female" {
11
+		t.Fatalf("Expected gender to be female but got %s", profile.Gender)
12
+	}
13
+
14
+	profile = GenerateProfile(0)
15
+
16
+	if profile.Gender != "male" {
17
+		t.Fatalf("Expected gender to be male but got %s", profile.Gender)
18
+	}
19
+
20
+	profile = GenerateProfile(2)
21
+
22
+	if profile == nil {
23
+		t.Fatal("Profile failed to generate")
24
+	}
25
+
26
+	if len(profile.Cell) != 12 {
27
+		t.Fatalf("Expected Cell# to be len %d but got %d\n", 12, len(profile.Cell))
28
+	}
29
+
30
+	if len(profile.Phone) != 12 {
31
+		t.Fatalf("Expected Phone# to be len %d but got %d\n", 12, len(profile.Cell))
32
+	}
33
+
34
+	if profile.Login.Username == "" {
35
+		t.Fatal("Profile Username failed to generate")
36
+	}
37
+
38
+	if profile.Location.Street == "" {
39
+		t.Fatal("Profile Street failed to generate")
40
+	}
41
+
42
+	if profile.ID.Name != "SSN" {
43
+		t.Fatalf("Profile ID Name to be SSN, but got %s\n", profile.ID.Name)
44
+	}
45
+
46
+	if profile.Picture.Large == "" {
47
+		t.Fatalf("Profile Picture Large to be set, but got %s\n", profile.Picture.Large)
48
+	}
49
+}

File diff suppressed because it is too large
+ 2616 - 0
vendor/github.com/Pallinder/go-randomdata/jsondata.go


+ 244 - 0
vendor/github.com/Pallinder/go-randomdata/postalcodes.go

@@ -0,0 +1,244 @@
1
+package randomdata
2
+
3
+import (
4
+	"fmt"
5
+	"math"
6
+	"math/rand"
7
+	"strings"
8
+)
9
+
10
+// Supported formats obtained from:
11
+// * http://www.geopostcodes.com/GeoPC_Postal_codes_formats
12
+
13
+// PostalCode yields a random postal/zip code for the given 2-letter country code.
14
+//
15
+// These codes are not guaranteed to refer to actually locations.
16
+// They merely follow the correct format as far as letters and digits goes.
17
+// Where possible, the function enforces valid ranges of letters and digits.
18
+func PostalCode(countrycode string) string {
19
+	switch strings.ToUpper(countrycode) {
20
+	case "LS", "MG", "IS", "OM", "PG":
21
+		return Digits(3)
22
+
23
+	case "AM", "GE", "NZ", "NE", "NO", "PY", "ZA", "MZ", "SJ", "LI", "AL",
24
+		"BD", "CV", "GL":
25
+		return Digits(4)
26
+
27
+	case "DZ", "BA", "KH", "DO", "EG", "EE", "GP", "GT", "ID", "IL", "JO",
28
+		"KW", "MQ", "MX", "LK", "SD", "TR", "UA", "US", "CR", "IQ", "KV", "MY",
29
+		"MN", "ME", "PK", "SM", "MA", "UY", "EH", "ZM":
30
+		return Digits(5)
31
+
32
+	case "BY", "CN", "IN", "KZ", "KG", "NG", "RO", "RU", "SG", "TJ", "TM", "UZ", "VN":
33
+		return Digits(6)
34
+
35
+	case "CL":
36
+		return Digits(7)
37
+
38
+	case "IR":
39
+		return Digits(10)
40
+
41
+	case "FO":
42
+		return "FO " + Digits(3)
43
+
44
+	case "AF":
45
+		return BoundedDigits(2, 10, 43) + BoundedDigits(2, 1, 99)
46
+
47
+	case "AU", "AT", "BE", "BG", "CY", "DK", "ET", "GW", "HU", "LR", "MK", "PH",
48
+		"CH", "TN", "VE":
49
+		return BoundedDigits(4, 1000, 9999)
50
+
51
+	case "SV":
52
+		return "CP " + BoundedDigits(4, 1000, 9999)
53
+
54
+	case "HT":
55
+		return "HT" + Digits(4)
56
+
57
+	case "LB":
58
+		return Digits(4) + " " + Digits(4)
59
+
60
+	case "LU":
61
+		return BoundedDigits(4, 6600, 6999)
62
+
63
+	case "MD":
64
+		return "MD-" + BoundedDigits(4, 1000, 9999)
65
+
66
+	case "HR":
67
+		return "HR-" + Digits(5)
68
+
69
+	case "CU":
70
+		return "CP " + BoundedDigits(5, 10000, 99999)
71
+
72
+	case "FI":
73
+		// Last digit is usually 0 but can, in some cases, be 1 or 5.
74
+		switch rand.Intn(2) {
75
+		case 0:
76
+			return Digits(4) + "0"
77
+		case 1:
78
+			return Digits(4) + "1"
79
+		}
80
+
81
+		return Digits(4) + "5"
82
+
83
+	case "FR", "GF", "PF", "YT", "MC", "RE", "BL", "MF", "PM", "RS", "TH":
84
+		return BoundedDigits(5, 10000, 99999)
85
+
86
+	case "DE":
87
+		return BoundedDigits(5, 1000, 99999)
88
+
89
+	case "GR":
90
+		return BoundedDigits(3, 100, 999) + " " + Digits(2)
91
+
92
+	case "HN":
93
+		return "CM" + Digits(4)
94
+
95
+	case "IT", "VA":
96
+		return BoundedDigits(5, 10, 99999)
97
+
98
+	case "KE":
99
+		return BoundedDigits(5, 100, 99999)
100
+
101
+	case "LA":
102
+		return BoundedDigits(5, 1000, 99999)
103
+
104
+	case "MH":
105
+		return BoundedDigits(5, 96960, 96970)
106
+
107
+	case "FM":
108
+		return "FM" + BoundedDigits(5, 96941, 96944)
109
+
110
+	case "MM":
111
+		return BoundedDigits(2, 1, 14) + Digits(3)
112
+
113
+	case "NP":
114
+		return BoundedDigits(5, 10700, 56311)
115
+
116
+	case "NC":
117
+		return "98" + Digits(3)
118
+
119
+	case "PW":
120
+		return "PW96940"
121
+
122
+	case "PR":
123
+		return "PR " + Digits(5)
124
+
125
+	case "SA":
126
+		return BoundedDigits(5, 10000, 99999) + "-" + BoundedDigits(4, 1000, 9999)
127
+
128
+	case "ES":
129
+		return BoundedDigits(2, 1, 52) + BoundedDigits(3, 100, 999)
130
+
131
+	case "WF":
132
+		return "986" + Digits(2)
133
+
134
+	case "SZ":
135
+		return Letters(1) + Digits(3)
136
+
137
+	case "BM":
138
+		return Letters(2) + Digits(2)
139
+
140
+	case "AD":
141
+		return Letters(2) + Digits(3)
142
+
143
+	case "BN", "AZ", "VG", "PE":
144
+		return Letters(2) + Digits(4)
145
+
146
+	case "BB":
147
+		return Letters(2) + Digits(5)
148
+
149
+	case "EC":
150
+		return Letters(2) + Digits(6)
151
+
152
+	case "MT":
153
+		return Letters(3) + Digits(4)
154
+
155
+	case "JM":
156
+		return "JM" + Letters(3) + Digits(2)
157
+
158
+	case "AR":
159
+		return Letters(1) + Digits(4) + Letters(3)
160
+
161
+	case "CA":
162
+		return Letters(1) + Digits(1) + Letters(1) + Digits(1) + Letters(1) + Digits(1)
163
+
164
+	case "FK", "TC":
165
+		return Letters(4) + Digits(1) + Letters(2)
166
+
167
+	case "GG", "IM", "JE", "GB":
168
+		return Letters(2) + Digits(2) + Letters(2)
169
+
170
+	case "KY":
171
+		return Letters(2) + Digits(1) + "-" + Digits(4)
172
+
173
+	case "JP":
174
+		return Digits(3) + "-" + Digits(4)
175
+
176
+	case "LV", "SI":
177
+		return Letters(2) + "-" + Digits(4)
178
+
179
+	case "LT":
180
+		return Letters(2) + "-" + Digits(5)
181
+
182
+	case "SE", "TW":
183
+		return Digits(5)
184
+
185
+	case "MV":
186
+		return Digits(2) + "-" + Digits(2)
187
+
188
+	case "PL":
189
+		return Digits(2) + "-" + Digits(3)
190
+
191
+	case "NI":
192
+		return Digits(3) + "-" + Digits(3) + "-" + Digits(1)
193
+
194
+	case "KR":
195
+		return Digits(3) + "-" + Digits(3)
196
+
197
+	case "PT":
198
+		return Digits(4) + "-" + Digits(3)
199
+
200
+	case "NL":
201
+		return Digits(4) + Letters(2)
202
+
203
+	case "BR":
204
+		return Digits(5) + "-" + Digits(3)
205
+	}
206
+
207
+	return ""
208
+}
209
+
210
+// Letters generates a string of N random leters (A-Z).
211
+func Letters(letters int) string {
212
+	list := make([]byte, letters)
213
+
214
+	for i := range list {
215
+		list[i] = byte(rand.Intn('Z'-'A') + 'A')
216
+	}
217
+
218
+	return string(list)
219
+}
220
+
221
+// Digits generates a string of N random digits, padded with zeros if necessary.
222
+func Digits(digits int) string {
223
+	max := int(math.Pow10(digits)) - 1
224
+	num := rand.Intn(max)
225
+	format := fmt.Sprintf("%%0%dd", digits)
226
+	return fmt.Sprintf(format, num)
227
+}
228
+
229
+// BoundedDigits generates a string of N random digits, padded with zeros if necessary.
230
+// The output is restricted to the given range.
231
+func BoundedDigits(digits, low, high int) string {
232
+	if low > high {
233
+		low, high = high, low
234
+	}
235
+
236
+	max := int(math.Pow10(digits)) - 1
237
+	if high > max {
238
+		high = max
239
+	}
240
+
241
+	num := rand.Intn(high-low+1) + low
242
+	format := fmt.Sprintf("%%0%dd", digits)
243
+	return fmt.Sprintf(format, num)
244
+}

+ 54 - 0
vendor/github.com/Pallinder/go-randomdata/postalcodes_test.go

@@ -0,0 +1,54 @@
1
+package randomdata
2
+
3
+import (
4
+	"testing"
5
+)
6
+
7
+var postalcodeTests = []struct {
8
+	Country string
9
+	Size    int
10
+}{
11
+	{"PE", 6},
12
+	{"FO", 6},
13
+	{"AF", 4},
14
+	{"DZ", 5},
15
+	{"BY", 6},
16
+	{"CL", 7},
17
+	{"SZ", 4},
18
+	{"BM", 4},
19
+	{"AD", 5},
20
+	{"BN", 6},
21
+	{"BB", 7},
22
+	{"MT", 7},
23
+	{"JM", 7},
24
+	{"AR", 8},
25
+	{"CA", 6},
26
+	{"FK", 7},
27
+	{"GG", 6},
28
+	{"NL", 6},
29
+	{"BR", 9},
30
+	{"KY", 8},
31
+	{"JP", 8},
32
+	{"LV", 7},
33
+	{"LT", 8},
34
+	{"MV", 5},
35
+	{"NI", 9},
36
+	{"PL", 6},
37
+	{"PT", 8},
38
+	{"KR", 7},
39
+	{"TW", 5},
40
+	{"MH", 5},
41
+}
42
+
43
+func TestPostalCode(t *testing.T) {
44
+	for _, pt := range postalcodeTests {
45
+		code := PostalCode(pt.Country)
46
+
47
+		if len(code) == pt.Size {
48
+			continue
49
+		}
50
+
51
+		t.Fatalf("Invalid length for country %q: Expected %d, have %d.",
52
+			pt.Country, pt.Size, len(code))
53
+	}
54
+}

+ 364 - 0
vendor/github.com/Pallinder/go-randomdata/random_data.go

@@ -0,0 +1,364 @@
1
+// Package randomdata implements a bunch of simple ways to generate (pseudo) random data
2
+package randomdata
3
+
4
+import (
5
+	"encoding/json"
6
+	"fmt"
7
+	"log"
8
+	"math/rand"
9
+	"net"
10
+	"strconv"
11
+	"strings"
12
+	"time"
13
+	"unicode"
14
+)
15
+
16
+const (
17
+	Male         int = 0
18
+	Female       int = 1
19
+	RandomGender int = 2
20
+)
21
+
22
+const (
23
+	Small int = 0
24
+	Large int = 1
25
+)
26
+
27
+const (
28
+	FullCountry      = 0
29
+	TwoCharCountry   = 1
30
+	ThreeCharCountry = 2
31
+)
32
+
33
+const (
34
+	DateInputLayout  = "2006-01-02"
35
+	DateOutputLayout = "Monday 2 Jan 2006"
36
+)
37
+
38
+type jsonContent struct {
39
+	Adjectives          []string `json:adjectives`
40
+	Nouns               []string `json:nouns`
41
+	FirstNamesFemale    []string `json:firstNamesFemale`
42
+	FirstNamesMale      []string `json:firstNamesMale`
43
+	LastNames           []string `json:lastNames`
44
+	Domains             []string `json:domains`
45
+	People              []string `json:people`
46
+	StreetTypes         []string `json:streetTypes` // Taken from https://github.com/tomharris/random_data/blob/master/lib/random_data/locations.rb
47
+	Paragraphs          []string `json:paragraphs`  // Taken from feedbooks.com
48
+	Countries           []string `json:countries`   // Fetched from the world bank at http://siteresources.worldbank.org/DATASTATISTICS/Resources/CLASS.XLS
49
+	CountriesThreeChars []string `json:countriesThreeChars`
50
+	CountriesTwoChars   []string `json:countriesTwoChars`
51
+	Currencies          []string `json:currencies` //https://github.com/OpenBookPrices/country-data
52
+	Cities              []string `json:cities`
53
+	States              []string `json:states`
54
+	StatesSmall         []string `json:statesSmall`
55
+	Days                []string `json:days`
56
+	Months              []string `json:months`
57
+	FemaleTitles        []string `json:femaleTitles`
58
+	MaleTitles          []string `json:maleTitles`
59
+	Timezones           []string `json:timezones` // https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
60
+}
61
+
62
+var jsonData = jsonContent{}
63
+
64
+func init() {
65
+	jsonData = jsonContent{}
66
+
67
+	err := json.Unmarshal(data, &jsonData)
68
+
69
+	if err != nil {
70
+		log.Fatal(err)
71
+	}
72
+}
73
+
74
+func seedAndReturnRandom(n int) int {
75
+	rand.Seed(time.Now().UnixNano())
76
+	return rand.Intn(n)
77
+}
78
+
79
+func seedAndReturnRandomFloat() float64 {
80
+	rand.Seed(time.Now().UnixNano())
81
+	return rand.Float64()
82
+}
83
+
84
+// Returns a random part of a slice
85
+func randomFrom(source []string) string {
86
+	return source[seedAndReturnRandom(len(source))]
87
+}
88
+
89
+// Returns a random title, gender decides the gender of the name
90
+func Title(gender int) string {
91
+	var title = ""
92
+	switch gender {
93
+	case Male:
94
+		title = randomFrom(jsonData.MaleTitles)
95
+		break
96
+	case Female:
97
+		title = randomFrom(jsonData.FemaleTitles)
98
+		break
99
+	default:
100
+		rand.Seed(time.Now().UnixNano())
101
+		title = FirstName(rand.Intn(2))
102
+		break
103
+	}
104
+	return title
105
+}
106
+
107
+// Returns a random first name, gender decides the gender of the name
108
+func FirstName(gender int) string {
109
+	var name = ""
110
+	switch gender {
111
+	case Male:
112
+		name = randomFrom(jsonData.FirstNamesMale)
113
+		break
114
+	case Female:
115
+		name = randomFrom(jsonData.FirstNamesFemale)
116
+		break
117
+	default:
118
+		rand.Seed(time.Now().UnixNano())
119
+		name = FirstName(rand.Intn(2))
120
+		break
121
+	}
122
+	return name
123
+}
124
+
125
+// Returns a random last name
126
+func LastName() string {
127
+	return randomFrom(jsonData.LastNames)
128
+}
129
+
130
+// Returns a combinaton of FirstName LastName randomized, gender decides the gender of the name
131
+func FullName(gender int) string {
132
+	return FirstName(gender) + " " + LastName()
133
+}
134
+
135
+// Returns a random email
136
+func Email() string {
137
+	return strings.ToLower(FirstName(RandomGender)+LastName()) + StringNumberExt(1, "", 3) + "@" + randomFrom(jsonData.Domains)
138
+}
139
+
140
+// Returns a random country, countryStyle decides what kind of format the returned country will have
141
+func Country(countryStyle int64) string {
142
+	country := ""
143
+	switch countryStyle {
144
+
145
+	default:
146
+
147
+	case FullCountry:
148
+		country = randomFrom(jsonData.Countries)
149
+		break
150
+
151
+	case TwoCharCountry:
152
+		country = randomFrom(jsonData.CountriesTwoChars)
153
+		break
154
+
155
+	case ThreeCharCountry:
156
+		country = randomFrom(jsonData.CountriesThreeChars)
157
+		break
158
+	}
159
+	return country
160
+}
161
+
162
+// Returns a random currency under ISO 4217 format
163
+func Currency() string {
164
+	return randomFrom(jsonData.Currencies)
165
+}
166
+
167
+// Returns a random city
168
+func City() string {
169
+	return randomFrom(jsonData.Cities)
170
+}
171
+
172
+// Returns a random american state
173
+func State(typeOfState int) string {
174
+	if typeOfState == Small {
175
+		return randomFrom(jsonData.StatesSmall)
176
+	} else {
177
+		return randomFrom(jsonData.States)
178
+	}
179
+	return ""
180
+}
181
+
182
+// Returns a random fake street name
183
+func Street() string {
184
+	return fmt.Sprintf("%s %s", randomFrom(jsonData.People), randomFrom(jsonData.StreetTypes))
185
+}
186
+
187
+// Returns an american style address
188
+func Address() string {
189
+	return fmt.Sprintf("%d %s,\n%s, %s, %s", Number(100), Street(), City(), State(Small), PostalCode("US"))
190
+}
191
+
192
+// Returns a random paragraph
193
+func Paragraph() string {
194
+	return randomFrom(jsonData.Paragraphs)
195
+}
196
+
197
+// Returns a random number, if only one integer is supplied it is treated as the max value to return
198
+// if a second argument is supplied it returns a number between (and including) the two numbers
199
+func Number(numberRange ...int) int {
200
+	nr := 0
201
+	rand.Seed(time.Now().UnixNano())
202
+	if len(numberRange) > 1 {
203
+		nr = 1
204
+		nr = seedAndReturnRandom(numberRange[1]-numberRange[0]) + numberRange[0]
205
+	} else {
206
+		nr = seedAndReturnRandom(numberRange[0])
207
+	}
208
+	return nr
209
+}
210
+
211
+func Decimal(numberRange ...int) float64 {
212
+	nr := 0.0
213
+	rand.Seed(time.Now().UnixNano())
214
+	if len(numberRange) > 1 {
215
+		nr = 1.0
216
+		nr = seedAndReturnRandomFloat()*(float64(numberRange[1])-float64(numberRange[0])) + float64(numberRange[0])
217
+	} else {
218
+		nr = seedAndReturnRandomFloat() * float64(numberRange[0])
219
+	}
220
+
221
+	if len(numberRange) > 2 {
222
+		sf := strconv.FormatFloat(nr, 'f', numberRange[2], 64)
223
+		nr, _ = strconv.ParseFloat(sf, 64)
224
+	}
225
+	return nr
226
+}
227
+
228
+func StringNumberExt(numberPairs int, separator string, numberOfDigits int) string {
229
+	numberString := ""
230
+
231
+	for i := 0; i < numberPairs; i++ {
232
+		for d := 0; d < numberOfDigits; d++ {
233
+			numberString += fmt.Sprintf("%d", Number(0, 9))
234
+		}
235
+
236
+		if i+1 != numberPairs {
237
+			numberString += separator
238
+		}
239
+	}
240
+
241
+	return numberString
242
+}
243
+
244
+// Returns a random number as a string
245
+func StringNumber(numberPairs int, separator string) string {
246
+	return StringNumberExt(numberPairs, separator, 2)
247
+}
248
+
249
+func Boolean() bool {
250
+	nr := seedAndReturnRandom(2)
251
+	return nr != 0
252
+}
253
+
254
+// Returns a random noun
255
+func Noun() string {
256
+	return randomFrom(jsonData.Nouns)
257
+}
258
+
259
+// Returns a random adjective
260
+func Adjective() string {
261
+	return randomFrom(jsonData.Adjectives)
262
+}
263
+
264
+func uppercaseFirstLetter(word string) string {
265
+	a := []rune(word)
266
+	a[0] = unicode.ToUpper(a[0])
267
+	return string(a)
268
+}
269
+
270
+func lowercaseFirstLetter(word string) string {
271
+	a := []rune(word)
272
+	a[0] = unicode.ToLower(a[0])
273
+	return string(a)
274
+}
275
+
276
+// Returns a silly name, useful for randomizing naming of things
277
+func SillyName() string {
278
+	return uppercaseFirstLetter(Noun()) + Adjective()
279
+}
280
+
281
+// Returns a valid IPv4 address as string
282
+func IpV4Address() string {
283
+	blocks := []string{}
284
+	for i := 0; i < 4; i++ {
285
+		number := seedAndReturnRandom(255)
286
+		blocks = append(blocks, strconv.Itoa(number))
287
+	}
288
+
289
+	return strings.Join(blocks, ".")
290
+}
291
+
292
+// Returns a valid IPv6 address as net.IP
293
+func IpV6Address() string {
294
+	var ip net.IP
295
+	for i := 0; i < net.IPv6len; i++ {
296
+		number := uint8(seedAndReturnRandom(255))
297
+		ip = append(ip, number)
298
+	}
299
+	return ip.String()
300
+}
301
+
302
+// MacAddress returns an mac address string
303
+func MacAddress() string {
304
+	blocks := []string{}
305
+	for i := 0; i < 6; i++ {
306
+		number := fmt.Sprintf("%02x", seedAndReturnRandom(255))
307
+		blocks = append(blocks, number)
308
+	}
309
+
310
+	return strings.Join(blocks, ":")
311
+}
312
+
313
+// Returns random day
314
+func Day() string {
315
+	return randomFrom(jsonData.Days)
316
+}
317
+
318
+// Returns random month
319
+func Month() string {
320
+	return randomFrom(jsonData.Months)
321
+}
322
+
323
+// Returns full date
324
+func FullDate() string {
325
+	timestamp := time.Now()
326
+	day := Day()
327
+	month := Month()
328
+	year := timestamp.Year()
329
+	fullDate := day + " " + strconv.Itoa(Number(1, 30)) + " " + month[0:3] + " " + strconv.Itoa(year)
330
+	return fullDate
331
+}
332
+
333
+// Returns a date string within a given range, given in the format "2006-01-02".
334
+// If no argument is supplied it will return the result of randomdata.FullDate().
335
+// If only one argument is supplied it is treated as the max date to return.
336
+// If a second argument is supplied it returns a date between (and including) the two dates.
337
+// Returned date is in format "Monday 2 Jan 2006".
338
+func FullDateInRange(dateRange ...string) string {
339
+	var (
340
+		min        time.Time
341
+		max        time.Time
342
+		duration   int
343
+		dateString string
344
+	)
345
+	if len(dateRange) == 1 {
346
+		max, _ = time.Parse(DateInputLayout, dateRange[0])
347
+	} else if len(dateRange) == 2 {
348
+		min, _ = time.Parse(DateInputLayout, dateRange[0])
349
+		max, _ = time.Parse(DateInputLayout, dateRange[1])
350
+	}
351
+	if !max.IsZero() && max.After(min) {
352
+		duration = Number(int(max.Sub(min))) * -1
353
+		dateString = max.Add(time.Duration(duration)).Format(DateOutputLayout)
354
+	} else if !max.IsZero() && !max.After(min) {
355
+		dateString = max.Format(DateOutputLayout)
356
+	} else {
357
+		dateString = FullDate()
358
+	}
359
+	return dateString
360
+}
361
+
362
+func Timezone() string {
363
+	return randomFrom(jsonData.Timezones)
364
+}

+ 100 - 0
vendor/github.com/Pallinder/go-randomdata/random_data_example_test.go

@@ -0,0 +1,100 @@
1
+package randomdata
2
+
3
+import "fmt"
4
+
5
+func ExampleRandomdata() {
6
+
7
+	// Print a male first name
8
+	fmt.Println(FirstName(Male))
9
+
10
+	// Print a female first name
11
+	fmt.Println(FirstName(Female))
12
+
13
+	// Print a last name
14
+	fmt.Println(LastName())
15
+
16
+	// Print a male name
17
+	fmt.Println(FullName(Male))
18
+
19
+	// Print a female name
20
+	fmt.Println(FullName(Female))
21
+
22
+	// Print a name with random gender
23
+	fmt.Println(FullName(RandomGender))
24
+
25
+	// Print a random email
26
+	fmt.Println(Email())
27
+
28
+	// Print a country with full text representation
29
+	fmt.Println(Country(FullCountry))
30
+
31
+	// Print a country using ISO 3166-1 alpha-3
32
+	fmt.Println(Country(ThreeCharCountry))
33
+
34
+	// Print a country using ISO 3166-1 alpha-2
35
+	fmt.Println(Country(TwoCharCountry))
36
+
37
+	// Print a currency using ISO 4217
38
+	fmt.Println(Currency())
39
+
40
+	// Print the name of a random city
41
+	fmt.Println(City())
42
+
43
+	// Print the name of a random american state
44
+	fmt.Println(State(Large))
45
+
46
+	// Print the name of a random american state using two letters
47
+	fmt.Println(State(Small))
48
+
49
+	// Print a random number >= 10 and <= 20
50
+	fmt.Println(Number(10, 20))
51
+
52
+	// Print a number >= 0 and <= 20
53
+	fmt.Println(Number(20))
54
+
55
+	// Print a random float >= 0 and <= 20 with decimal point 3
56
+	fmt.Println(Decimal(0, 20, 3))
57
+
58
+	// Print a random float >= 10 and <= 20
59
+	fmt.Println(Decimal(10, 20))
60
+
61
+	// Print a random float >= 0 and <= 20
62
+	fmt.Println(Decimal(20))
63
+
64
+	// Print a paragraph
65
+	fmt.Println(Paragraph())
66
+
67
+	// Print a random bool
68
+	fmt.Println(Boolean())
69
+
70
+	// Print a random postalcode from Sweden
71
+	fmt.Println(PostalCode("SE"))
72
+
73
+	// Print a random american sounding street name
74
+	fmt.Println(Street())
75
+
76
+	// Print a random american address
77
+	fmt.Println(Address())
78
+
79
+	// Print a random string of numbers
80
+	fmt.Println(StringNumber(2, "-"))
81
+
82
+	// Print a set of 2 random 3-Digits numbers as a string
83
+	fmt.Println(StringNumberExt(2, "-", 3))
84
+
85
+	// Print a random IPv4 address
86
+	fmt.Println(IpV4Address())
87
+
88
+	// Print a random IPv6 address
89
+	fmt.Println(IpV6Address())
90
+
91
+	// Print a random day
92
+	fmt.Println(Day())
93
+
94
+	// Print a month
95
+	fmt.Println(Month())
96
+
97
+	// Print full date
98
+	fmt.Println(FullDate())
99
+
100
+}

+ 387 - 0
vendor/github.com/Pallinder/go-randomdata/random_data_test.go

@@ -0,0 +1,387 @@
1
+package randomdata
2
+
3
+import (
4
+	"bytes"
5
+	"net"
6
+	"regexp"
7
+	"strconv"
8
+	"strings"
9
+	"testing"
10
+	"time"
11
+)
12
+
13
+func TestRandomStringDigits(t *testing.T) {
14
+	t.Log("TestRandomStringDigits")
15
+
16
+	if len(StringNumber(2, "-")) != 5 {
17
+		t.Fatal("Wrong length returned")
18
+	}
19
+
20
+	if len(StringNumber(2, "")) != 4 {
21
+		t.Fatal("Wrong length returned")
22
+	}
23
+
24
+	if len(StringNumberExt(3, "/", 3)) != 11 {
25
+		t.Fatal("Wrong length returned")
26
+	}
27
+
28
+	if len(StringNumberExt(3, "", 3)) != 9 {
29
+		t.Fatal("Wrong length returned")
30
+	}
31
+}
32
+
33
+func TestFirstName(t *testing.T) {
34
+	t.Log("TestFirstName")
35
+	firstNameMale := FirstName(Male)
36
+	firstNameFemale := FirstName(Female)
37
+	randomName := FirstName(RandomGender)
38
+
39
+	if !findInSlice(jsonData.FirstNamesMale, firstNameMale) {
40
+		t.Error("firstNameMale empty or not in male names")
41
+	}
42
+
43
+	if !findInSlice(jsonData.FirstNamesFemale, firstNameFemale) {
44
+		t.Error("firstNameFemale empty or not in female names")
45
+	}
46
+
47
+	if randomName == "" {
48
+		t.Error("randomName empty")
49
+	}
50
+
51
+}
52
+
53
+func TestLastName(t *testing.T) {
54
+	t.Log("TestLastName")
55
+	lastName := LastName()
56
+
57
+	if !findInSlice(jsonData.LastNames, lastName) {
58
+		t.Error("lastName empty or not in slice")
59
+	}
60
+}
61
+
62
+func TestFullName(t *testing.T) {
63
+	t.Log("TestFullName")
64
+
65
+	fullNameMale := FullName(Male)
66
+	fullNameFemale := FullName(Female)
67
+	fullNameRandom := FullName(RandomGender)
68
+
69
+	maleSplit := strings.Fields(fullNameMale)
70
+	femaleSplit := strings.Fields(fullNameFemale)
71
+	randomSplit := strings.Fields(fullNameRandom)
72
+
73
+	if len(maleSplit) == 0 {
74
+		t.Error("Failed on full name male")
75
+	}
76
+
77
+	if !findInSlice(jsonData.FirstNamesMale, maleSplit[0]) {
78
+		t.Error("Couldnt find maleSplit first name in firstNamesMale")
79
+	}
80
+
81
+	if !findInSlice(jsonData.LastNames, maleSplit[1]) {
82
+		t.Error("Couldnt find maleSplit last name in lastNames")
83
+	}
84
+
85
+	if len(femaleSplit) == 0 {
86
+		t.Error("Failed on full name female")
87
+	}
88
+
89
+	if !findInSlice(jsonData.FirstNamesFemale, femaleSplit[0]) {
90
+		t.Error("Couldnt find femaleSplit first name in firstNamesFemale")
91
+	}
92
+
93
+	if !findInSlice(jsonData.LastNames, femaleSplit[1]) {
94
+		t.Error("Couldnt find femaleSplit last name in lastNames")
95
+	}
96
+
97
+	if len(randomSplit) == 0 {
98
+		t.Error("Failed on full name random")
99
+	}
100
+
101
+	if !findInSlice(jsonData.FirstNamesMale, randomSplit[0]) && !findInSlice(jsonData.FirstNamesFemale, randomSplit[0]) {
102
+		t.Error("Couldnt find randomSplit first name in either firstNamesMale or firstNamesFemale")
103
+	}
104
+
105
+}
106
+
107
+func TestEmail(t *testing.T) {
108
+	t.Log("TestEmail")
109
+	email := Email()
110
+
111
+	if email == "" {
112
+		t.Error("Failed to generate email with content")
113
+	}
114
+
115
+}
116
+
117
+func TestCountry(t *testing.T) {
118
+	t.Log("TestCountry")
119
+	countryFull := Country(FullCountry)
120
+	countryTwo := Country(TwoCharCountry)
121
+	countryThree := Country(ThreeCharCountry)
122
+
123
+	if len(countryThree) < 3 {
124
+		t.Error("countryThree < 3 chars")
125
+	}
126
+
127
+	if !findInSlice(jsonData.Countries, countryFull) {
128
+		t.Error("Couldnt find country in countries")
129
+	}
130
+
131
+	if !findInSlice(jsonData.CountriesTwoChars, countryTwo) {
132
+		t.Error("Couldnt find country with two chars in countriesTwoChars")
133
+	}
134
+
135
+	if !findInSlice(jsonData.CountriesThreeChars, countryThree) {
136
+		t.Error("Couldnt find country with three chars in countriesThreeChars")
137
+	}
138
+}
139
+
140
+func TestCurrency(t *testing.T) {
141
+	t.Log("TestCurrency")
142
+	if !findInSlice(jsonData.Currencies, Currency()) {
143
+		t.Error("Could not find currency in currencies")
144
+	}
145
+}
146
+
147
+func TestCity(t *testing.T) {
148
+	t.Log("TestCity")
149
+	city := City()
150
+
151
+	if !findInSlice(jsonData.Cities, city) {
152
+		t.Error("Couldnt find city in cities")
153
+	}
154
+}
155
+
156
+func TestParagraph(t *testing.T) {
157
+	t.Log("TestParagraph")
158
+	paragraph := Paragraph()
159
+
160
+	if !findInSlice(jsonData.Paragraphs, paragraph) {
161
+		t.Error("Couldnt find paragraph in paragraphs")
162
+	}
163
+}
164
+
165
+func TestBool(t *testing.T) {
166
+	t.Log("TestBool")
167
+	booleanVal := Boolean()
168
+	if booleanVal != true && booleanVal != false {
169
+		t.Error("Bool was wrong format")
170
+	}
171
+}
172
+
173
+func TestState(t *testing.T) {
174
+	t.Log("TestState")
175
+	stateValSmall := State(Small)
176
+	stateValLarge := State(Large)
177
+
178
+	if !findInSlice(jsonData.StatesSmall, stateValSmall) {
179
+		t.Error("Couldnt find small state name in states")
180
+	}
181
+
182
+	if !findInSlice(jsonData.States, stateValLarge) {
183
+		t.Error("Couldnt find state name in states")
184
+	}
185
+
186
+}
187
+
188
+func TestNoun(t *testing.T) {
189
+	if len(jsonData.Nouns) == 0 {
190
+		t.Error("Nouns is empty")
191
+	}
192
+
193
+	noun := Noun()
194
+
195
+	if !findInSlice(jsonData.Nouns, noun) {
196
+		t.Error("Couldnt find noun in json data")
197
+	}
198
+}
199
+
200
+func TestAdjective(t *testing.T) {
201
+	if len(jsonData.Adjectives) == 0 {
202
+		t.Error("Adjectives array is empty")
203
+	}
204
+
205
+	adjective := Adjective()
206
+
207
+	if !findInSlice(jsonData.Adjectives, adjective) {
208
+		t.Error("Couldnt find noun in json data")
209
+	}
210
+}
211
+
212
+func TestSillyName(t *testing.T) {
213
+	sillyName := SillyName()
214
+
215
+	if len(sillyName) == 0 {
216
+		t.Error("Couldnt generate a silly name")
217
+	}
218
+}
219
+
220
+func TestIpV4Address(t *testing.T) {
221
+	ipAddress := IpV4Address()
222
+
223
+	ipBlocks := strings.Split(ipAddress, ".")
224
+
225
+	if len(ipBlocks) < 0 || len(ipBlocks) > 4 {
226
+		t.Error("Invalid generated IP address")
227
+	}
228
+
229
+	for _, blockString := range ipBlocks {
230
+		blockNumber, err := strconv.Atoi(blockString)
231
+
232
+		if err != nil {
233
+			t.Error("Error while testing IpV4Address(): " + err.Error())
234
+		}
235
+
236
+		if blockNumber < 0 || blockNumber > 255 {
237
+			t.Error("Invalid generated IP address")
238
+		}
239
+	}
240
+}
241
+
242
+func TestIpV6Address(t *testing.T) {
243
+	ipAddress := net.ParseIP(IpV6Address())
244
+
245
+	if len(ipAddress) != net.IPv6len {
246
+		t.Errorf("Invalid generated IPv6 address %v", ipAddress)
247
+	}
248
+	roundTripIP := net.ParseIP(ipAddress.String())
249
+	if roundTripIP == nil || !bytes.Equal(ipAddress, roundTripIP) {
250
+		t.Errorf("Invalid generated IPv6 address %v", ipAddress)
251
+	}
252
+}
253
+
254
+func TestMacAddress(t *testing.T) {
255
+	t.Log("MacAddress")
256
+
257
+	mac := MacAddress()
258
+	if len(mac) != 17 {
259
+		t.Errorf("Invalid generated Mac address %v", mac)
260
+	}
261
+
262
+	if !regexp.MustCompile(`([0-9a-fa-f]{2}[:-]){5}([0-9a-fa-f]{2})`).MatchString(mac) {
263
+		t.Errorf("Invalid generated Mac address %v", mac)
264
+	}
265
+}
266
+
267
+func TestDecimal(t *testing.T) {
268
+	d := Decimal(2, 4, 3)
269
+	if !(d >= 2 && d <= 4) {
270
+		t.Error("Invalid generate range")
271
+	}
272
+
273
+	ds := strings.Split(strconv.FormatFloat(d, 'f', 3, 64), ".")
274
+	if len(ds[1]) != 3 {
275
+		t.Error("Invalid floating point")
276
+	}
277
+}
278
+
279
+func TestDay(t *testing.T) {
280
+	t.Log("TestDay")
281
+	day := Day()
282
+
283
+	if !findInSlice(jsonData.Days, day) {
284
+		t.Error("Couldnt find day in days")
285
+	}
286
+}
287
+
288
+func TestMonth(t *testing.T) {
289
+	t.Log("TestMonth")
290
+	month := Month()
291
+
292
+	if !findInSlice(jsonData.Months, month) {
293
+		t.Error("Couldnt find month in months")
294
+	}
295
+}
296
+
297
+func TestFullDate(t *testing.T) {
298
+	t.Log("TestFullDate")
299
+	fulldateOne := FullDate()
300
+	fulldateTwo := FullDate()
301
+
302
+	if fulldateOne == fulldateTwo {
303
+		t.Error("Invalid random full date")
304
+	}
305
+}
306
+
307
+func TestFullDateInRangeNoArgs(t *testing.T) {
308
+	t.Log("TestFullDateInRangeNoArgs")
309
+	fullDate := FullDateInRange()
310
+	_, err := time.Parse(DateOutputLayout, fullDate)
311
+
312
+	if err != nil {
313
+		t.Error("Didn't get valid date format.")
314
+	}
315
+}
316
+
317
+func TestFullDateInRangeOneArg(t *testing.T) {
318
+	t.Log("TestFullDateInRangeOneArg")
319
+	maxDate, _ := time.Parse(DateInputLayout, "2016-12-31")
320
+	for i := 0; i < 100000; i++ {
321
+		fullDate := FullDateInRange("2016-12-31")
322
+		d, err := time.Parse(DateOutputLayout, fullDate)
323
+
324
+		if err != nil {
325
+			t.Error("Didn't get valid date format.")
326
+		}
327
+
328
+		if d.After(maxDate) {
329
+			t.Error("Random date didn't match specified max date.")
330
+		}
331
+	}
332
+}
333
+
334
+func TestFullDateInRangeTwoArgs(t *testing.T) {
335
+	t.Log("TestFullDateInRangeTwoArgs")
336
+	minDate, _ := time.Parse(DateInputLayout, "2016-01-01")
337
+	maxDate, _ := time.Parse(DateInputLayout, "2016-12-31")
338
+	for i := 0; i < 100000; i++ {
339
+		fullDate := FullDateInRange("2016-01-01", "2016-12-31")
340
+		d, err := time.Parse(DateOutputLayout, fullDate)
341
+
342
+		if err != nil {
343
+			t.Error("Didn't get valid date format.")
344
+		}
345
+
346
+		if d.After(maxDate) {
347
+			t.Error("Random date didn't match specified max date.")
348
+		}
349
+
350
+		if d.Before(minDate) {
351
+			t.Error("Random date didn't match specified min date.")
352
+		}
353
+	}
354
+}
355
+
356
+func TestFullDateInRangeSwappedArgs(t *testing.T) {
357
+	t.Log("TestFullDateInRangeSwappedArgs")
358
+	wrongMaxDate, _ := time.Parse(DateInputLayout, "2016-01-01")
359
+	fullDate := FullDateInRange("2016-12-31", "2016-01-01")
360
+	d, err := time.Parse(DateOutputLayout, fullDate)
361
+
362
+	if err != nil {
363
+		t.Error("Didn't get valid date format.")
364
+	}
365
+
366
+	if d != wrongMaxDate {
367
+		t.Error("Didn't return min date.")
368
+	}
369
+}
370
+
371
+func TestTimezone(t *testing.T) {
372
+	t.Log("TestTimezone")
373
+	timezone := Timezone()
374
+
375
+	if !findInSlice(jsonData.Timezones, timezone) {
376
+		t.Errorf("Couldnt find timezone in timezones: %v", timezone)
377
+	}
378
+}
379
+
380
+func findInSlice(source []string, toFind string) bool {
381
+	for _, text := range source {
382
+		if text == toFind {
383
+			return true
384
+		}
385
+	}
386
+	return false
387
+}

+ 33 - 3
vendor/github.com/emicklei/go-restful-openapi/build_path.go

@@ -1,7 +1,10 @@
1 1
 package restfulspec
2 2
 
3 3
 import (
4
+	"net/http"
4 5
 	"reflect"
6
+	"regexp"
7
+	"strconv"
5 8
 	"strings"
6 9
 
7 10
 	restful "github.com/emicklei/go-restful"
@@ -47,9 +50,9 @@ func buildPathItem(ws *restful.WebService, r restful.Route, existingPathItem spe
47 50
 func buildOperation(ws *restful.WebService, r restful.Route, cfg Config) *spec.Operation {
48 51
 	o := spec.NewOperation(r.Operation)
49 52
 	o.Description = r.Doc
50
-	// take the first line to be the summary
53
+	// take the first line (stripping HTML tags) to be the summary
51 54
 	if lines := strings.Split(r.Doc, "\n"); len(lines) > 0 {
52
-		o.Summary = lines[0]
55
+		o.Summary = stripTags(lines[0])
53 56
 	}
54 57
 	o.Consumes = r.Consumes
55 58
 	o.Produces = r.Produces
@@ -78,9 +81,27 @@ func buildOperation(ws *restful.WebService, r restful.Route, cfg Config) *spec.O
78 81
 			o.Responses.Default = &r
79 82
 		}
80 83
 	}
84
+	if len(o.Responses.StatusCodeResponses) == 0 {
85
+		o.Responses.StatusCodeResponses[200] = spec.Response{ResponseProps: spec.ResponseProps{Description: http.StatusText(http.StatusOK)}}
86
+	}
81 87
 	return o
82 88
 }
83 89
 
90
+// stringAutoType automatically picks the correct type from an ambiguously typed
91
+// string. Ex. numbers become int, true/false become bool, etc.
92
+func stringAutoType(ambiguous string) interface{} {
93
+	if ambiguous == "" {
94
+		return nil
95
+	}
96
+	if parsedInt, err := strconv.ParseInt(ambiguous, 10, 64); err == nil {
97
+		return parsedInt
98
+	}
99
+	if parsedBool, err := strconv.ParseBool(ambiguous); err == nil {
100
+		return parsedBool
101
+	}
102
+	return ambiguous
103
+}
104
+
84 105
 func buildParameter(r restful.Route, restfulParam *restful.Parameter, cfg Config) spec.Parameter {
85 106
 	p := spec.Parameter{}
86 107
 	param := restfulParam.Data()
@@ -89,11 +110,13 @@ func buildParameter(r restful.Route, restfulParam *restful.Parameter, cfg Config
89 110
 	p.Description = param.Description
90 111
 	p.Name = param.Name
91 112
 	p.Required = param.Required
92
-	p.Default = param.DefaultValue
113
+	p.Default = stringAutoType(param.DefaultValue)
93 114
 	p.Format = param.DataFormat
115
+
94 116
 	if p.In == "body" && r.ReadSample != nil && p.Type == reflect.TypeOf(r.ReadSample).String() {
95 117
 		p.Schema = new(spec.Schema)
96 118
 		p.Schema.Ref = spec.MustCreateRef("#/definitions/" + p.Type)
119
+		p.SimpleSchema = spec.SimpleSchema{}
97 120
 	}
98 121
 	return p
99 122
 }
@@ -122,3 +145,10 @@ func buildResponse(e restful.ResponseError, cfg Config) (r spec.Response) {
122 145
 	}
123 146
 	return r
124 147
 }
148
+
149
+// stripTags takes a snippet of HTML and returns only the text content.
150
+// For example, `<b>&lt;Hi!&gt;</b> <br>` -> `&lt;Hi!&gt; `.
151
+func stripTags(html string) string {
152
+	re := regexp.MustCompile("<[^>]*>")
153
+	return re.ReplaceAllString(html, "")
154
+}

+ 7 - 2
vendor/github.com/emicklei/go-restful-openapi/build_path_test.go

@@ -7,13 +7,15 @@ import (
7 7
 )
8 8
 
9 9
 func TestRouteToPath(t *testing.T) {
10
+	description := "get the <strong>a</strong> <em>b</em> test\nthis is the test description"
11
+
10 12
 	ws := new(restful.WebService)
11 13
 	ws.Path("/tests/{v}")
12 14
 	ws.Param(ws.PathParameter("v", "value of v").DefaultValue("default-v"))
13 15
 	ws.Consumes(restful.MIME_JSON)
14 16
 	ws.Produces(restful.MIME_XML)
15 17
 	ws.Route(ws.GET("/a/{b}").To(dummy).
16
-		Doc("get the a b test").
18
+		Doc(description).
17 19
 		Param(ws.PathParameter("b", "value of b").DefaultValue("default-b")).
18 20
 		Param(ws.QueryParameter("q", "value of q").DefaultValue("default-q")).
19 21
 		Returns(200, "list of a b tests", []Sample{}).
@@ -22,9 +24,12 @@ func TestRouteToPath(t *testing.T) {
22 24
 	p := buildPaths(ws, Config{})
23 25
 	t.Log(asJSON(p))
24 26
 
25
-	if p.Paths["/tests/{v}/a/{b}"].Get.Description != "get the a b test" {
27
+	if p.Paths["/tests/{v}/a/{b}"].Get.Description != description {
26 28
 		t.Errorf("GET description incorrect")
27 29
 	}
30
+	if p.Paths["/tests/{v}/a/{b}"].Get.Summary != "get the a b test" {
31
+		t.Errorf("GET summary incorrect")
32
+	}
28 33
 	response := p.Paths["/tests/{v}/a/{b}"].Get.Responses.StatusCodeResponses[200]
29 34
 	if response.Schema.Type[0] != "array" {
30 35
 		t.Errorf("response type incorrect")

+ 4 - 3
vendor/github.com/emicklei/go-restful-openapi/examples/user-resource.go

@@ -33,7 +33,7 @@ func (u UserResource) WebService() *restful.WebService {
33 33
 	ws.Route(ws.GET("/{user-id}").To(u.findUser).
34 34
 		// docs
35 35
 		Doc("get a user").
36
-		Param(ws.PathParameter("user-id", "identifier of the user").DataType("string")).
36
+		Param(ws.PathParameter("user-id", "identifier of the user").DataType("integer").DefaultValue("1")).
37 37
 		Metadata(restfulspec.KeyOpenAPITags, tags).
38 38
 		Writes(User{}). // on the response
39 39
 		Returns(200, "OK", User{}).
@@ -132,7 +132,7 @@ func main() {
132 132
 	// Optionally, you can install the Swagger Service which provides a nice Web UI on your REST API
133 133
 	// You need to download the Swagger HTML5 assets and change the FilePath location in the config below.
134 134
 	// Open http://localhost:8080/apidocs/?url=http://localhost:8080/apidocs.json
135
-	http.Handle("/apidocs/", http.StripPrefix("/apidocs/", http.FileServer(http.Dir("/Users/emicklei/xProjects/swagger-ui/dist"))))
135
+	http.Handle("/apidocs/", http.StripPrefix("/apidocs/", http.FileServer(http.Dir("/home/v/Downloads/swagger-ui"))))
136 136
 
137 137
 	log.Printf("start listening on localhost:8080")
138 138
 	log.Fatal(http.ListenAndServe(":8080", nil))
@@ -163,5 +163,6 @@ func enrichSwaggerObject(swo *spec.Swagger) {
163 163
 // User is just a sample type
164 164
 type User struct {
165 165
 	ID   string `json:"id" description:"identifier of the user"`
166
-	Name string `json:"name" description:"name of the user"`
166
+	Name string `json:"name" description:"name of the user" default:"john"`
167
+	Age  int    `json:"age" description:"age of the user" default:"21"`
167 168
 }

+ 1 - 1
vendor/github.com/emicklei/go-restful-openapi/lookup.go

@@ -13,7 +13,7 @@ func asParamType(kind int) string {
13 13
 	case kind == restful.HeaderParameterKind:
14 14
 		return "header"
15 15
 	case kind == restful.FormParameterKind:
16
-		return "form"
16
+		return "formData"
17 17
 	}
18 18
 	return ""
19 19
 }

+ 1 - 1
vendor/github.com/emicklei/go-restful-openapi/property_ext.go

@@ -16,7 +16,7 @@ func setDescription(prop *spec.Schema, field reflect.StructField) {
16 16
 
17 17
 func setDefaultValue(prop *spec.Schema, field reflect.StructField) {
18 18
 	if tag := field.Tag.Get("default"); tag != "" {
19
-		prop.Default = tag
19
+		prop.Default = stringAutoType(tag)
20 20
 	}
21 21
 }
22 22
 

+ 2 - 1
vendor/github.com/emicklei/go-restful/README.md

@@ -67,8 +67,9 @@ func (u UserResource) findUser(request *restful.Request, response *restful.Respo
67 67
 - [Example posted on blog](http://ernestmicklei.com/2012/11/go-restful-first-working-example/)
68 68
 - [Design explained on blog](http://ernestmicklei.com/2012/11/go-restful-api-design/)
69 69
 - [sourcegraph](https://sourcegraph.com/github.com/emicklei/go-restful)
70
+- [showcase: Zazkia - tcp proxy for testing resiliency](https://github.com/emicklei/zazkia)
70 71
 - [showcase: Mora - MongoDB REST Api server](https://github.com/emicklei/mora)
71 72
 
72 73
 Type ```git shortlog -s``` for a full list of contributors.
73 74
 
74
-© 2012 - 2017, http://ernestmicklei.com. MIT License. Contributions are welcome.
75
+© 2012 - 2017, http://ernestmicklei.com. MIT License. Contributions are welcome.

+ 4 - 4
vendor/github.com/emicklei/go-restful/compressors.go

@@ -15,20 +15,20 @@ type CompressorProvider interface {
15 15
 	// Before using it, call Reset().
16 16
 	AcquireGzipWriter() *gzip.Writer
17 17
 
18
-	// Releases an aqcuired *gzip.Writer.
18
+	// Releases an acquired *gzip.Writer.
19 19
 	ReleaseGzipWriter(w *gzip.Writer)
20 20
 
21 21
 	// Returns a *gzip.Reader which needs to be released later.
22 22
 	AcquireGzipReader() *gzip.Reader
23 23
 
24
-	// Releases an aqcuired *gzip.Reader.
24
+	// Releases an acquired *gzip.Reader.
25 25
 	ReleaseGzipReader(w *gzip.Reader)
26 26
 
27 27
 	// Returns a *zlib.Writer which needs to be released later.
28 28
 	// Before using it, call Reset().
29 29
 	AcquireZlibWriter() *zlib.Writer
30 30
 
31
-	// Releases an aqcuired *zlib.Writer.
31
+	// Releases an acquired *zlib.Writer.
32 32
 	ReleaseZlibWriter(w *zlib.Writer)
33 33
 }
34 34
 
@@ -45,7 +45,7 @@ func CurrentCompressorProvider() CompressorProvider {
45 45
 	return currentCompressorProvider
46 46
 }
47 47
 
48
-// CompressorProvider sets the actual provider of compressors (zlib or gzip).
48
+// SetCompressorProvider sets the actual provider of compressors (zlib or gzip).
49 49
 func SetCompressorProvider(p CompressorProvider) {
50 50
 	if p == nil {
51 51
 		panic("cannot set compressor provider to nil")

+ 3 - 3
vendor/github.com/emicklei/go-restful/container.go

@@ -32,7 +32,7 @@ type Container struct {
32 32
 	contentEncodingEnabled bool          // default is false
33 33
 }
34 34
 
35
-// NewContainer creates a new Container using a new ServeMux and default router (RouterJSR311)
35
+// NewContainer creates a new Container using a new ServeMux and default router (CurlyRouter)
36 36
 func NewContainer() *Container {
37 37
 	return &Container{
38 38
 		webServices:            []*WebService{},
@@ -74,7 +74,7 @@ func (c *Container) DoNotRecover(doNot bool) {
74 74
 	c.doNotRecover = doNot
75 75
 }
76 76
 
77
-// Router changes the default Router (currently RouterJSR311)
77
+// Router changes the default Router (currently CurlyRouter)
78 78
 func (c *Container) Router(aRouter RouteSelector) {
79 79
 	c.router = aRouter
80 80
 }
@@ -140,7 +140,7 @@ func (c *Container) addHandler(service *WebService, serveMux *http.ServeMux) boo
140 140
 func (c *Container) Remove(ws *WebService) error {
141 141
 	if c.ServeMux == http.DefaultServeMux {
142 142
 		errMsg := fmt.Sprintf("[restful] cannot remove a WebService from a Container using the DefaultServeMux: ['%v']", ws)
143
-		log.Printf(errMsg)
143
+		log.Print(errMsg)
144 144
 		return errors.New(errMsg)
145 145
 	}
146 146
 	c.webServicesLock.Lock()

+ 1 - 1
vendor/github.com/emicklei/go-restful/examples/google_app_engine/datastore/main.go

@@ -54,7 +54,7 @@ func init() {
54 54
 		WebServicesUrl: gaeUrl(),
55 55
 		ApiPath:        "/apidocs.json",
56 56
 
57
-		// Optionally, specifiy where the UI is located
57
+		// Optionally, specify where the UI is located
58 58
 		SwaggerPath: "/apidocs/",
59 59
 
60 60
 		// GAE support static content which is configured in your app.yaml.

+ 1 - 1
vendor/github.com/emicklei/go-restful/examples/google_app_engine/restful-user-service.go

@@ -153,7 +153,7 @@ func init() {
153 153
 		WebServicesUrl: getGaeURL(),
154 154
 		ApiPath:        "/apidocs.json",
155 155
 
156
-		// Optionally, specifiy where the UI is located
156
+		// Optionally, specify where the UI is located
157 157
 		SwaggerPath: "/apidocs/",
158 158
 		// GAE support static content which is configured in your app.yaml.
159 159
 		// This example expect the swagger-ui in static/swagger so you should place it there :)

+ 1 - 1
vendor/github.com/emicklei/go-restful/examples/msgpack/msgpack_entity_test.go

@@ -103,7 +103,7 @@ func runRestfulMsgPackRouterServer() {
103 103
 	container := restful.NewContainer()
104 104
 	register(container)
105 105
 
106
-	log.Printf("start listening on localhost:8090")
106
+	log.Print("start listening on localhost:8090")
107 107
 	server := &http.Server{Addr: ":8090", Handler: container}
108 108
 	log.Fatal(server.ListenAndServe())
109 109
 }

+ 1 - 1
vendor/github.com/emicklei/go-restful/examples/restful-CORS-filter.go

@@ -62,7 +62,7 @@ func main() {
62 62
 	// Add container filter to respond to OPTIONS
63 63
 	wsContainer.Filter(wsContainer.OPTIONSFilter)
64 64
 
65
-	log.Printf("start listening on localhost:8080")
65
+	log.Print("start listening on localhost:8080")
66 66
 	server := &http.Server{Addr: ":8080", Handler: wsContainer}
67 67
 	log.Fatal(server.ListenAndServe())
68 68
 }

+ 1 - 1
vendor/github.com/emicklei/go-restful/examples/restful-NCSA-logging.go

@@ -46,7 +46,7 @@ func main() {
46 46
 	ws.Filter(NCSACommonLogFormatLogger())
47 47
 	ws.Route(ws.GET("/ping").To(hello))
48 48
 	restful.Add(ws)
49
-	http.ListenAndServe(":8080", nil)
49
+	log.Fatal(http.ListenAndServe(":8080", nil))
50 50
 }
51 51
 
52 52
 func hello(req *restful.Request, resp *restful.Response) {

+ 4 - 4
vendor/github.com/emicklei/go-restful/examples/restful-basic-authentication.go

@@ -3,6 +3,7 @@ package main
3 3
 import (
4 4
 	"github.com/emicklei/go-restful"
5 5
 	"io"
6
+	"log"
6 7
 	"net/http"
7 8
 )
8 9
 
@@ -15,14 +16,13 @@ func main() {
15 16
 	ws := new(restful.WebService)
16 17
 	ws.Route(ws.GET("/secret").Filter(basicAuthenticate).To(secret))
17 18
 	restful.Add(ws)
18
-	http.ListenAndServe(":8080", nil)
19
+	log.Fatal(http.ListenAndServe(":8080", nil))
19 20
 }
20 21
 
21 22
 func basicAuthenticate(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {
22
-	encoded := req.Request.Header.Get("Authorization")
23 23
 	// usr/pwd = admin/admin
24
-	// real code does some decoding
25
-	if len(encoded) == 0 || "Basic YWRtaW46YWRtaW4=" != encoded {
24
+	u, p, ok := req.Request.BasicAuth()
25
+	if !ok || u != "admin" || p != "admin" {
26 26
 		resp.AddHeader("WWW-Authenticate", "Basic realm=Protected Area")
27 27
 		resp.WriteErrorString(401, "401: Not Authorized")
28 28
 		return

+ 1 - 1
vendor/github.com/emicklei/go-restful/examples/restful-curly-router.go

@@ -101,7 +101,7 @@ func main() {
101 101
 	u := UserResource{map[string]User{}}
102 102
 	u.Register(wsContainer)
103 103
 
104
-	log.Printf("start listening on localhost:8080")
104
+	log.Print("start listening on localhost:8080")
105 105
 	server := &http.Server{Addr: ":8080", Handler: wsContainer}
106 106
 	log.Fatal(server.ListenAndServe())
107 107
 }

+ 1 - 1
vendor/github.com/emicklei/go-restful/examples/restful-curly-router_test.go

@@ -91,7 +91,7 @@ func RunRestfulCurlyRouterServer() {
91 91
 	u := UserResource{map[string]User{}}
92 92
 	u.Register(wsContainer)
93 93
 
94
-	log.Printf("start listening on localhost:8090")
94
+	log.Print("start listening on localhost:8090")
95 95
 	server := &http.Server{Addr: ":8090", Handler: wsContainer}
96 96
 	log.Fatal(server.ListenAndServe())
97 97
 }

+ 2 - 2
vendor/github.com/emicklei/go-restful/examples/restful-encoding-filter.go

@@ -25,7 +25,7 @@ type UserList struct {
25 25
 
26 26
 func main() {
27 27
 	restful.Add(NewUserService())
28
-	log.Printf("start listening on localhost:8080")
28
+	log.Print("start listening on localhost:8080")
29 29
 	log.Fatal(http.ListenAndServe(":8080", nil))
30 30
 }
31 31
 
@@ -56,6 +56,6 @@ func encodingFilter(req *restful.Request, resp *restful.Response, chain *restful
56 56
 // GET http://localhost:8080/users/42
57 57
 //
58 58
 func findUser(request *restful.Request, response *restful.Response) {
59
-	log.Printf("findUser")
59
+	log.Print("findUser")
60 60
 	response.WriteEntity(User{"42", "Gandalf"})
61 61
 }

+ 3 - 3
vendor/github.com/emicklei/go-restful/examples/restful-filters.go

@@ -26,7 +26,7 @@ func main() {
26 26
 	restful.Filter(globalLogging)
27 27
 
28 28
 	restful.Add(NewUserService())
29
-	log.Printf("start listening on localhost:8080")
29
+	log.Print("start listening on localhost:8080")
30 30
 	log.Fatal(http.ListenAndServe(":8080", nil))
31 31
 }
32 32
 
@@ -102,13 +102,13 @@ func (c *CountFilter) routeCounter(req *restful.Request, resp *restful.Response,
102 102
 // GET http://localhost:8080/users
103 103
 //
104 104
 func getAllUsers(request *restful.Request, response *restful.Response) {
105
-	log.Printf("getAllUsers")
105
+	log.Print("getAllUsers")
106 106
 	response.WriteEntity(UserList{[]User{{"42", "Gandalf"}, {"3.14", "Pi"}}})
107 107
 }
108 108
 
109 109
 // GET http://localhost:8080/users/42
110 110
 //
111 111
 func findUser(request *restful.Request, response *restful.Response) {
112
-	log.Printf("findUser")
112
+	log.Print("findUser")
113 113
 	response.WriteEntity(User{"42", "Gandalf"})
114 114
 }

+ 2 - 1
vendor/github.com/emicklei/go-restful/examples/restful-form-handling.go

@@ -5,6 +5,7 @@ import (
5 5
 	"github.com/emicklei/go-restful"
6 6
 	"github.com/gorilla/schema"
7 7
 	"io"
8
+	"log"
8 9
 	"net/http"
9 10
 )
10 11
 
@@ -27,7 +28,7 @@ func main() {
27 28
 	ws.Route(ws.POST("/profiles").Consumes("application/x-www-form-urlencoded").To(postAdddress))
28 29
 	ws.Route(ws.GET("/profiles").To(addresssForm))
29 30
 	restful.Add(ws)
30
-	http.ListenAndServe(":8080", nil)
31
+	log.Fatal(http.ListenAndServe(":8080", nil))
31 32
 }
32 33
 
33 34
 func postAdddress(req *restful.Request, resp *restful.Response) {

+ 2 - 1
vendor/github.com/emicklei/go-restful/examples/restful-hello-world.go

@@ -3,6 +3,7 @@ package main
3 3
 import (
4 4
 	"github.com/emicklei/go-restful"
5 5
 	"io"
6
+	"log"
6 7
 	"net/http"
7 8
 )
8 9
 
@@ -14,7 +15,7 @@ func main() {
14 15
 	ws := new(restful.WebService)
15 16
 	ws.Route(ws.GET("/hello").To(hello))
16 17
 	restful.Add(ws)
17
-	http.ListenAndServe(":8080", nil)
18
+	log.Fatal(http.ListenAndServe(":8080", nil))
18 19
 }
19 20
 
20 21
 func hello(req *restful.Request, resp *restful.Response) {

+ 1 - 1
vendor/github.com/emicklei/go-restful/examples/restful-html-template.go

@@ -17,7 +17,7 @@ func main() {
17 17
 	ws.Route(ws.GET("/").To(home))
18 18
 	restful.Add(ws)
19 19
 	print("open browser on http://localhost:8080/\n")
20
-	http.ListenAndServe(":8080", nil)
20
+	log.Fatal(http.ListenAndServe(":8080", nil))
21 21
 }
22 22
 
23 23
 type Message struct {

+ 1 - 1
vendor/github.com/emicklei/go-restful/examples/restful-multi-containers.go

@@ -23,7 +23,7 @@ func main() {
23 23
 	ws.Route(ws.GET("/hello").To(hello))
24 24
 	restful.Add(ws)
25 25
 	go func() {
26
-		http.ListenAndServe(":8080", nil)
26
+		log.Fatal(http.ListenAndServe(":8080", nil))
27 27
 	}()
28 28
 
29 29
 	container2 := restful.NewContainer()

+ 2 - 1
vendor/github.com/emicklei/go-restful/examples/restful-no-cache-filter.go

@@ -2,6 +2,7 @@ package main
2 2
 
3 3
 import (
4 4
 	"io"
5
+	"log"
5 6
 	"net/http"
6 7
 
7 8
 	"github.com/emicklei/go-restful"
@@ -16,7 +17,7 @@ func main() {
16 17
 	ws.Filter(restful.NoBrowserCacheFilter)
17 18
 	ws.Route(ws.GET("/hello").To(hello))
18 19
 	restful.Add(ws)
19
-	http.ListenAndServe(":8080", nil)
20
+	log.Fatal(http.ListenAndServe(":8080", nil))
20 21
 }
21 22
 
22 23
 func hello(req *restful.Request, resp *restful.Response) {

+ 1 - 1
vendor/github.com/emicklei/go-restful/examples/restful-options-filter.go

@@ -45,7 +45,7 @@ func main() {
45 45
 	// For use on the default container, you can write
46 46
 	// restful.Filter(restful.OPTIONSFilter())
47 47
 
48
-	log.Printf("start listening on localhost:8080")
48
+	log.Print("start listening on localhost:8080")
49 49
 	server := &http.Server{Addr: ":8080", Handler: wsContainer}
50 50
 	log.Fatal(server.ListenAndServe())
51 51
 }

+ 3 - 2
vendor/github.com/emicklei/go-restful/examples/restful-path-tail.go

@@ -3,10 +3,11 @@ package main
3 3
 import (
4 4
 	. "github.com/emicklei/go-restful"
5 5
 	"io"
6
+	"log"
6 7
 	"net/http"
7 8
 )
8 9
 
9
-// This example shows how to a Route that matches the "tail" of a path.
10
+// This example shows how to create a Route matching the "tail" of a path.
10 11
 // Requires the use of a CurlyRouter and the star "*" path parameter pattern.
11 12
 //
12 13
 // GET http://localhost:8080/basepath/some/other/location/test.xml
@@ -18,7 +19,7 @@ func main() {
18 19
 	Add(ws)
19 20
 
20 21
 	println("[go-restful] serve path tails from http://localhost:8080/basepath")
21
-	http.ListenAndServe(":8080", nil)
22
+	log.Fatal(http.ListenAndServe(":8080", nil))
22 23
 }
23 24
 
24 25
 func staticFromPathParam(req *Request, resp *Response) {

+ 1 - 1
vendor/github.com/emicklei/go-restful/examples/restful-resource-functions.go

@@ -59,5 +59,5 @@ func (p ProductResource) Register() {
59 59
 
60 60
 func main() {
61 61
 	ProductResource{}.Register()
62
-	http.ListenAndServe(":8080", nil)
62
+	log.Fatal(http.ListenAndServe(":8080", nil))
63 63
 }

+ 1 - 1
vendor/github.com/emicklei/go-restful/examples/restful-serve-static.go

@@ -27,7 +27,7 @@ func main() {
27 27
 	restful.Add(ws)
28 28
 
29 29
 	println("[go-restful] serving files on http://localhost:8080/static from local /tmp")
30
-	http.ListenAndServe(":8080", nil)
30
+	log.Fatal(http.ListenAndServe(":8080", nil))
31 31
 }
32 32
 
33 33
 func staticFromPathParam(req *restful.Request, resp *restful.Response) {

+ 2 - 2
vendor/github.com/emicklei/go-restful/examples/restful-swagger.go

@@ -40,12 +40,12 @@ func main() {
40 40
 		WebServicesUrl: "http://localhost:8080",
41 41
 		ApiPath:        "/apidocs.json",
42 42
 
43
-		// Optionally, specifiy where the UI is located
43
+		// Optionally, specify where the UI is located
44 44
 		SwaggerPath:     "/apidocs/",
45 45
 		SwaggerFilePath: "/Users/emicklei/xProjects/swagger-ui/dist"}
46 46
 	swagger.RegisterSwaggerService(config, restful.DefaultContainer)
47 47
 
48
-	log.Printf("start listening on localhost:8080")
48
+	log.Print("start listening on localhost:8080")
49 49
 	server := &http.Server{Addr: ":8080", Handler: restful.DefaultContainer}
50 50
 	log.Fatal(server.ListenAndServe())
51 51
 }

+ 2 - 2
vendor/github.com/emicklei/go-restful/examples/restful-user-resource.go

@@ -141,12 +141,12 @@ func main() {
141 141
 		WebServicesUrl: "http://localhost:8080",
142 142
 		ApiPath:        "/apidocs.json",
143 143
 
144
-		// Optionally, specifiy where the UI is located
144
+		// Optionally, specify where the UI is located
145 145
 		SwaggerPath:     "/apidocs/",
146 146
 		SwaggerFilePath: "/Users/emicklei/xProjects/swagger-ui/dist"}
147 147
 	swagger.RegisterSwaggerService(config, wsContainer)
148 148
 
149
-	log.Printf("start listening on localhost:8080")
149
+	log.Print("start listening on localhost:8080")
150 150
 	server := &http.Server{Addr: ":8080", Handler: wsContainer}
151 151
 	log.Fatal(server.ListenAndServe())
152 152
 }

+ 2 - 2
vendor/github.com/emicklei/go-restful/examples/restful-user-service.go

@@ -133,11 +133,11 @@ func main() {
133 133
 		WebServicesUrl: "http://localhost:8080",
134 134
 		ApiPath:        "/apidocs.json",
135 135
 
136
-		// Optionally, specifiy where the UI is located
136
+		// Optionally, specify where the UI is located
137 137
 		SwaggerPath:     "/apidocs/",
138 138
 		SwaggerFilePath: "/Users/emicklei/Projects/swagger-ui/dist"}
139 139
 	swagger.InstallSwaggerService(config)
140 140
 
141
-	log.Printf("start listening on localhost:8080")
141
+	log.Print("start listening on localhost:8080")
142 142
 	log.Fatal(http.ListenAndServe(":8080", nil))
143 143
 }

+ 1 - 1
vendor/github.com/emicklei/go-restful/logger.go

@@ -21,7 +21,7 @@ func TraceLogger(logger log.StdLogger) {
21 21
 	EnableTracing(logger != nil)
22 22
 }
23 23
 
24
-// expose the setter for the global logger on the top-level package
24
+// SetLogger exposes the setter for the global logger on the top-level package
25 25
 func SetLogger(customLogger log.StdLogger) {
26 26
 	log.SetLogger(customLogger)
27 27
 }

+ 1 - 1
vendor/github.com/emicklei/go-restful/response.go

@@ -21,7 +21,7 @@ type Response struct {
21 21
 	http.ResponseWriter
22 22
 	requestAccept string   // mime-type what the Http Request says it wants to receive
23 23
 	routeProduces []string // mime-types what the Route says it can produce
24
-	statusCode    int      // HTTP status code that has been written explicity (if zero then net/http has written 200)
24
+	statusCode    int      // HTTP status code that has been written explicitly (if zero then net/http has written 200)
25 25
 	contentLength int      // number of bytes written for the response body
26 26
 	prettyPrint   bool     // controls the indentation feature of XML and JSON serialization. It is initialized using var PrettyPrintResponses.
27 27
 	err           error    // err property is kept when WriteError is called

+ 1 - 1
vendor/github.com/emicklei/go-restful/route.go

@@ -100,7 +100,7 @@ func (r Route) matchesContentType(mimeTypes string) bool {
100 100
 	}
101 101
 
102 102
 	if len(mimeTypes) == 0 {
103
-		// idempotent methods with (most-likely or garanteed) empty content match missing Content-Type
103
+		// idempotent methods with (most-likely or guaranteed) empty content match missing Content-Type
104 104
 		m := r.Method
105 105
 		if m == "GET" || m == "HEAD" || m == "OPTIONS" || m == "DELETE" || m == "TRACE" {
106 106
 			return true

+ 26 - 7
vendor/github.com/emicklei/go-restful/route_builder.go

@@ -89,7 +89,7 @@ func (b *RouteBuilder) Doc(documentation string) *RouteBuilder {
89 89
 	return b
90 90
 }
91 91
 
92
-// A verbose explanation of the operation behavior. Optional.
92
+// Notes is a verbose explanation of the operation behavior. Optional.
93 93
 func (b *RouteBuilder) Notes(notes string) *RouteBuilder {
94 94
 	b.notes = notes
95 95
 	return b
@@ -156,9 +156,10 @@ func (b *RouteBuilder) ReturnsError(code int, message string, model interface{})
156 156
 // The model parameter is optional ; either pass a struct instance or use nil if not applicable.
157 157
 func (b *RouteBuilder) Returns(code int, message string, model interface{}) *RouteBuilder {
158 158
 	err := ResponseError{
159
-		Code:    code,
160
-		Message: message,
161
-		Model:   model,
159
+		Code:      code,
160
+		Message:   message,
161
+		Model:     model,
162
+		IsDefault: false,
162 163
 	}
163 164
 	// lazy init because there is no NewRouteBuilder (yet)
164 165
 	if b.errorMap == nil {
@@ -168,6 +169,22 @@ func (b *RouteBuilder) Returns(code int, message string, model interface{}) *Rou
168 169
 	return b
169 170
 }
170 171
 
172
+// DefaultReturns is a special Returns call that sets the default of the response ; the code is zero.
173
+func (b *RouteBuilder) DefaultReturns(message string, model interface{}) *RouteBuilder {
174
+	b.Returns(0, message, model)
175
+	// Modify the ResponseError just added/updated
176
+	re := b.errorMap[0]
177
+	// errorMap is initialized
178
+	b.errorMap[0] = ResponseError{
179
+		Code:      re.Code,
180
+		Message:   re.Message,
181
+		Model:     re.Model,
182
+		IsDefault: true,
183
+	}
184
+	return b
185
+}
186
+
187
+// Metadata adds or updates a key=value pair to the metadata map.
171 188
 func (b *RouteBuilder) Metadata(key string, value interface{}) *RouteBuilder {
172 189
 	if b.metadata == nil {
173 190
 		b.metadata = map[string]interface{}{}
@@ -176,10 +193,12 @@ func (b *RouteBuilder) Metadata(key string, value interface{}) *RouteBuilder {
176 193
 	return b
177 194
 }
178 195
 
196
+// ResponseError represents a response; not necessarily an error.
179 197
 type ResponseError struct {
180
-	Code    int
181
-	Message string
182
-	Model   interface{}
198
+	Code      int
199
+	Message   string
200
+	Model     interface{}
201
+	IsDefault bool
183 202
 }
184 203
 
185 204
 func (b *RouteBuilder) servicePath(path string) *RouteBuilder {

+ 5 - 1
vendor/github.com/emicklei/go-restful/route_builder_test.go

@@ -2,6 +2,7 @@ package restful
2 2
 
3 3
 import (
4 4
 	"testing"
5
+	"time"
5 6
 )
6 7
 
7 8
 func TestRouteBuilder_PathParameter(t *testing.T) {
@@ -41,7 +42,7 @@ func TestRouteBuilder(t *testing.T) {
41 42
 	json := "application/json"
42 43
 	b := new(RouteBuilder)
43 44
 	b.To(dummy)
44
-	b.Path("/routes").Method("HEAD").Consumes(json).Produces(json).Metadata("test", "test-value")
45
+	b.Path("/routes").Method("HEAD").Consumes(json).Produces(json).Metadata("test", "test-value").DefaultReturns("default", time.Now())
45 46
 	r := b.Build()
46 47
 	if r.Path != "/routes" {
47 48
 		t.Error("path invalid")
@@ -58,6 +59,9 @@ func TestRouteBuilder(t *testing.T) {
58 59
 	if r.Metadata["test"] != "test-value" {
59 60
 		t.Errorf("Metadata not set")
60 61
 	}
62
+	if _, ok := r.ResponseErrors[0]; !ok {
63
+		t.Fatal("expected default response")
64
+	}
61 65
 }
62 66
 
63 67
 func TestAnonymousFuncNaming(t *testing.T) {

+ 1 - 1
vendor/github.com/emicklei/go-restful/web_service.go

@@ -233,7 +233,7 @@ func (w *WebService) RootPath() string {
233 233
 	return w.rootPath
234 234
 }
235 235
 
236
-// PathParameters return the path parameter names for (shared amoung its Routes)
236
+// PathParameters return the path parameter names for (shared among its Routes)
237 237
 func (w *WebService) PathParameters() []*Parameter {
238 238
 	return w.pathParameters
239 239
 }

+ 1 - 9
vendor/github.com/go-openapi/spec/ref.go

@@ -125,20 +125,12 @@ func MustCreateRef(refURI string) Ref {
125 125
 	return Ref{Ref: jsonreference.MustCreateRef(refURI)}
126 126
 }
127 127
 
128
-// // NewResolvedRef creates a resolved ref
129
-// func NewResolvedRef(refURI string, data interface{}) Ref {
130
-// 	return Ref{
131
-// 		Ref:      jsonreference.MustCreateRef(refURI),
132
-// 		Resolved: data,
133
-// 	}
134
-// }
135
-
136 128
 // MarshalJSON marshals this ref into a JSON object
137 129
 func (r Ref) MarshalJSON() ([]byte, error) {
138 130
 	str := r.String()
139 131
 	if str == "" {
140 132
 		if r.IsRoot() {
141
-			return []byte(`{"$ref":"#"}`), nil
133
+			return []byte(`{"$ref":""}`), nil
142 134
 		}
143 135
 		return []byte("{}"), nil
144 136
 	}