Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Jul 2015 10:52:47 +0000 (UTC)
From:      Kubilay Kocak <koobs@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r392126 - in head/devel/py-phabricator: . files
Message-ID:  <201507151052.t6FAqlJs010131@svnmir.geo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: koobs
Date: Wed Jul 15 10:52:47 2015
New Revision: 392126
URL: https://svnweb.freebsd.org/changeset/ports/392126

Log:
  devel/py-phabricator: Support token-based authentication
  
  Backport upstream pull request #23 [1] that adds support for new style
  token-based authentication. This PR fixes issue #22 [2]. Additionally
  modify the patch to add the token argument to the and of the argument
  list as per upstream pull request comment.
  
  This change fixes errors associated with not being able to find 'user'
  or 'cert' configuration keys (in ~/.arcrc) keys when using token based
  authentication.
  
  This was reproducible with deskutils/py-bugwarrior
  
  - Sort Makefile
  - Sort USE_PYTHON values
  - Canonicalize regression-test invocation
  
  [1] https://github.com/disqus/python-phabricator/pull/23
  [2] https://github.com/disqus/python-phabricator/issues/22
  
  Approved by:		sbz (maintainer)
  Differential Revision:	https://reviews.freebsd.org/D2983

Added:
  head/devel/py-phabricator/files/
  head/devel/py-phabricator/files/patch-phabricator_____init____.py   (contents, props changed)
  head/devel/py-phabricator/files/patch-phabricator_tests.py   (contents, props changed)
Modified:
  head/devel/py-phabricator/Makefile

Modified: head/devel/py-phabricator/Makefile
==============================================================================
--- head/devel/py-phabricator/Makefile	Wed Jul 15 10:16:35 2015	(r392125)
+++ head/devel/py-phabricator/Makefile	Wed Jul 15 10:52:47 2015	(r392126)
@@ -3,6 +3,7 @@
 
 PORTNAME=	phabricator
 PORTVERSION=	0.4.0
+PORTREVISION=	1
 CATEGORIES=	devel python
 MASTER_SITES=	CHEESESHOP
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
@@ -13,19 +14,19 @@ COMMENT=	Phabricator API Bindings
 LICENSE=	APACHE20
 LICENSE_FILE=	${WRKSRC}/LICENSE
 
-USES=		python
-USE_PYTHON=	distutils autoplist
-
-OPTIONS_DEFINE=	TESTS
-
 TEST_DEPENDS=	${PYTHON_PKGNAMEPREFIX}nose>0:${PORTSDIR}/devel/py-nose \
 		${PYTHON_PKGNAMEPREFIX}mock>0:${PORTSDIR}/devel/py-mock \
 		${PYTHON_PKGNAMEPREFIX}unittest2>0:${PORTSDIR}/devel/py-unittest2
 
+USES=		python
+USE_PYTHON=	autoplist distutils
+
+OPTIONS_DEFINE=	TESTS
+
 TESTS_DESC=		Include test suite requirements
 TESTS_BUILD_DEPENDS=	${TEST_DEPENDS}
 
 regression-test: build
-	@cd ${WRKSRC} && ${PYTHON_CMD} ${PYSETUP} test
+	@cd ${WRKSRC} && ${PYTHON_CMD} ${PYDISTUTILS_SETUP} test
 
 .include <bsd.port.mk>

Added: head/devel/py-phabricator/files/patch-phabricator_____init____.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/py-phabricator/files/patch-phabricator_____init____.py	Wed Jul 15 10:52:47 2015	(r392126)
@@ -0,0 +1,38 @@
+--- phabricator/__init__.py.orig	2013-11-26 21:00:52 UTC
++++ phabricator/__init__.py
+@@ -288,15 +288,19 @@ class Phabricator(Resource):
+     }
+ 
+     def __init__(self, username=None, certificate=None, host=None,
+-            timeout=5, response_format='json', **kwargs):
++            timeout=5, response_format='json', token=None, **kwargs):
+ 
+         # Set values in ~/.arcrc as defaults
+         if ARCRC:
+             self.host = host if host else ARCRC['hosts'].keys()[0]
+-            self.username = username if username else ARCRC['hosts'][self.host]['user']
+-            self.certificate = certificate if certificate else ARCRC['hosts'][self.host]['cert']
++            if token or ARCRC['hosts'][self.host].has_key('token'):
++                self.token = token if token else ARCRC['hosts'][self.host]['token']
++            else:
++                self.username = username if username else ARCRC['hosts'][self.host]['user']
++                self.certificate = certificate if certificate else ARCRC['hosts'][self.host]['cert']
+         else:
+             self.host = host
++            self.token = token
+             self.username = username
+             self.certificate = certificate
+ 
+@@ -313,6 +317,12 @@ class Phabricator(Resource):
+         raise SyntaxError('You cannot call the Conduit API without a resource.')
+ 
+     def connect(self):
++        if self.token:
++            self.conduit = {
++                'token': self.token
++            }
++            return
++
+         auth = Resource(api=self, method='conduit', endpoint='connect')
+ 
+         response = auth(user=self.username, host=self.host,

Added: head/devel/py-phabricator/files/patch-phabricator_tests.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/py-phabricator/files/patch-phabricator_tests.py	Wed Jul 15 10:52:47 2015	(r392126)
@@ -0,0 +1,12 @@
+--- phabricator/tests.py.orig	2013-11-23 04:51:16 UTC
++++ phabricator/tests.py
+@@ -9,6 +9,9 @@ RESPONSES = {
+     'maniphest.find': '{"result":{"PHID-TASK-4cgpskv6zzys6rp5rvrc":{"id":"722","phid":"PHID-TASK-4cgpskv6zzys6rp5rvrc","authorPHID":"PHID-USER-5022a9389121884ab9db","ownerPHID":"PHID-USER-5022a9389121884ab9db","ccPHIDs":["PHID-USER-5022a9389121884ab9db","PHID-USER-ba8aeea1b3fe2853d6bb"],"status":"3","priority":"Needs Triage","title":"Relations should be two-way","description":"When adding a differential revision you can specify Maniphest Tickets to add the relation. However, this doesnt add the relation from the ticket -> the differently.(This was added via the commit message)","projectPHIDs":["PHID-PROJ-358dbc2e601f7e619232","PHID-PROJ-f58a9ac58c333f106a69"],"uri":"https:\/\/secure.phabricator.com\/T722","auxiliary":[],"objectName":"T722","dateCreated":"1325553508","dateModified":"1325618490"}},"error_code":null,"error_info":null}'
+ }
+ 
++# Protect against local user's .arcrc interference.
++phabricator.ARCRC = {}
++
+ class PhabricatorTest(unittest.TestCase):
+     def setUp(self):
+         self.api = phabricator.Phabricator(username='test', certificate='test', host='http://localhost')



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507151052.t6FAqlJs010131>