@@ -138,14 +138,44 @@ abstract class HttpWsSampler<T> : ApiWsSampler<T>() where T : Individual{
138138
139139 private fun handleAuthInfo (i : AuthenticationDto ) {
140140
141- val auth = try {
142- HttpWsAuthenticationInfo .fromDto(i, config.overrideAuthExternalEndpointURL)
143- }catch (e: Exception ){
144- throw SutProblemException (" Failed to parse auth info: " + e.message!! )
145- }
141+ if (i.createUsers != null ) {
142+ val auth = try {
143+ HttpWsAuthenticationInfo .fromDto(i, config.overrideAuthExternalEndpointURL)
144+ } catch (e: Exception ) {
145+ throw SutProblemException (" Failed to parse auth info: " + e.message!! )
146+ }
147+
148+ authentications.addInfo(auth)
149+ return
150+ } else {
146151
147- authentications.addInfo(auth)
148- return
152+ /*
153+ make 2 copies, with different names.
154+ this might look weird at a first look... if an auth has info to create users,
155+ it can create as many as it wants.
156+ but, we still need to be able to distinguish 2 different users created in the same test.
157+ easiest approach is to have 2 distinct auth objects with different names, as those will
158+ be treated as 2 different users, regardless of the fact they are created on the fly
159+ */
160+ val name = i.name
161+ try {
162+ i.name = " ${name} _x" // changing name is easier than duplicating the DTO
163+ val auth = HttpWsAuthenticationInfo .fromDto(i, config.overrideAuthExternalEndpointURL)
164+ authentications.addInfo(auth)
165+ } catch (e: Exception ) {
166+ i.name = name
167+ throw SutProblemException (" Failed to parse auth info: " + e.message!! )
168+ }
169+ try {
170+ i.name = " ${name} _y"
171+ val auth = HttpWsAuthenticationInfo .fromDto(i, config.overrideAuthExternalEndpointURL)
172+ authentications.addInfo(auth)
173+ } catch (e: Exception ) {
174+ i.name = name
175+ throw SutProblemException (" Failed to parse auth info: " + e.message!! )
176+ }
177+ i.name = name // let's avoid side-effects on input objects
178+ }
149179 }
150180
151181
0 commit comments