@@ -25,6 +25,13 @@ var gitRefNameValidationTestCases = []validationTestCase{
2525 },
2626 expectedErrors : binding.Errors {},
2727 },
28+ {
29+ description : "Reference name has allowed special characters" ,
30+ data : TestForm {
31+ BranchName : "debian/1%1.6.0-2" ,
32+ },
33+ expectedErrors : binding.Errors {},
34+ },
2835 {
2936 description : "Reference name contains backslash" ,
3037 data : TestForm {
@@ -129,6 +136,123 @@ var gitRefNameValidationTestCases = []validationTestCase{
129136 },
130137 },
131138 },
139+ {
140+ description : "Reference name is single @" ,
141+ data : TestForm {
142+ BranchName : "@" ,
143+ },
144+ expectedErrors : binding.Errors {
145+ binding.Error {
146+ FieldNames : []string {"BranchName" },
147+ Classification : ErrGitRefName ,
148+ Message : "GitRefName" ,
149+ },
150+ },
151+ },
152+ {
153+ description : "Reference name has @{" ,
154+ data : TestForm {
155+ BranchName : "branch@{" ,
156+ },
157+ expectedErrors : binding.Errors {
158+ binding.Error {
159+ FieldNames : []string {"BranchName" },
160+ Classification : ErrGitRefName ,
161+ Message : "GitRefName" ,
162+ },
163+ },
164+ },
165+ {
166+ description : "Reference name has unallowed special character ~" ,
167+ data : TestForm {
168+ BranchName : "~debian/1%1.6.0-2" ,
169+ },
170+ expectedErrors : binding.Errors {
171+ binding.Error {
172+ FieldNames : []string {"BranchName" },
173+ Classification : ErrGitRefName ,
174+ Message : "GitRefName" ,
175+ },
176+ },
177+ },
178+ {
179+ description : "Reference name has unallowed special character *" ,
180+ data : TestForm {
181+ BranchName : "*debian/1%1.6.0-2" ,
182+ },
183+ expectedErrors : binding.Errors {
184+ binding.Error {
185+ FieldNames : []string {"BranchName" },
186+ Classification : ErrGitRefName ,
187+ Message : "GitRefName" ,
188+ },
189+ },
190+ },
191+ {
192+ description : "Reference name has unallowed special character ?" ,
193+ data : TestForm {
194+ BranchName : "?debian/1%1.6.0-2" ,
195+ },
196+ expectedErrors : binding.Errors {
197+ binding.Error {
198+ FieldNames : []string {"BranchName" },
199+ Classification : ErrGitRefName ,
200+ Message : "GitRefName" ,
201+ },
202+ },
203+ },
204+ {
205+ description : "Reference name has unallowed special character ^" ,
206+ data : TestForm {
207+ BranchName : "^debian/1%1.6.0-2" ,
208+ },
209+ expectedErrors : binding.Errors {
210+ binding.Error {
211+ FieldNames : []string {"BranchName" },
212+ Classification : ErrGitRefName ,
213+ Message : "GitRefName" ,
214+ },
215+ },
216+ },
217+ {
218+ description : "Reference name has unallowed special character :" ,
219+ data : TestForm {
220+ BranchName : "debian:jessie" ,
221+ },
222+ expectedErrors : binding.Errors {
223+ binding.Error {
224+ FieldNames : []string {"BranchName" },
225+ Classification : ErrGitRefName ,
226+ Message : "GitRefName" ,
227+ },
228+ },
229+ },
230+ {
231+ description : "Reference name has unallowed special character (whitespace)" ,
232+ data : TestForm {
233+ BranchName : "debian jessie" ,
234+ },
235+ expectedErrors : binding.Errors {
236+ binding.Error {
237+ FieldNames : []string {"BranchName" },
238+ Classification : ErrGitRefName ,
239+ Message : "GitRefName" ,
240+ },
241+ },
242+ },
243+ {
244+ description : "Reference name has unallowed special character [" ,
245+ data : TestForm {
246+ BranchName : "debian[jessie" ,
247+ },
248+ expectedErrors : binding.Errors {
249+ binding.Error {
250+ FieldNames : []string {"BranchName" },
251+ Classification : ErrGitRefName ,
252+ Message : "GitRefName" ,
253+ },
254+ },
255+ },
132256}
133257
134258func Test_GitRefNameValidation (t * testing.T ) {
0 commit comments