| |
@@ -2,36 +2,32 @@
|
| |
import unittest
|
| |
import configparser
|
| |
from ..copr_rpmbuild.providers.spec import SpecUrlProvider
|
| |
+ from . import TestCase
|
| |
|
| |
|
| |
- class TestSpecUrlProvider(unittest.TestCase):
|
| |
+ class TestSpecUrlProvider(TestCase):
|
| |
def setUp(self):
|
| |
+ super(TestSpecUrlProvider, self).setUp()
|
| |
self.source_json = {"url": u"http://foo.ex/somepackage.spec"}
|
| |
self.resultdir = "/path/to/resultdir"
|
| |
|
| |
def test_init(self):
|
| |
- provider = SpecUrlProvider(self.source_json, self.resultdir)
|
| |
+ provider = SpecUrlProvider(self.source_json, self.resultdir, self.config)
|
| |
self.assertEqual(provider.url, "http://foo.ex/somepackage.spec")
|
| |
|
| |
@mock.patch('requests.get')
|
| |
@mock.patch("rpmbuild.copr_rpmbuild.providers.spec.run_cmd")
|
| |
@mock.patch('builtins.open', new_callable=mock.mock_open())
|
| |
def test_produce_srpm(self, mock_open, run_cmd, mock_get):
|
| |
- provider = SpecUrlProvider(self.source_json, self.resultdir)
|
| |
+ provider = SpecUrlProvider(self.source_json, self.resultdir, self.config)
|
| |
provider.produce_srpm()
|
| |
run_cmd.assert_called_with(["rpkg", "srpm", "--outdir", self.resultdir,
|
| |
"--spec", '{}/somepackage.spec'.format(provider.workdir)],
|
| |
cwd=provider.workdir)
|
| |
|
| |
- @mock.patch('builtins.open', new_callable=mock.mock_open())
|
| |
- def test_create_rpmmacros(self, mock_open):
|
| |
- provider = SpecUrlProvider(self.source_json, self.resultdir)
|
| |
- provider.create_rpmmacros()
|
| |
- mock_open.assert_called_with("{}/.rpmmacros".format(provider.workdir), "w")
|
| |
-
|
| |
@mock.patch('requests.get')
|
| |
@mock.patch('builtins.open', new_callable=mock.mock_open())
|
| |
def test_save_spec(self, mock_open, mock_get):
|
| |
- provider = SpecUrlProvider(self.source_json, self.resultdir)
|
| |
+ provider = SpecUrlProvider(self.source_json, self.resultdir, self.config)
|
| |
provider.save_spec()
|
| |
mock_open.assert_called_with("{}/somepackage.spec".format(provider.workdir), "w")
|
| |
Ad. https://bugzilla.redhat.com/show_bug.cgi?id=1536846.
Currently users are open to "source attacks" (e.g. man-in-the-middle) if they are using insecure protocols for Source directive in spec file. This PR prevents using insecure protocols by default by limiting curl protocols (the tool that is used by rpmbuild for downloading sources) to "https" and "ftps". This is just a default setting. Other COPR deployments may allow usage of other protocols if they want to.