Add support to vulnerability alert and automated security fixes APIs (#1195)

* Add functions about automated security fixes and vulnerability alerts

* Refine methods and add unit test

* Add record

* Update record file  - change user name

* Add get vulnerability alert function

* Fix typo

* Create file for testCreateFile

* Add tests

* Add unit test

* Simplify assert statement
This commit is contained in:
Will Li
2019-08-08 12:24:33 +10:00
committed by Steve Kowalik
parent 7ddb657d47
commit 8abd50e225
12 changed files with 268 additions and 2 deletions
+60
View File
@@ -2687,6 +2687,66 @@ class Repository(github.GithubObject.CompletableGithubObject):
input=post_parameters
)
def get_vulnerability_alert(self):
"""
:calls: `GET /repos/:owner/:repo/vulnerability-alerts <http://developer.github.com/v3/repos>`_
:rtype: bool
"""
status, _, _ = self._requester.requestJson(
"GET",
self.url + "/vulnerability-alerts",
headers={'Accept': Consts.vulnerabilityAlertsPreview}
)
return status == 204
def enable_vulnerability_alert(self):
"""
:calls: `PUT /repos/:owner/:repo/vulnerability-alerts <http://developer.github.com/v3/repos>`_
:rtype: bool
"""
status, _, _ = self._requester.requestJson(
"PUT",
self.url + "/vulnerability-alerts",
headers={'Accept': Consts.vulnerabilityAlertsPreview}
)
return status == 204
def disable_vulnerability_alert(self):
"""
:calls: `DELETE /repos/:owner/:repo/vulnerability-alerts <http://developer.github.com/v3/repos>`_
:rtype: bool
"""
status, _, _ = self._requester.requestJson(
"DELETE",
self.url + "/vulnerability-alerts",
headers={'Accept': Consts.vulnerabilityAlertsPreview}
)
return status == 204
def enable_automated_security_fixes(self):
"""
:calls: `PUT /repos/:owner/:repo/automated-security-fixes <http://developer.github.com/v3/repos>`_
:rtype: bool
"""
status, _, _ = self._requester.requestJson(
"PUT",
self.url + "/automated-security-fixes",
headers={'Accept': Consts.automatedSecurityFixes}
)
return status == 204
def disable_automated_security_fixes(self):
"""
:calls: `DELETE /repos/:owner/:repo/automated-security-fixes <http://developer.github.com/v3/repos>`_
:rtype: bool
"""
status, _, _ = self._requester.requestJson(
"DELETE",
self.url + "/automated-security-fixes",
headers={'Accept': Consts.automatedSecurityFixes}
)
return status == 204
def remove_from_collaborators(self, collaborator):
"""
:calls: `DELETE /repos/:owner/:repo/collaborators/:user <http://developer.github.com/v3/repos/collaborators>`_