@@ -94,6 +94,7 @@ def kafka_credential_type() -> models.CredentialType:
94
94
@pytest .mark .django_db
95
95
def test_validate_for_aap_credential (
96
96
default_activation : models .Activation ,
97
+ default_organization : models .Organization ,
97
98
inputs ,
98
99
result ,
99
100
preseed_credential_types ,
@@ -106,6 +107,7 @@ def test_validate_for_aap_credential(
106
107
inputs = inputs ,
107
108
managed = False ,
108
109
credential_type_id = aap_credential_type .id ,
110
+ organization = default_organization ,
109
111
)
110
112
default_activation .eda_credentials .add (credential )
111
113
@@ -120,6 +122,7 @@ def test_is_activation_valid_with_token_and_run_job_template(
120
122
default_project : models .Project ,
121
123
default_user_awx_token : models .AwxToken ,
122
124
default_user : models .User ,
125
+ default_organization : models .Organization ,
123
126
preseed_credential_types ,
124
127
):
125
128
activation = models .Activation .objects .create (
@@ -130,6 +133,7 @@ def test_is_activation_valid_with_token_and_run_job_template(
130
133
project_id = default_project .id ,
131
134
awx_token_id = default_user_awx_token .id ,
132
135
user_id = default_user .id ,
136
+ organization = default_organization ,
133
137
)
134
138
135
139
valid , _ = is_activation_valid (activation )
@@ -139,6 +143,7 @@ def test_is_activation_valid_with_token_and_run_job_template(
139
143
@pytest .mark .django_db
140
144
def test_is_activation_valid_with_aap_credential_and_run_job_template (
141
145
default_activation : models .Activation ,
146
+ default_organization : models .Organization ,
142
147
preseed_credential_types ,
143
148
):
144
149
aap_credential_type = models .CredentialType .objects .get (
@@ -149,6 +154,7 @@ def test_is_activation_valid_with_aap_credential_and_run_job_template(
149
154
inputs = {"username" : "adam" , "password" : "secret" },
150
155
managed = False ,
151
156
credential_type_id = aap_credential_type .id ,
157
+ organization = default_organization ,
152
158
)
153
159
154
160
default_activation .eda_credentials .add (credential )
@@ -163,6 +169,7 @@ def test_is_activation_valid_with_run_job_template_and_no_token_no_credential(
163
169
default_rulebook_with_run_job_template : models .Rulebook ,
164
170
default_project : models .Project ,
165
171
default_user : models .User ,
172
+ default_organization : models .Organization ,
166
173
preseed_credential_types ,
167
174
):
168
175
activation = models .Activation .objects .create (
@@ -172,6 +179,7 @@ def test_is_activation_valid_with_run_job_template_and_no_token_no_credential(
172
179
decision_environment_id = default_decision_environment .id ,
173
180
project_id = default_project .id ,
174
181
user_id = default_user .id ,
182
+ organization = default_organization ,
175
183
)
176
184
177
185
valid , message = is_activation_valid (activation )
@@ -247,6 +255,7 @@ def test_create_activation_with_eda_credentials(
247
255
preseed_credential_types ,
248
256
credential_type ,
249
257
status_code ,
258
+ default_organization : models .Organization ,
250
259
):
251
260
credential_type = models .CredentialType .objects .get (name = credential_type )
252
261
@@ -257,13 +266,15 @@ def test_create_activation_with_eda_credentials(
257
266
inputs = inputs_to_store (
258
267
{"username" : "dummy-user" , "password" : "dummy-password" }
259
268
),
269
+ organization = default_organization ,
260
270
)
261
271
kafka_eda_credential = models .EdaCredential .objects .create (
262
272
name = "kafka-eda-credential" ,
263
273
inputs = inputs_to_store (
264
274
{"sasl_username" : "adam" , "sasl_password" : "secret" },
265
275
),
266
276
credential_type = kafka_credential_type ,
277
+ organization = default_organization ,
267
278
)
268
279
test_activation = {
269
280
"name" : "test_activation" ,
@@ -272,6 +283,7 @@ def test_create_activation_with_eda_credentials(
272
283
],
273
284
"rulebook_id" : activation_payload ["rulebook_id" ],
274
285
"eda_credentials" : [credential .id , kafka_eda_credential .id ],
286
+ "organization_id" : default_organization .id ,
275
287
}
276
288
277
289
response = admin_client .post (
@@ -315,19 +327,22 @@ def test_create_activation_with_key_conflict(
315
327
default_decision_environment : models .DecisionEnvironment ,
316
328
default_rulebook : models .Rulebook ,
317
329
kafka_credential_type : models .CredentialType ,
330
+ default_organization : models .Organization ,
318
331
preseed_credential_types ,
319
332
):
320
333
test_activation = {
321
334
"name" : "test_activation" ,
322
335
"decision_environment_id" : default_decision_environment .id ,
323
336
"rulebook_id" : default_rulebook .id ,
324
337
"extra_var" : OVERLAP_EXTRA_VAR ,
338
+ "organization_id" : default_organization .id ,
325
339
}
326
340
327
341
test_eda_credential = models .EdaCredential .objects .create (
328
342
name = "eda-credential" ,
329
343
inputs = {"sasl_username" : "adam" , "sasl_password" : "secret" },
330
344
credential_type_id = kafka_credential_type .id ,
345
+ organization = default_organization ,
331
346
)
332
347
test_activation ["eda_credentials" ] = [test_eda_credential .id ]
333
348
@@ -347,6 +362,7 @@ def test_create_activation_with_conflict_credentials(
347
362
admin_client : APIClient ,
348
363
activation_payload : Dict [str , Any ],
349
364
user_credential_type : models .CredentialType ,
365
+ default_organization : models .Organization ,
350
366
preseed_credential_types ,
351
367
):
352
368
test_activation = {
@@ -355,6 +371,7 @@ def test_create_activation_with_conflict_credentials(
355
371
"decision_environment_id"
356
372
],
357
373
"rulebook_id" : activation_payload ["rulebook_id" ],
374
+ "organization_id" : default_organization .id ,
358
375
}
359
376
360
377
eda_credentials = models .EdaCredential .objects .bulk_create (
@@ -392,19 +409,22 @@ def test_create_activation_without_extra_vars_single_credential(
392
409
default_decision_environment : models .DecisionEnvironment ,
393
410
default_rulebook : models .Rulebook ,
394
411
user_credential_type : models .CredentialType ,
412
+ default_organization : models .Organization ,
395
413
preseed_credential_types ,
396
414
):
397
415
test_activation = {
398
416
"name" : "test_activation" ,
399
417
"decision_environment_id" : default_decision_environment .id ,
400
418
"rulebook_id" : default_rulebook .id ,
401
419
"extra_var" : None ,
420
+ "organization_id" : default_organization .id ,
402
421
}
403
422
404
423
eda_credential = models .EdaCredential .objects .create (
405
424
name = "credential-1" ,
406
425
inputs = {"sasl_username" : "adam" , "sasl_password" : "secret" },
407
426
credential_type_id = user_credential_type .id ,
427
+ organization = default_organization ,
408
428
)
409
429
410
430
eda_credential_ids = [eda_credential .id ]
@@ -427,12 +447,14 @@ def test_create_activation_without_extra_vars_duplicate_credentials(
427
447
default_decision_environment : models .DecisionEnvironment ,
428
448
default_rulebook : models .Rulebook ,
429
449
user_credential_type : models .CredentialType ,
450
+ default_organization : models .Organization ,
430
451
preseed_credential_types ,
431
452
):
432
453
test_activation = {
433
454
"name" : "test_activation" ,
434
455
"decision_environment_id" : default_decision_environment .id ,
435
456
"rulebook_id" : default_rulebook .id ,
457
+ "organization_id" : default_organization .id ,
436
458
}
437
459
438
460
eda_credentials = models .EdaCredential .objects .bulk_create (
@@ -441,11 +463,13 @@ def test_create_activation_without_extra_vars_duplicate_credentials(
441
463
name = "credential-1" ,
442
464
inputs = {"sasl_username" : "adam" , "sasl_password" : "secret" },
443
465
credential_type_id = user_credential_type .id ,
466
+ organization = default_organization ,
444
467
),
445
468
models .EdaCredential (
446
469
name = "credential-2" ,
447
470
inputs = {"sasl_username" : "bearny" , "sasl_password" : "demo" },
448
471
credential_type_id = user_credential_type .id ,
472
+ organization = default_organization ,
449
473
),
450
474
]
451
475
)
0 commit comments