@@ -509,12 +509,33 @@ def test_tags(self):
509509 tags4 = response .data
510510 self .assertNotEqual (tags3 ['uuid' ], tags4 ['uuid' ])
511511 self .assertNotIn ('rack' , json .dumps (response .data ['tags' ]))
512+ # set valid values
513+ body = {'tags' : json .dumps ({'kubernetes.io/hostname' : 'valid' })}
514+ response = self .client .post (url , json .dumps (body ), content_type = 'application/json' ,
515+ HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
516+ self .assertEqual (response .status_code , 201 )
517+ body = {'tags' : json .dumps ({'is.valid' : 'is-also_valid' })}
518+ response = self .client .post (url , json .dumps (body ), content_type = 'application/json' ,
519+ HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
520+ self .assertEqual (response .status_code , 201 )
521+ body = {'tags' : json .dumps ({'host.the-name.com/is.valid' : 'valid' })}
522+ response = self .client .post (url , json .dumps (body ), content_type = 'application/json' ,
523+ HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
524+ self .assertEqual (response .status_code , 201 )
512525 # set invalid values
513526 body = {'tags' : json .dumps ({'valid' : 'in\n valid' })}
514527 response = self .client .post (url , json .dumps (body ), content_type = 'application/json' ,
515528 HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
516529 self .assertEqual (response .status_code , 400 )
517- body = {'tags' : json .dumps ({'in.valid' : 'valid' })}
530+ body = {'tags' : json .dumps ({'host.name.com/notvalid-' : 'valid' })}
531+ response = self .client .post (url , json .dumps (body ), content_type = 'application/json' ,
532+ HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
533+ self .assertEqual (response .status_code , 400 )
534+ body = {'tags' : json .dumps ({'valid' : 'invalid.' })}
535+ response = self .client .post (url , json .dumps (body ), content_type = 'application/json' ,
536+ HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
537+ self .assertEqual (response .status_code , 400 )
538+ body = {'tags' : json .dumps ({'host.name.com/,not.valid' : 'valid' })}
518539 response = self .client .post (url , json .dumps (body ), content_type = 'application/json' ,
519540 HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
520541 self .assertEqual (response .status_code , 400 )
0 commit comments