|
Vivek Anand |
6f20f8 |
#!/usr/bin/env python
|
|
Vivek Anand |
6f20f8 |
# coding=utf-8
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
"""
|
|
Vivek Anand |
6f20f8 |
(c) 2017 - Copyright Red Hat Inc
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
Authors:
|
|
Vivek Anand |
6f20f8 |
Vivek Anand <vivekanand1101@gmail.com></vivekanand1101@gmail.com>
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
"""
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
67d1cc |
from __future__ import unicode_literals, absolute_import
|
|
Aurélien Bompard |
dcf6f6 |
|
|
Vivek Anand |
6f20f8 |
from unittest.case import SkipTest
|
|
Vivek Anand |
6f20f8 |
import json
|
|
Vivek Anand |
6f20f8 |
import unittest
|
|
Vivek Anand |
6f20f8 |
import shutil
|
|
Vivek Anand |
6f20f8 |
import sys
|
|
Vivek Anand |
6f20f8 |
import os
|
|
Pierre-Yves Chibon |
73d120 |
|
|
Vivek Anand |
6f20f8 |
try:
|
|
Vivek Anand |
6f20f8 |
import pyclamd
|
|
Abhijeet Kasurde |
f4bf50 |
except ImportError:
|
|
Vivek Anand |
6f20f8 |
pyclamd = None
|
|
Vivek Anand |
6f20f8 |
import tempfile
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
import pygit2
|
|
Vivek Anand |
6f20f8 |
from mock import patch
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
sys.path.insert(
|
|
Pierre-Yves Chibon |
73d120 |
0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
b130e5 |
import pagure.config
|
|
Pierre-Yves Chibon |
930073 |
import pagure.lib.query
|
|
Vivek Anand |
6f20f8 |
import tests
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
class PagureFlaskIssuesACLtests(tests.Modeltests):
|
|
Vivek Anand |
6f20f8 |
""" Tests for flask issues controller of pagure for acls """
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.git.update_git")
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.notify.send_email")
|
|
Vivek Anand |
6f20f8 |
def test_view_issue_no_access(self, p_send_email, p_ugt):
|
|
Vivek Anand |
6f20f8 |
""" Test the view_issue endpoint. when a user has no access on repo """
|
|
Vivek Anand |
6f20f8 |
p_send_email.return_value = True
|
|
Vivek Anand |
6f20f8 |
p_ugt.return_value = True
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/foo/issue/1")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 404)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
73d120 |
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 404)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Create issues to play with
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(self.session, "test")
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.new_issue(
|
|
Vivek Anand |
6f20f8 |
session=self.session,
|
|
Vivek Anand |
6f20f8 |
repo=repo,
|
|
Pierre-Yves Chibon |
73d120 |
title="Test issue",
|
|
Pierre-Yves Chibon |
73d120 |
content="We should work on this",
|
|
Pierre-Yves Chibon |
73d120 |
user="pingou",
|
|
Vivek Anand |
6f20f8 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(msg.title, "Test issue")
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Add milestone
|
|
Pierre-Yves Chibon |
73d120 |
repo.milestones = {"77": None}
|
|
Vivek Anand |
6f20f8 |
self.session.add(repo)
|
|
Pierre-Yves Chibon |
930073 |
issue = pagure.lib.query.search_issues(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, repo=repo, issueid=1
|
|
Vivek Anand |
6f20f8 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
930073 |
pagure.lib.query.edit_issue(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, issue, user="pingou", milestone="77"
|
|
Vivek Anand |
6f20f8 |
)
|
|
Vivek Anand |
6f20f8 |
self.session.add(repo)
|
|
Vivek Anand |
6f20f8 |
self.session.add(issue)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.set_custom_key_fields(
|
|
Vivek Anand |
6f20f8 |
self.session,
|
|
Vivek Anand |
6f20f8 |
project=repo,
|
|
Pierre-Yves Chibon |
73d120 |
fields=["abc", "xyz"],
|
|
Pierre-Yves Chibon |
73d120 |
types=["boolean", "boolean"],
|
|
Vivek Anand |
6f20f8 |
data=[None, None],
|
|
Vivek Anand |
6f20f8 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(msg, "List of custom fields updated")
|
|
Vivek Anand |
6f20f8 |
self.session.add(repo)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.set_custom_key_value(
|
|
Vivek Anand |
6f20f8 |
self.session,
|
|
Vivek Anand |
6f20f8 |
issue=issue,
|
|
Pierre-Yves Chibon |
73d120 |
key=pagure.lib.query.get_custom_key(self.session, repo, "abc"),
|
|
Pierre-Yves Chibon |
73d120 |
value=1,
|
|
Vivek Anand |
6f20f8 |
)
|
|
Vivek Anand |
6f20f8 |
self.session.add(issue)
|
|
Vivek Anand |
6f20f8 |
self.session.commit()
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 200)
|
|
Vivek Anand |
6f20f8 |
# Not authentified = No edit
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
73d120 |
'
|
|
Pierre-Yves Chibon |
73d120 |
'href="/test/issue/1/edit" title="Edit this issue">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output.get_data(as_text=True),
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
self.assertTrue(
|
|
Vivek Anand |
6f20f8 |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Login\n to comment on this ticket."
|
|
Pierre-Yves Chibon |
73d120 |
in output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
4c5425 |
output_text = output.get_data(as_text=True)
|
|
Vivek Anand |
6f20f8 |
# Not author nor admin = No edit
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Ryan Lerch |
e85d33 |
'href="/test/issue/1/edit" title="Edit this issue">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Julen Landa Alustiza |
581c9c |
'
|
|
Ryan Lerch |
e85d33 |
' title="Delete this ticket">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output.get_data(as_text=True),
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# no edit metadata
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Julen Landa Alustiza |
581c9c |
' editmetadatatoggle pointer inline-block"">'
|
|
Ryan Lerch |
e85d33 |
'',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
0541ed |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
0541ed |
'Login to comment on this ticket.',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# can view the milestone
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Milestone", output_text)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
4c5425 |
'\n '
|
|
Pierre-Yves Chibon |
73d120 |
"\n 77\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
# but can't edit them
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Vivek Anand |
6f20f8 |
'
|
|
Vivek Anand |
6f20f8 |
' name="milestone"><option value=""></option>
|
|
Vivek Anand |
6f20f8 |
'selected value="77">77',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
215f54 |
# can view depending
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"Depending on", output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
215f54 |
# can't edit depending on
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
215f54 |
'
|
|
Pierre-Yves Chibon |
215f54 |
placeholder="issue depending" name="depending"\n\
|
|
Vivek Anand |
6f20f8 |
value="" />',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# no checkbox for private
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Vivek Anand |
6f20f8 |
'<input id="private" name="private" type="checkbox" value="y">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
user.username = "foo"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
4c5425 |
output_text = output.get_data(as_text=True)
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Ryan Lerch |
e85d33 |
'href="/test/issue/1/edit" title="Edit this issue">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Julen Landa Alustiza |
581c9c |
'
|
|
Ryan Lerch |
e85d33 |
' title="Delete this ticket">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
0541ed |
csrf_token = self.get_csrf(output=output)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# no edit metadata
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Julen Landa Alustiza |
581c9c |
' editmetadatatoggle pointer inline-block">'
|
|
Ryan Lerch |
e85d33 |
'',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
0541ed |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
0541ed |
'Login to comment on this ticket.',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# can't see the custom field as a checkbox
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Vivek Anand |
6f20f8 |
'
|
|
Vivek Anand |
6f20f8 |
'class="form-control" name="abc" id="abc"checked/>',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# can view the milestone
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"Milestone", output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
4c5425 |
'\n 77',
|
|
Pierre-Yves Chibon |
73d120 |
output.get_data(as_text=True),
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# but can't edit them
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Vivek Anand |
6f20f8 |
'
|
|
Vivek Anand |
6f20f8 |
' name="milestone"><option value=""></option>
|
|
Vivek Anand |
6f20f8 |
'selected value="77">77',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
215f54 |
# can view depending
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Depending on", output_text)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
215f54 |
# can't edit depending on
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
215f54 |
'
|
|
Pierre-Yves Chibon |
215f54 |
placeholder="issue depending" name="depending"\n\
|
|
Vivek Anand |
6f20f8 |
value="" />',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# no checkbox for private
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Vivek Anand |
6f20f8 |
'<input id="private" name="private" type="checkbox" value="y">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Create private issue
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(self.session, "test")
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.new_issue(
|
|
Vivek Anand |
6f20f8 |
session=self.session,
|
|
Vivek Anand |
6f20f8 |
repo=repo,
|
|
Pierre-Yves Chibon |
73d120 |
title="Test issue",
|
|
Pierre-Yves Chibon |
73d120 |
content="We should work on this",
|
|
Pierre-Yves Chibon |
73d120 |
user="pingou",
|
|
Vivek Anand |
6f20f8 |
private=True,
|
|
Vivek Anand |
6f20f8 |
)
|
|
Vivek Anand |
6f20f8 |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(msg.title, "Test issue")
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Not logged in
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/2")
|
|
Pierre-Yves Chibon |
97f498 |
self.assertEqual(output.status_code, 404)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Wrong user
|
|
Vivek Anand |
6f20f8 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/2")
|
|
Pierre-Yves Chibon |
97f498 |
self.assertEqual(output.status_code, 404)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# reporter
|
|
Pierre-Yves Chibon |
73d120 |
user.username = "pingou"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/2")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
0541ed |
output_text = output.get_data(as_text=True)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Issue #2: Test issue - test - Pagure</title>",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
3a8ee8 |
'
|
|
Pierre-Yves Chibon |
73d120 |
'fa fa-fw fa-lock">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Ryan Lerch |
e85d33 |
'href="/test/issue/2/edit" title="Edit this issue">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.git.update_git")
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.notify.send_email")
|
|
Vivek Anand |
6f20f8 |
def test_view_issue_ticket_access(self, p_send_email, p_ugt):
|
|
Vivek Anand |
6f20f8 |
""" Test the view_issue endpoint. when a user has ticket access on repo """
|
|
Vivek Anand |
6f20f8 |
p_send_email.return_value = True
|
|
Vivek Anand |
6f20f8 |
p_ugt.return_value = True
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/foo/issue/1")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 404)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
73d120 |
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 404)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Create issues to play with
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(self.session, "test")
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Add user 'foo' with ticket access on repo
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.add_user_to_project(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, repo, new_user="foo", user="pingou", access="ticket"
|
|
Vivek Anand |
6f20f8 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(msg, "User added")
|
|
Vivek Anand |
6f20f8 |
self.session.commit()
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(self.session, "test")
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.new_issue(
|
|
Vivek Anand |
6f20f8 |
session=self.session,
|
|
Vivek Anand |
6f20f8 |
repo=repo,
|
|
Pierre-Yves Chibon |
73d120 |
title="Test issue",
|
|
Pierre-Yves Chibon |
73d120 |
content="We should work on this",
|
|
Pierre-Yves Chibon |
73d120 |
user="pingou",
|
|
Vivek Anand |
6f20f8 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(msg.title, "Test issue")
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Add milestone
|
|
Pierre-Yves Chibon |
73d120 |
repo.milestones = {"77": None}
|
|
Vivek Anand |
6f20f8 |
self.session.add(repo)
|
|
Pierre-Yves Chibon |
930073 |
issue = pagure.lib.query.search_issues(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, repo=repo, issueid=1
|
|
Vivek Anand |
6f20f8 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
930073 |
pagure.lib.query.edit_issue(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, issue, user="pingou", milestone="77"
|
|
Vivek Anand |
6f20f8 |
)
|
|
Vivek Anand |
6f20f8 |
self.session.add(repo)
|
|
Vivek Anand |
6f20f8 |
self.session.add(issue)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.set_custom_key_fields(
|
|
Vivek Anand |
6f20f8 |
self.session,
|
|
Vivek Anand |
6f20f8 |
project=repo,
|
|
Pierre-Yves Chibon |
73d120 |
fields=["abc", "xyz"],
|
|
Pierre-Yves Chibon |
73d120 |
types=["boolean", "boolean"],
|
|
Vivek Anand |
6f20f8 |
data=[None, None],
|
|
Vivek Anand |
6f20f8 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(msg, "List of custom fields updated")
|
|
Vivek Anand |
6f20f8 |
self.session.add(repo)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.set_custom_key_value(
|
|
Vivek Anand |
6f20f8 |
self.session,
|
|
Vivek Anand |
6f20f8 |
issue=issue,
|
|
Pierre-Yves Chibon |
73d120 |
key=pagure.lib.query.get_custom_key(self.session, repo, "abc"),
|
|
Pierre-Yves Chibon |
73d120 |
value=1,
|
|
Vivek Anand |
6f20f8 |
)
|
|
Vivek Anand |
6f20f8 |
self.session.add(issue)
|
|
Vivek Anand |
6f20f8 |
self.session.commit()
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
0541ed |
output_text = output.get_data(as_text=True)
|
|
Vivek Anand |
6f20f8 |
# Not authentified = No edit
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
73d120 |
'
|
|
Pierre-Yves Chibon |
73d120 |
'href="/test/issue/1/edit" title="Edit this issue">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
0541ed |
self.assertIn(
|
|
Vivek Anand |
6f20f8 |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Login\n to comment on this ticket.",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
4c5425 |
output_text = output.get_data(as_text=True)
|
|
Vivek Anand |
6f20f8 |
# Not author nor admin = No edit
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Ryan Lerch |
e85d33 |
'href="/test/issue/1/edit" title="Edit this issue">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Julen Landa Alustiza |
581c9c |
'
|
|
Ryan Lerch |
e85d33 |
' title="Delete this ticket">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# no edit metadata
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Julen Landa Alustiza |
581c9c |
' editmetadatatoggle pointer inline-block">'
|
|
Ryan Lerch |
e85d33 |
'',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
0541ed |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
0541ed |
'Login to comment on this ticket.',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# can view the milestone
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Milestone", output_text)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
4c5425 |
'\n 77',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
# but can't edit them
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Vivek Anand |
6f20f8 |
'
|
|
Vivek Anand |
6f20f8 |
' name="milestone"><option value=""></option>
|
|
Vivek Anand |
6f20f8 |
'selected value="77">77',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
215f54 |
# can view depending
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Depending on", output_text)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
215f54 |
# can't edit depending on
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
215f54 |
'
|
|
Pierre-Yves Chibon |
215f54 |
placeholder="issue depending" name="depending"\n\
|
|
Vivek Anand |
6f20f8 |
value="" />',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# no checkbox for private
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Vivek Anand |
6f20f8 |
'<input id="private" name="private" type="checkbox" value="y">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
user.username = "foo"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
4c5425 |
output_text = output.get_data(as_text=True)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# the user can't edit the issue
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Ryan Lerch |
e85d33 |
'href="/test/issue/1/edit" title="Edit this issue">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# the user still can't delete the ticket
|
|
Ryan Lerch |
e85d33 |
self.assertNotIn(
|
|
Julen Landa Alustiza |
581c9c |
'
|
|
Ryan Lerch |
e85d33 |
' title="Delete this ticket">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
0541ed |
csrf_token = self.get_csrf(output=output)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# the user can do the following things
|
|
Vivek Anand |
6f20f8 |
# edit metadata
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
aede19 |
'
|
|
Julen Landa Alustiza |
0cafab |
"issue-metadata-display editmetadatatoggle pointer inline-block"
|
|
Pierre-Yves Chibon |
aede19 |
'">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# can view the milestone
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Milestone", output_text)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
4c5425 |
'\n 77',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# can edit them
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Vivek Anand |
6f20f8 |
'
|
|
Vivek Anand |
6f20f8 |
'name="milestone"><option value=""></option>
|
|
Vivek Anand |
6f20f8 |
'value="77">77\n \n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
215f54 |
# can view depending
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Depending on", output_text)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
215f54 |
# can edit depending on
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
215f54 |
'
|
|
Pierre-Yves Chibon |
215f54 |
'\n placeholder="issue depending" name="depending"\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# the user should be able to do public -> private
|
|
Vivek Anand |
6f20f8 |
# the other way round won't be possible since GET and POST
|
|
Vivek Anand |
6f20f8 |
# to this endpoint for this user will be blocked
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# checkbox for private
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Vivek Anand |
6f20f8 |
'<input id="private" name="private" type="checkbox" value="y">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Create private issue
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(self.session, "test")
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.new_issue(
|
|
Vivek Anand |
6f20f8 |
session=self.session,
|
|
Vivek Anand |
6f20f8 |
repo=repo,
|
|
Pierre-Yves Chibon |
73d120 |
title="Test issue",
|
|
Pierre-Yves Chibon |
73d120 |
content="We should work on this",
|
|
Pierre-Yves Chibon |
73d120 |
user="pingou",
|
|
Vivek Anand |
6f20f8 |
private=True,
|
|
Vivek Anand |
6f20f8 |
)
|
|
Vivek Anand |
6f20f8 |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(msg.title, "Test issue")
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Not logged in
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/2")
|
|
Pierre-Yves Chibon |
97f498 |
self.assertEqual(output.status_code, 404)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Wrong user
|
|
Vivek Anand |
6f20f8 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/2")
|
|
Pierre-Yves Chibon |
97f498 |
self.assertEqual(output.status_code, 404)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# reporter
|
|
Pierre-Yves Chibon |
73d120 |
user.username = "pingou"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/2")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
0541ed |
output_text = output.get_data(as_text=True)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Issue #2: Test issue - test - Pagure</title>",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
3a8ee8 |
'
|
|
Pierre-Yves Chibon |
73d120 |
'fa fa-fw fa-lock">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Ryan Lerch |
e85d33 |
'href="/test/issue/2/edit" title="Edit this issue">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.git.update_git")
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.notify.send_email")
|
|
Vivek Anand |
6f20f8 |
def test_view_issue_commit_access(self, p_send_email, p_ugt):
|
|
Vivek Anand |
6f20f8 |
""" Test the view_issue endpoint. when a user has commit access on repo """
|
|
Vivek Anand |
6f20f8 |
p_send_email.return_value = True
|
|
Vivek Anand |
6f20f8 |
p_ugt.return_value = True
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/foo/issue/1")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 404)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
73d120 |
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 404)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Create issues to play with
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(self.session, "test")
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Add user 'foo' with ticket access on repo
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.add_user_to_project(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, repo, new_user="foo", user="pingou", access="commit"
|
|
Vivek Anand |
6f20f8 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(msg, "User added")
|
|
Vivek Anand |
6f20f8 |
self.session.commit()
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(self.session, "test")
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.new_issue(
|
|
Vivek Anand |
6f20f8 |
session=self.session,
|
|
Vivek Anand |
6f20f8 |
repo=repo,
|
|
Pierre-Yves Chibon |
73d120 |
title="Test issue",
|
|
Pierre-Yves Chibon |
73d120 |
content="We should work on this",
|
|
Pierre-Yves Chibon |
73d120 |
user="pingou",
|
|
Vivek Anand |
6f20f8 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(msg.title, "Test issue")
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Add milestone
|
|
Pierre-Yves Chibon |
73d120 |
repo.milestones = {"77": None}
|
|
Vivek Anand |
6f20f8 |
self.session.add(repo)
|
|
Pierre-Yves Chibon |
930073 |
issue = pagure.lib.query.search_issues(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, repo=repo, issueid=1
|
|
Vivek Anand |
6f20f8 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
930073 |
pagure.lib.query.edit_issue(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, issue, user="pingou", milestone="77"
|
|
Vivek Anand |
6f20f8 |
)
|
|
Vivek Anand |
6f20f8 |
self.session.add(repo)
|
|
Vivek Anand |
6f20f8 |
self.session.add(issue)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.set_custom_key_fields(
|
|
Vivek Anand |
6f20f8 |
self.session,
|
|
Vivek Anand |
6f20f8 |
project=repo,
|
|
Pierre-Yves Chibon |
73d120 |
fields=["abc", "xyz"],
|
|
Pierre-Yves Chibon |
73d120 |
types=["boolean", "boolean"],
|
|
Vivek Anand |
6f20f8 |
data=[None, None],
|
|
Vivek Anand |
6f20f8 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(msg, "List of custom fields updated")
|
|
Vivek Anand |
6f20f8 |
self.session.add(repo)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.set_custom_key_value(
|
|
Vivek Anand |
6f20f8 |
self.session,
|
|
Vivek Anand |
6f20f8 |
issue=issue,
|
|
Pierre-Yves Chibon |
73d120 |
key=pagure.lib.query.get_custom_key(self.session, repo, "abc"),
|
|
Pierre-Yves Chibon |
73d120 |
value=1,
|
|
Vivek Anand |
6f20f8 |
)
|
|
Vivek Anand |
6f20f8 |
self.session.add(issue)
|
|
Vivek Anand |
6f20f8 |
self.session.commit()
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
0541ed |
output_text = output.get_data(as_text=True)
|
|
Vivek Anand |
6f20f8 |
# Not authentified = No edit
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
73d120 |
'
|
|
Pierre-Yves Chibon |
73d120 |
'href="/test/issue/1/edit" title="Edit this issue">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
self.assertTrue(
|
|
Vivek Anand |
6f20f8 |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Login\n to comment on this ticket.",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
4c5425 |
output_text = output.get_data(as_text=True)
|
|
Vivek Anand |
6f20f8 |
# Not author nor admin = No edit
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Ryan Lerch |
e85d33 |
'href="/test/issue/1/edit" title="Edit this issue">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Julen Landa Alustiza |
581c9c |
'
|
|
Ryan Lerch |
e85d33 |
' title="Delete this ticket">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# no edit metadata
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Julen Landa Alustiza |
581c9c |
' editmetadatatoggle pointer inline-block">'
|
|
Ryan Lerch |
e85d33 |
'',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
0541ed |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
0541ed |
'Login to comment on this ticket.',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# can view the milestone
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Milestone", output_text)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
4c5425 |
'\n 77',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
# but can't edit them
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Vivek Anand |
6f20f8 |
'
|
|
Vivek Anand |
6f20f8 |
' name="milestone"><option value=""></option>
|
|
Vivek Anand |
6f20f8 |
'selected value="77">77',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
215f54 |
# can view depending
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Depending on", output_text)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
215f54 |
# can't edit depending on
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
215f54 |
'
|
|
Pierre-Yves Chibon |
215f54 |
placeholder="issue depending" name="depending"\n\
|
|
Vivek Anand |
6f20f8 |
value="" />',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# no checkbox for private
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Vivek Anand |
6f20f8 |
'<input id="private" name="private" type="checkbox" value="y">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
user.username = "foo"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
4c5425 |
output_text = output.get_data(as_text=True)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# the user can edit the issue
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Ryan Lerch |
e85d33 |
'href="/test/issue/1/edit" title="Edit this issue">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# the user can delete the ticket
|
|
Ryan Lerch |
e85d33 |
self.assertIn(
|
|
Pierre-Yves Chibon |
aede19 |
'
|
|
Ryan Lerch |
e85d33 |
' title="Delete this ticket">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
0541ed |
csrf_token = self.get_csrf(output=output)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# the user can do the following things
|
|
Vivek Anand |
6f20f8 |
# edit metadata
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
aede19 |
'
|
|
Julen Landa Alustiza |
0cafab |
"issue-metadata-display editmetadatatoggle pointer inline-block"
|
|
Pierre-Yves Chibon |
aede19 |
'">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# can view the milestone
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Milestone", output_text)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
4c5425 |
'\n 77',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# can edit them
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Vivek Anand |
6f20f8 |
'
|
|
Vivek Anand |
6f20f8 |
'name="milestone"><option value=""></option>
|
|
Vivek Anand |
6f20f8 |
'value="77">77\n \n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
215f54 |
# can view depending
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Depending on", output_text)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
215f54 |
# can edit depending on
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
215f54 |
'
|
|
Pierre-Yves Chibon |
215f54 |
'\n placeholder="issue depending" name="depending"\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# the user should be able to do public -> private
|
|
Vivek Anand |
6f20f8 |
# the other way round won't be possible since GET and POST
|
|
Vivek Anand |
6f20f8 |
# to this endpoint for this user will be blocked
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# checkbox for private
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Vivek Anand |
6f20f8 |
'<input id="private" name="private" type="checkbox" value="y">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Create private issue
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(self.session, "test")
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.new_issue(
|
|
Vivek Anand |
6f20f8 |
session=self.session,
|
|
Vivek Anand |
6f20f8 |
repo=repo,
|
|
Pierre-Yves Chibon |
73d120 |
title="Test issue",
|
|
Pierre-Yves Chibon |
73d120 |
content="We should work on this",
|
|
Pierre-Yves Chibon |
73d120 |
user="pingou",
|
|
Vivek Anand |
6f20f8 |
private=True,
|
|
Vivek Anand |
6f20f8 |
)
|
|
Vivek Anand |
6f20f8 |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(msg.title, "Test issue")
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Not logged in
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/2")
|
|
Pierre-Yves Chibon |
97f498 |
self.assertEqual(output.status_code, 404)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Wrong user
|
|
Vivek Anand |
6f20f8 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/2")
|
|
Pierre-Yves Chibon |
97f498 |
self.assertEqual(output.status_code, 404)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# reporter
|
|
Pierre-Yves Chibon |
73d120 |
user.username = "pingou"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/2")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
0541ed |
output_text = output.get_data(as_text=True)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Issue #2: Test issue - test - Pagure</title>",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
3a8ee8 |
'
|
|
Pierre-Yves Chibon |
73d120 |
'fa fa-fw fa-lock">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Ryan Lerch |
e85d33 |
'href="/test/issue/2/edit" title="Edit this issue">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.git.update_git")
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.notify.send_email")
|
|
Vivek Anand |
6f20f8 |
def test_view_issue_admin_access(self, p_send_email, p_ugt):
|
|
Vivek Anand |
6f20f8 |
""" Test the view_issue endpoint. when a user has admin access on repo """
|
|
Vivek Anand |
6f20f8 |
p_send_email.return_value = True
|
|
Vivek Anand |
6f20f8 |
p_ugt.return_value = True
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/foo/issue/1")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 404)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
73d120 |
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 404)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Create issues to play with
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(self.session, "test")
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Add user 'foo' with ticket access on repo
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.add_user_to_project(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, repo, new_user="foo", user="pingou", access="admin"
|
|
Vivek Anand |
6f20f8 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(msg, "User added")
|
|
Vivek Anand |
6f20f8 |
self.session.commit()
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(self.session, "test")
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.new_issue(
|
|
Vivek Anand |
6f20f8 |
session=self.session,
|
|
Vivek Anand |
6f20f8 |
repo=repo,
|
|
Pierre-Yves Chibon |
73d120 |
title="Test issue",
|
|
Pierre-Yves Chibon |
73d120 |
content="We should work on this",
|
|
Pierre-Yves Chibon |
73d120 |
user="pingou",
|
|
Vivek Anand |
6f20f8 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(msg.title, "Test issue")
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Add milestone
|
|
Pierre-Yves Chibon |
73d120 |
repo.milestones = {"77": None}
|
|
Vivek Anand |
6f20f8 |
self.session.add(repo)
|
|
Pierre-Yves Chibon |
930073 |
issue = pagure.lib.query.search_issues(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, repo=repo, issueid=1
|
|
Vivek Anand |
6f20f8 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
930073 |
pagure.lib.query.edit_issue(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, issue, user="pingou", milestone="77"
|
|
Vivek Anand |
6f20f8 |
)
|
|
Vivek Anand |
6f20f8 |
self.session.add(repo)
|
|
Vivek Anand |
6f20f8 |
self.session.add(issue)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.set_custom_key_fields(
|
|
Vivek Anand |
6f20f8 |
self.session,
|
|
Vivek Anand |
6f20f8 |
project=repo,
|
|
Pierre-Yves Chibon |
73d120 |
fields=["abc", "xyz"],
|
|
Pierre-Yves Chibon |
73d120 |
types=["boolean", "boolean"],
|
|
Vivek Anand |
6f20f8 |
data=[None, None],
|
|
Vivek Anand |
6f20f8 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(msg, "List of custom fields updated")
|
|
Vivek Anand |
6f20f8 |
self.session.add(repo)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.set_custom_key_value(
|
|
Vivek Anand |
6f20f8 |
self.session,
|
|
Vivek Anand |
6f20f8 |
issue=issue,
|
|
Pierre-Yves Chibon |
73d120 |
key=pagure.lib.query.get_custom_key(self.session, repo, "abc"),
|
|
Pierre-Yves Chibon |
73d120 |
value=1,
|
|
Vivek Anand |
6f20f8 |
)
|
|
Vivek Anand |
6f20f8 |
self.session.add(issue)
|
|
Vivek Anand |
6f20f8 |
self.session.commit()
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 200)
|
|
Vivek Anand |
6f20f8 |
# Not authentified = No edit
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
73d120 |
'
|
|
Pierre-Yves Chibon |
73d120 |
'href="/test/issue/1/edit" title="Edit this issue">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output.get_data(as_text=True),
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
self.assertTrue(
|
|
Vivek Anand |
6f20f8 |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Login\n to comment on this ticket."
|
|
Pierre-Yves Chibon |
73d120 |
in output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
4c5425 |
output_text = output.get_data(as_text=True)
|
|
Vivek Anand |
6f20f8 |
# Not author nor admin = No edit
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Ryan Lerch |
e85d33 |
'href="/test/issue/1/edit" title="Edit this issue">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Julen Landa Alustiza |
581c9c |
'
|
|
Ryan Lerch |
e85d33 |
' title="Delete this ticket">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# no edit metadata
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Julen Landa Alustiza |
581c9c |
' editmetadatatoggle pointer inline-block">'
|
|
Ryan Lerch |
e85d33 |
'',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
0541ed |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
0541ed |
'Login to comment on this ticket.',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# can view the milestone
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Milestone", output_text)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
4c5425 |
'\n 77',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
# but can't edit them
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Vivek Anand |
6f20f8 |
'
|
|
Vivek Anand |
6f20f8 |
' name="milestone"><option value=""></option>
|
|
Vivek Anand |
6f20f8 |
'selected value="77">77',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
215f54 |
# can view depending
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Depending on", output_text)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
215f54 |
# can't edit depending on
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
215f54 |
'
|
|
Pierre-Yves Chibon |
215f54 |
placeholder="issue depending" name="depending"\n\
|
|
Vivek Anand |
6f20f8 |
value="" />',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# no checkbox for private
|
|
Vivek Anand |
6f20f8 |
self.assertNotIn(
|
|
Vivek Anand |
6f20f8 |
'<input id="private" name="private" type="checkbox" value="y">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
user.username = "foo"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
4c5425 |
output_text = output.get_data(as_text=True)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# the user can edit the issue
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Ryan Lerch |
e85d33 |
'href="/test/issue/1/edit" title="Edit this issue">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
aede19 |
'
|
|
Ryan Lerch |
e85d33 |
' title="Delete this ticket">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
0541ed |
csrf_token = self.get_csrf(output=output)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# the user can do the following things
|
|
Vivek Anand |
6f20f8 |
# edit metadata
|
|
Pierre-Yves Chibon |
aede19 |
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
aede19 |
'
|
|
Julen Landa Alustiza |
0cafab |
"issue-metadata-display editmetadatatoggle pointer inline-block"
|
|
Pierre-Yves Chibon |
aede19 |
'">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# can view the milestone
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Milestone", output_text)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
4c5425 |
'\n 77',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# can edit them
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Vivek Anand |
6f20f8 |
'
|
|
Vivek Anand |
6f20f8 |
'name="milestone"><option value=""></option>
|
|
Vivek Anand |
6f20f8 |
'value="77">77\n \n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
215f54 |
# can view depending
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Depending on", output_text)
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
215f54 |
# can edit depending on
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
215f54 |
'
|
|
Pierre-Yves Chibon |
215f54 |
'\n placeholder="issue depending" name="depending"\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# the user should be able to do public -> private
|
|
Vivek Anand |
6f20f8 |
# the other way round won't be possible since GET and POST
|
|
Vivek Anand |
6f20f8 |
# to this endpoint for this user will be blocked
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# checkbox for private
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Vivek Anand |
6f20f8 |
'<input id="private" name="private" type="checkbox" value="y">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Create private issue
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(self.session, "test")
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.new_issue(
|
|
Vivek Anand |
6f20f8 |
session=self.session,
|
|
Vivek Anand |
6f20f8 |
repo=repo,
|
|
Pierre-Yves Chibon |
73d120 |
title="Test issue",
|
|
Pierre-Yves Chibon |
73d120 |
content="We should work on this",
|
|
Pierre-Yves Chibon |
73d120 |
user="pingou",
|
|
Vivek Anand |
6f20f8 |
private=True,
|
|
Vivek Anand |
6f20f8 |
)
|
|
Vivek Anand |
6f20f8 |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(msg.title, "Test issue")
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Not logged in
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/2")
|
|
Pierre-Yves Chibon |
97f498 |
self.assertEqual(output.status_code, 404)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# Wrong user
|
|
Vivek Anand |
6f20f8 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/2")
|
|
Pierre-Yves Chibon |
97f498 |
self.assertEqual(output.status_code, 404)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
# reporter
|
|
Pierre-Yves Chibon |
73d120 |
user.username = "pingou"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/2")
|
|
Vivek Anand |
6f20f8 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
0541ed |
output_text = output.get_data(as_text=True)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Issue #2: Test issue - test - Pagure</title>",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
3a8ee8 |
'
|
|
Pierre-Yves Chibon |
73d120 |
'fa fa-fw fa-lock">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
self.assertIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Ryan Lerch |
e85d33 |
'href="/test/issue/2/edit" title="Edit this issue">\n',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Vivek Anand |
6f20f8 |
|
|
Vivek Anand |
6f20f8 |
|
|
Pierre-Yves Chibon |
73d120 |
if __name__ == "__main__":
|
|
Pierre-Yves Chibon |
393f31 |
unittest.main(verbosity=2)
|