File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,16 @@ load test_helper
51
51
52
52
run govc tags.category.rm " $update_name "
53
53
assert_success
54
+
55
+ run govc tags.category.create -id " invalid" custom-id-cat
56
+ assert_failure
57
+
58
+ id=" urn:vmomi:InventoryServiceCategory:$( new_id) :GLOBAL"
59
+ run govc tags.category.create -id " $id " custom-id-cat
60
+ assert_success
61
+
62
+ run govc tags.category.info " $id "
63
+ assert_success
54
64
}
55
65
56
66
@test " tags" {
@@ -117,6 +127,16 @@ load test_helper
117
127
118
128
run govc tags.info enoent
119
129
assert_failure # does not exist
130
+
131
+ run govc tags.category.create -c " $category_name " -id " invalid" custom-id-tag
132
+ assert_failure
133
+
134
+ id=" urn:vmomi:InventoryServiceTag:$( new_id) :GLOBAL"
135
+ run govc tags.create -c " $category_name " -id " $id " custom-id-tag
136
+ assert_success
137
+
138
+ run govc tags.info " $id "
139
+ assert_success
120
140
}
121
141
122
142
@test " tags.association" {
Original file line number Diff line number Diff line change @@ -595,7 +595,13 @@ func (s *handler) category(w http.ResponseWriter, r *http.Request) {
595
595
return
596
596
}
597
597
}
598
- id := newID ("Category" )
598
+ id := spec .Category .CategoryID
599
+ if id == "" {
600
+ id = newID ("Category" )
601
+ } else if ! strings .HasPrefix (id , "urn:vmomi:InventoryServiceCategory:" ) {
602
+ BadRequest (w , "com.vmware.vapi.std.errors.invalid_argument" )
603
+ return
604
+ }
599
605
spec .Category .ID = id
600
606
s .Category [id ] = & spec .Category
601
607
OK (w , id )
@@ -668,7 +674,13 @@ func (s *handler) tag(w http.ResponseWriter, r *http.Request) {
668
674
return
669
675
}
670
676
}
671
- id := newID ("Tag" )
677
+ id := spec .Tag .TagID
678
+ if id == "" {
679
+ id = newID ("Tag" )
680
+ } else if ! strings .HasPrefix (id , "urn:vmomi:InventoryServiceTag:" ) {
681
+ BadRequest (w , "com.vmware.vapi.std.errors.invalid_argument" )
682
+ return
683
+ }
672
684
spec .Tag .ID = id
673
685
s .Tag [id ] = & spec .Tag
674
686
s .Association [id ] = make (map [internal.AssociatedObject ]bool )
You can’t perform that action at this time.
0 commit comments