@@ -100,4 +100,51 @@ static void AssertInviteLink(OrganizationInviteLinkResponseModel? content, Organ
100100 var content = await getResponse . Content . ReadFromJsonAsync < OrganizationInviteLinkResponseModel > ( ) ;
101101 AssertInviteLink ( content , _organization ) ;
102102 }
103+
104+ [ Fact ]
105+ public async Task CreateThenUpdateThenGet_AsOwner_ReturnsCreatedAndOkAndOk ( )
106+ {
107+ var createRequest = new CreateOrganizationInviteLinkRequestModel
108+ {
109+ AllowedDomains = [ "acme.com" ] ,
110+ EncryptedInviteKey = _validEncryptedKey ,
111+ } ;
112+
113+ var createResponse = await _client . PostAsJsonAsync (
114+ $ "/organizations/{ _organization . Id } /invite-link", createRequest ) ;
115+
116+ Assert . Equal ( HttpStatusCode . Created , createResponse . StatusCode ) ;
117+
118+ var created = await createResponse . Content . ReadFromJsonAsync < OrganizationInviteLinkResponseModel > ( ) ;
119+ Assert . NotNull ( created ) ;
120+
121+ var updateRequest = new UpdateOrganizationInviteLinkRequestModel
122+ {
123+ AllowedDomains = [ "example.com" , "new.com" ] ,
124+ } ;
125+
126+ var updateResponse = await _client . PutAsJsonAsync (
127+ $ "/organizations/{ _organization . Id } /invite-link", updateRequest ) ;
128+
129+ Assert . Equal ( HttpStatusCode . OK , updateResponse . StatusCode ) ;
130+
131+ var updated = await updateResponse . Content . ReadFromJsonAsync < OrganizationInviteLinkResponseModel > ( ) ;
132+ Assert . NotNull ( updated ) ;
133+ Assert . Equal ( created . Id , updated . Id ) ;
134+ Assert . Equal ( created . Code , updated . Code ) ;
135+ Assert . Equal ( _organization . Id , updated . OrganizationId ) ;
136+ Assert . Equal ( _validEncryptedKey , updated . EncryptedInviteKey ) ;
137+ Assert . Equal ( [ "example.com" , "new.com" ] , updated . AllowedDomains ) ;
138+
139+ var getResponse = await _client . GetAsync ( $ "/organizations/{ _organization . Id } /invite-link") ;
140+
141+ Assert . Equal ( HttpStatusCode . OK , getResponse . StatusCode ) ;
142+
143+ var content = await getResponse . Content . ReadFromJsonAsync < OrganizationInviteLinkResponseModel > ( ) ;
144+ Assert . NotNull ( content ) ;
145+ Assert . Equal ( created . Id , content . Id ) ;
146+ Assert . Equal ( created . Code , content . Code ) ;
147+ Assert . Equal ( _validEncryptedKey , content . EncryptedInviteKey ) ;
148+ Assert . Equal ( [ "example.com" , "new.com" ] , content . AllowedDomains ) ;
149+ }
103150}
0 commit comments