Exemplo n.º 1
0
  def test_acls_job(self):
    job = MockMr1Job()

    assert_true(can_view_job('test', job))
    assert_true(can_modify_job('test', job))

    assert_false(can_view_job('test2', job))
    assert_false(can_modify_job('test2', job))
Exemplo n.º 2
0
Arquivo: tests.py Projeto: ronwxy/hue
    def test_acls_job(self):
        job = MockMr1Job()

        assert_true(can_view_job('test', job))
        assert_true(can_modify_job('test', job))

        assert_false(can_view_job('test2', job))
        assert_false(can_modify_job('test2', job))
Exemplo n.º 3
0
  def test_acls_job(self):
    response = self.c.get('/jobbrowser/jobs/job_1356251510842_0054') # Check in perm decorator
    assert_true(can_view_job('test', response.context['job']))
    assert_true(can_modify_job('test', response.context['job']))

    response2 = self.c2.get('/jobbrowser/jobs/job_1356251510842_0054')
    assert_true('don't have permission to access job' in response2.content, response2.content)

    assert_false(can_view_job('test2', response.context['job']))
    assert_false(can_modify_job('test2', response.context['job']))
Exemplo n.º 4
0
  def test_acls_job(self):
    response = self.c.get('/jobbrowser/jobs/job_1356251510842_0054') # Check in perm decorator
    assert_true(can_view_job('test', response.context['job']))
    assert_true(can_modify_job('test', response.context['job']))

    response2 = self.c2.get('/jobbrowser/jobs/job_1356251510842_0054')
    assert_true('don't have permission to access job' in response2.content, response2.content)

    assert_false(can_view_job('test2', response.context['job']))
    assert_false(can_modify_job('test2', response.context['job']))
Exemplo n.º 5
0
    def test_acls_job(self):
        response = self.c.get("/jobbrowser/jobs/job_1356251510842_0054")  # Check in perm decorator
        assert_true(can_view_job("test", response.context["job"]))
        assert_true(can_modify_job("test", response.context["job"]))

        response2 = self.c2.get("/jobbrowser/jobs/job_1356251510842_0054")
        assert_true("don't have permission to access job" in response2.content, response2.content)

        assert_false(can_view_job("test2", response.context["job"]))
        assert_false(can_modify_job("test2", response.context["job"]))
Exemplo n.º 6
0
def massage_job_for_json(job, request):
  job = {
    'id': job.jobId,
    'shortId': job.jobId_short,
    'name': hasattr(job, 'jobName') and job.jobName or '',
    'status': job.status,
    'url': job.jobId and reverse('jobbrowser.views.single_job', kwargs={'job': job.jobId}) or '',
    'logs': job.jobId and reverse('jobbrowser.views.job_single_logs', kwargs={'job': job.jobId}) or '',
    'queueName': hasattr(job, 'queueName') and job.queueName or _('N/A'),
    'priority': hasattr(job, 'priority') and job.priority.lower() or _('N/A'),
    'user': job.user,
    'isRetired': job.is_retired,
    'isMR2': job.is_mr2,
    'mapProgress': hasattr(job, 'mapProgress') and job.mapProgress or '',
    'reduceProgress': hasattr(job, 'reduceProgress') and job.reduceProgress or '',
    'setupProgress': hasattr(job, 'setupProgress') and job.setupProgress or '',
    'cleanupProgress': hasattr(job, 'cleanupProgress') and job.cleanupProgress or '',
    'desiredMaps': job.desiredMaps,
    'desiredReduces': job.desiredReduces,
    'applicationType': hasattr(job, 'applicationType') and job.applicationType or None,
    'mapsPercentComplete': int(job.maps_percent_complete) if job.maps_percent_complete else '',
    'finishedMaps': job.finishedMaps,
    'finishedReduces': job.finishedReduces,
    'reducesPercentComplete': int(job.reduces_percent_complete) if job.reduces_percent_complete else '',
    'jobFile': hasattr(job, 'jobFile') and job.jobFile or '',
    'launchTimeMs': hasattr(job, 'launchTimeMs') and job.launchTimeMs or '',
    'launchTimeFormatted': hasattr(job, 'launchTimeFormatted') and job.launchTimeFormatted or '',
    'startTimeMs': hasattr(job, 'startTimeMs') and job.startTimeMs or '',
    'startTimeFormatted': hasattr(job, 'startTimeFormatted') and job.startTimeFormatted or '',
    'finishTimeMs': hasattr(job, 'finishTimeMs') and job.finishTimeMs or '',
    'finishTimeFormatted': hasattr(job, 'finishTimeFormatted') and job.finishTimeFormatted or '',
    'durationFormatted': hasattr(job, 'durationFormatted') and job.durationFormatted or '',
    'durationMs': hasattr(job, 'durationInMillis') and job.durationInMillis or '',
    'canKill': job.status.lower() in ('running', 'pending') and (request.user.is_superuser or request.user.username == job.user or can_modify_job(request.user.username, job)),
    'killUrl': job.jobId and reverse('jobbrowser.views.kill_job', kwargs={'job': job.jobId}) or ''
  }
  return job
Exemplo n.º 7
0
def massage_job_for_json(job, request):
    job = {
        'id':
        job.jobId,
        'shortId':
        job.jobId_short,
        'name':
        hasattr(job, 'jobName') and job.jobName or '',
        'status':
        job.status,
        'url':
        job.jobId
        and reverse('jobbrowser.views.single_job', kwargs={'job': job.jobId})
        or '',
        'logs':
        job.jobId and reverse('jobbrowser.views.job_single_logs',
                              kwargs={'job': job.jobId}) or '',
        'queueName':
        hasattr(job, 'queueName') and job.queueName or _('N/A'),
        'priority':
        hasattr(job, 'priority') and job.priority.lower() or _('N/A'),
        'user':
        job.user,
        'isRetired':
        job.is_retired,
        'isMR2':
        job.is_mr2,
        'mapProgress':
        hasattr(job, 'mapProgress') and job.mapProgress or '',
        'reduceProgress':
        hasattr(job, 'reduceProgress') and job.reduceProgress or '',
        'setupProgress':
        hasattr(job, 'setupProgress') and job.setupProgress or '',
        'cleanupProgress':
        hasattr(job, 'cleanupProgress') and job.cleanupProgress or '',
        'desiredMaps':
        job.desiredMaps,
        'desiredReduces':
        job.desiredReduces,
        'applicationType':
        hasattr(job, 'applicationType') and job.applicationType or None,
        'mapsPercentComplete':
        int(job.maps_percent_complete) if job.maps_percent_complete else '',
        'finishedMaps':
        job.finishedMaps,
        'finishedReduces':
        job.finishedReduces,
        'reducesPercentComplete':
        int(job.reduces_percent_complete)
        if job.reduces_percent_complete else '',
        'jobFile':
        hasattr(job, 'jobFile') and job.jobFile or '',
        'launchTimeMs':
        hasattr(job, 'launchTimeMs') and job.launchTimeMs or '',
        'launchTimeFormatted':
        hasattr(job, 'launchTimeFormatted') and job.launchTimeFormatted or '',
        'startTimeMs':
        hasattr(job, 'startTimeMs') and job.startTimeMs or '',
        'startTimeFormatted':
        hasattr(job, 'startTimeFormatted') and job.startTimeFormatted or '',
        'finishTimeMs':
        hasattr(job, 'finishTimeMs') and job.finishTimeMs or '',
        'finishTimeFormatted':
        hasattr(job, 'finishTimeFormatted') and job.finishTimeFormatted or '',
        'durationFormatted':
        hasattr(job, 'durationFormatted') and job.durationFormatted or '',
        'durationMs':
        hasattr(job, 'durationInMillis') and job.durationInMillis or '',
        'canKill':
        job.status.lower() in ('running', 'pending')
        and (request.user.is_superuser or request.user.username == job.user
             or can_modify_job(request.user.username, job)),
        'killUrl':
        job.jobId
        and reverse('jobbrowser.views.kill_job', kwargs={'job': job.jobId})
        or ''
    }
    return job