Пример #1
0
def test_ad_hoc_event_websocket_notifications(emit):
    ahc = AdHocCommand(id=123)
    ahc.save()
    AdHocCommandEvent.create_from_data(ad_hoc_command_id=ahc.pk)
    assert len(emit.call_args_list) == 1
    topic, payload = emit.call_args_list[0][0]
    assert topic == 'ad_hoc_command_events-123'
    assert payload['ad_hoc_command'] == 123
Пример #2
0
def test_ad_hoc_events_sublist_truncation(get, organization_factory, job_template_factory, truncate, expected):
    objs = organization_factory("org", superusers=['admin'])
    adhoc = AdHocCommand()
    adhoc.save()
    AdHocCommandEvent.create_from_data(ad_hoc_command_id=adhoc.pk, uuid='abc123', event='runner_on_start', stdout='a' * 1025, job_created=adhoc.created).save()

    url = reverse('api:ad_hoc_command_ad_hoc_command_events_list', kwargs={'pk': adhoc.pk})
    if not truncate:
        url += '?no_truncate=1'

    response = get(url, user=objs.superusers.admin, expect=200)
    assert (len(response.data['results'][0]['stdout']) == 1025) == expected
Пример #3
0
 def test_host_friend_cancel(self, host, admin_user, host_adhoc):
     adhoc_command = AdHocCommand(inventory=host.inventory,
                                  created_by=admin_user)
     access = AdHocCommandAccess(host_adhoc)
     assert not access.can_cancel(adhoc_command)
Пример #4
0
 def test_host_self_cancel(self, host, host_adhoc):
     adhoc_command = AdHocCommand(inventory=host.inventory,
                                  created_by=host_adhoc)
     access = AdHocCommandAccess(host_adhoc)
     assert access.can_cancel(adhoc_command)
Пример #5
0
    params['organization'] = organization.id
    response = put(reverse('api:credential_detail', kwargs={'pk': cred.pk}),
                   params, admin)
    assert response.status_code == 200

    cred = Credential.objects.all()[:1].get()
    assert cred.inputs['username'] == 'joe'
    assert 'password' not in cred.inputs


@pytest.mark.django_db
@pytest.mark.parametrize(
    'relation, related_obj',
    [
        ['ad_hoc_commands', AdHocCommand()],
        ['unifiedjobs', Job()],
        ['unifiedjobtemplates', JobTemplate()],
        ['unifiedjobtemplates',
         InventorySource(source='ec2')],
        ['projects', Project()],
        ['workflowjobnodes', WorkflowJobNode()],
    ],
)
def test_credential_type_mutability(patch, organization, admin,
                                    credentialtype_ssh, credentialtype_aws,
                                    relation, related_obj):
    cred = Credential(credential_type=credentialtype_ssh,
                      name='Best credential ever',
                      organization=organization,
                      inputs={