File tree Expand file tree Collapse file tree 2 files changed +32
-4
lines changed
tests/integration/targets/image_share_group_token/tasks Expand file tree Collapse file tree 2 files changed +32
-4
lines changed Original file line number Diff line number Diff line change @@ -138,16 +138,28 @@ def _create(self) -> Optional[ImageShareGroupToken]:
138138
139139 def _handle_present (self ) -> None :
140140 label = self .module .params .get ("label" )
141+ requested_uuid = self .module .params .get ("valid_for_sharegroup_uuid" )
142+
141143 token = self ._get_image_share_group_token_by_label (label )
142144
143- if not token :
145+ if token :
146+ token ._api_get ()
147+
148+ existing_uuid = token .valid_for_sharegroup_uuid
149+
150+ if requested_uuid != existing_uuid :
151+ self .fail (
152+ msg = (
153+ "failed to update {} -> {}: valid_for_sharegroup_uuid "
154+ "is a non-updatable field"
155+ ).format (existing_uuid , requested_uuid )
156+ )
157+ else :
144158 token = self ._create ()
145159 self .register_action (
146160 "Created Image Share Group Token {0}" .format (label )
147161 )
148-
149- # Force lazy-loading
150- token ._api_get ()
162+ token ._api_get ()
151163
152164 self .results ["image_share_group_token" ] = token ._raw_json
153165
Original file line number Diff line number Diff line change 4444 - share_group_token_create.single_use_token is defined
4545 - share_group_token_create.single_use_token | length > 0
4646
47+ - name : Attempt to update image share group token with modified share group UUID (should fail)
48+ linode.cloud.image_share_group_token :
49+ label : " ansible-test-{{ r }}"
50+ valid_for_sharegroup_uuid : " {{ share_group_create.image_share_group.uuid }}x"
51+ state : present
52+ register : share_group_token_update_attempt
53+ failed_when : false
54+ environment :
55+ LINODE_API_TOKEN : " {{ consumer_api_token }}"
56+
57+ - name : Assert image share group token update fails for non-mutable field
58+ assert :
59+ that :
60+ - share_group_token_update_attempt.msg is defined
61+ - " 'non-updatable field' in share_group_token_update_attempt.msg"
62+
4763 always :
4864 - ignore_errors : yes
4965 block :
You can’t perform that action at this time.
0 commit comments