dynamist / phabfive

A command line tool to interact with Phabricator
Apache License 2.0
4 stars 2 forks source link

Raise exception when Conduit access is not accepted for Passphrase #21

Closed maiyuki closed 5 years ago

maiyuki commented 5 years ago

Before: phabfive passphrase K1

(empty)

phabfive passphrase K2

<password K2 shown>

After: phabfive passphrase K1

This private material for this credential is not accessible via API calls.

phabfive passphrase K2

<password K2 shown>

When using print function to check what self.phab.passphrase.query returns you can see that the key value material returns a dict with different key values. In this case it returns key value password when you can access the secret via API, or noAPIAccess when you cannot access the secret via API. From this the we can catch noAPIAccess and raise is as an Exception.

phabfive passphrase K1 (with print function)

'material': {'noAPIAccess': 'This private material for this credential is not accessible via API calls.'}}}, 'cursor': {'limit': 100, 'after': None, 'before': None}}>

phabfive passphrase K2 (with print function)

'material': {'password': '<password K2 shown>'}}}, 'cursor': {'limit': 100, 'after': None, 'before': None}}>
holmboe commented 5 years ago

Quick question: if I do phabfive passphrase K1 is the exit status non-zero? Verify with echo $?. It is preferable that we exit with non-zero when the Conduit API access is not granted.

maiyuki commented 5 years ago

Quick question: if I do phabfive passphrase K1 is the exit status non-zero? Verify with echo $?. It is preferable that we exit with non-zero when the Conduit API access is not granted.

~/dynamist/phabfive(feature/passphrase-conduit-access*) » phabfive passphrase K1                   
This private material for this credential is not accessible via API calls.

~/dynamist/phabfive(feature/passphrase-conduit-access*) » echo $?                                  
1

@holmboe exit status 1

holmboe commented 5 years ago

@holmboe exit status 1

Nice! :+1: