Created
January 23, 2013 12:48
-
-
Save iurisilvio/4605176 to your computer and use it in GitHub Desktop.
EJTP-console script test related with issue https://github.com/campadrenalin/EJTP-lib-python/issues/53 and pull request https://github.com/campadrenalin/EJTP-lib-python/pull/56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ~/.ejtp/console/idents.json | |
{ | |
"[\"local\",null,\"mitzi\"]": { | |
"encryptor": [ | |
"rsa", | |
"-----BEGIN RSA PRIVATE KEY-----\nMIICXAIBAAKBgQDAZQNip0GPxFZsyxcgIgyvuPTHsruu66DBsESG5/Pfbcye3g4W\nwfg+dBP3IfUnLB4QXGzK42BAd57fCBXOtalSOkFoze/C2q74gYFBMvIPbEfef8yQ\n83uoNkYAFBVp6yNlT51IQ2mY19KpqoyxMZftxwdtImthE5UG1knZE64sIwIDAQAB\nAoGAIGjjyRqj0LQiWvFbU+5odLGTipBxTWYkDnzDDnbEfj7g2WJOvUavqtWjB16R\nDahA6ECpkwP6kuGTwb567fdsLkLApwwqAtpjcu96lJpbRC1nq1zZjwNB+ywssqfV\nV3R2/rgIEE6hsWS1wBHufJeqBZtlkeUp/VEx/uopyuR/WgECQQDJOaFSutj1q1dt\nNO23Q6w3Ie4uMQ59rWeRxXA5+KjDZCxrizzo/Bew5ZysJzHB2n8QQ15WJ7gTSjwJ\nMQdl/7SJAkEA9MQG/6JivkhUNh45xMYqnMHuutyIeGE17QndSfknU+8CX9UBLjsL\nw1QU+llJ3iYfMPEDaydn0HJ8+iinyyAISwJAe7Z2vEorwT5KTdXQoG92nZ66tKNs\naVAG8NQWH04FU7tuo9/C3uq+Ff/UxvKB4NDYdcM1aHqa7SEir/P4vHjtIQJAFKc9\n1/BB2MCNqoteYIZALj4HAOl+8nlxbXD5pTZK5UAzuRZmJRqCYZcEtiM2onIhC6Yq\nna4Tink+pnUrw24OhQJBAIjujQS5qwOf2p5yOqU3UYsBv7PS8IitmYFARTlcYh1G\nrmcIPHRtkxIwNuFxy3ZRRPEDGFa82id5QHUJT8sJbqY=\n-----END RSA PRIVATE KEY-----" | |
], | |
"name": "[email protected]", | |
"location": [ | |
"local", | |
null, | |
"mitzi" | |
] | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ~/.ejtp/idents.json | |
{ | |
"[\"local\",null,\"mitzi\"]": { | |
"encryptor": [ | |
"rsa", | |
"-----BEGIN RSA PRIVATE KEY-----\nMIICXAIBAAKBgQDAZQNip0GPxFZsyxcgIgyvuPTHsruu66DBsESG5/Pfbcye3g4W\nwfg+dBP3IfUnLB4QXGzK42BAd57fCBXOtalSOkFoze/C2q74gYFBMvIPbEfef8yQ\n83uoNkYAFBVp6yNlT51IQ2mY19KpqoyxMZftxwdtImthE5UG1knZE64sIwIDAQAB\nAoGAIGjjyRqj0LQiWvFbU+5odLGTipBxTWYkDnzDDnbEfj7g2WJOvUavqtWjB16R\nDahA6ECpkwP6kuGTwb567fdsLkLApwwqAtpjcu96lJpbRC1nq1zZjwNB+ywssqfV\nV3R2/rgIEE6hsWS1wBHufJeqBZtlkeUp/VEx/uopyuR/WgECQQDJOaFSutj1q1dt\nNO23Q6w3Ie4uMQ59rWeRxXA5+KjDZCxrizzo/Bew5ZysJzHB2n8QQ15WJ7gTSjwJ\nMQdl/7SJAkEA9MQG/6JivkhUNh45xMYqnMHuutyIeGE17QndSfknU+8CX9UBLjsL\nw1QU+llJ3iYfMPEDaydn0HJ8+iinyyAISwJAe7Z2vEorwT5KTdXQoG92nZ66tKNs\naVAG8NQWH04FU7tuo9/C3uq+Ff/UxvKB4NDYdcM1aHqa7SEir/P4vHjtIQJAFKc9\n1/BB2MCNqoteYIZALj4HAOl+8nlxbXD5pTZK5UAzuRZmJRqCYZcEtiM2onIhC6Yq\nna4Tink+pnUrw24OhQJBAIjujQS5qwOf2p5yOqU3UYsBv7PS8IitmYFARTlcYh1G\nrmcIPHRtkxIwNuFxy3ZRRPEDGFa82id5QHUJT8sJbqY=\n-----END RSA PRIVATE KEY-----" | |
], | |
"name": "[email protected]", | |
"location": [ | |
"local", | |
null, | |
"mitzi" | |
] | |
}, | |
"[\"local\",null,\"victor\"]": { | |
"encryptor": [ | |
"rsa", | |
"-----BEGIN RSA PRIVATE KEY-----\nMIICXAIBAAKBgQC6efOadLJZpX837OIpAlqO2NQEfOA1DE8lfC1q8fKGtMlEl8Oq\nR9lbEiMdsbg5M902Gi33UMlJuap+5TaGEBJDBJZNr3d2LFOjlEPGyJeqiu5PnBjX\n3vZx97y+NUm71rsL7k1KRjzAQnuCPSSqQdo5GLdNODgTa2ljXQ4Khd/9CwIDAQAB\nAoGARbSkfQ42RRB6N7uS5uV8WH1w86SCYxIQ2+BJUfrTP8uAmOVqPNLSyxpCii0O\nwkNC46BxoktOkwKWWwzvjrmfOU2hEga3ny/S1r2VU6nfex29ozl+gUD7zEkB8MaV\nQqnRF18gkeGvHcCMU5nSbjYaosp39yj9qBcRDePQIWN3aRECQQDCj8FWSyrP/zoN\n+6YR3j/0Ty6b43KDU3fcvG/+IvHhB+OFawiPlR3uPGYVJG0CfbWC/QEtx90VcGi5\nOnaQRtsXAkEA9VyYg5+5ZzfbfGqZZZRvPHk08rsquAXnGWkT67lobkBtWvx0TxYo\nTKi8PwLZ8paLA3wf2VDJ6/Ufn5APOtSWLQJAP5cUrcurlofoxaE2SijF5mfq5/CT\nAPFK/85nHDz3qYEWkAjHp4YpXjBHfSmGp4XGyaU/uWLVk6hF0iSVk9pUyQJACNya\nSY64RIkY7UpwVeHhjp6WEfo+lbzo1tsbtBTTN8At8u5RSRX0yKgDfIce1gsn5C1U\nfSXU1SfaR4oNcsOA1QJBAKDEQ4PATuH46E7e3Ie+A5AUVSyLqO5H2SC0yg6zduG6\npxbmsfpVLOfko+j9YrH+OdD5WIAjN/wL1CtmVhqSLr8=\n-----END RSA PRIVATE KEY-----" | |
], | |
"name": "[email protected]", | |
"location": [ | |
"local", | |
null, | |
"victor" | |
] | |
}, | |
"[\"local\",null,\"atlas\"]": { | |
"encryptor": [ | |
"rsa", | |
"-----BEGIN RSA PRIVATE KEY-----\nMIICXgIBAAKBgQCvCM8MTSOSeA8G62b9Fg2Ic18JoHoswqn7kmU+qmYxJnTd0rSS\nYaQWiSflchTBgGcbItR4jsktYifOSfp7Cl1k5IHXqGKLHtIt8Fo02k/ajR5DzGJN\n2yAJfbBCi43ifOaVKwjuJqcFKhuPUqNJecFn8m62QOQehrIlUAlnnM7OXQIDAQAB\nAoGBAJGrVRU5xZcKUAdENkv+5Hhg/AE5CzThNTJnXddPXQkepjhOOXVxyWvv7cIo\ntVltEWImFInY21jnzZUDQHDR6XLCe8B3LRlOWrkv7+byesIFkNH9C7uvheD5xxiG\nzPpOkpwcms3QW+/FmhN5Wia+4oeHB4J9uAjJmNoaddfqAhWBAkEAwdEjMzJaKIx5\n6OIyYAEnC6lvVI6Qx/ssKQH7GhaItxzLZRaIaK4XUgrL5q1OHNNCCFgREw7nhyu3\nZnt8v833rQJBAOcw/wQ0iQktluqKoT4i73hRkGk7MTB2Y/4e2YTVnypUtQC+jxs1\nND3CJj59oJojfA3SJg0M0pWXcMKIIhRxx3ECQQCVl6zafBeYSmxhsgx9iwYu+xSh\np/PZVmTMNeowRYo6AvB90nlwikYXnZupLMQofWnu9MIg+pT7AGPqpo8vn3J1AkAU\nowEAhRf+Y71m7jz6aO/rU4yKeCgp5UeDtYlBHDh69Ni7Wkc37IXfRWdYiKo/WA+I\nxEt1OsHJbJ06ICC6pnVhAkEAio1qXj8vLi9t9xocRe8LIthaYBslw4B8yY69fRhd\nuQifuvld7xjeXsfCWRmA4t72SmcAyzMaG5wnqhLNeCXXYw==\n-----END RSA PRIVATE KEY-----" | |
], | |
"name": "[email protected]", | |
"location": [ | |
"local", | |
null, | |
"atlas" | |
] | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
||| What interface do you want to use? | |
||| Available interfaces: [email protected], [email protected], [email protected] | |
$ [email protected] | |
||| Enter a command [messages | send | set client | eval | quit] | |
$ send | |
||| What interface do you want to send to? | |
||| Example: ["udp4", ["127.0.0.1", 5803], "caroline"] | |
$ ["local", null, "mitzi"] | |
||| What message do you want to send? | |
$ "test" | |
||| Enter a command [messages | send | set client | eval | quit] | |
$ messages | |
All messages: | |
-------------------------------------------------------------------------------- | |
["local", null, "mitzi"](at 01/23/13 10:41:22): | |
"test" | |
||| Enter a command [messages | send | set client | eval | quit] | |
$ eval | |
$ 2 ** 10 | |
1024 | |
||| Enter a command [messages | send | set client | eval | quit] | |
$ set client | |
||| What interface do you want to use? | |
||| Available interfaces: [email protected], [email protected], [email protected] | |
$ [email protected] | |
||| Enter a command [messages | send | set client | eval | quit] | |
$ send | |
||| What interface do you want to send to? | |
||| Example: ["udp4", ["127.0.0.1", 5803], "caroline"] | |
$ ["local", null, "mitzi"] | |
||| What message do you want to send? | |
$ "test2" | |
||| Enter a command [messages | send | set client | eval | quit] | |
$ messages | |
All messages: | |
-------------------------------------------------------------------------------- | |
["local", null, "mitzi"](at 01/23/13 10:41:22): | |
"test" | |
-------------------------------------------------------------------------------- | |
["local", null, "victor"](at 01/23/13 10:41:22): | |
"test2" | |
||| Enter a command [messages | send | set client | eval | quit] | |
$ quit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# scripts/test.py | |
import os | |
import imp | |
import json | |
ROOT = os.path.split(__file__)[0] | |
# load ejtp-console as a module | |
with open(os.path.join(ROOT, 'ejtp-console'), 'rb') as fp: | |
console = imp.load_module('console', fp, 'ejtp-console', ('.py', 'rb', imp.PY_SOURCE)) | |
# define input messages | |
inputs = [ | |
"[email protected]", | |
"send", | |
json.dumps(["local", None, "mitzi"]), | |
json.dumps("test"), | |
"messages", | |
"eval", | |
"2 ** 10", | |
"set client", | |
"[email protected]", | |
"send", | |
json.dumps(["local", None, "mitzi"]), | |
json.dumps("test2"), | |
"messages", | |
"quit" | |
] | |
def input_func(prompt): | |
global inputs | |
print prompt, | |
try: | |
obj = inputs.pop(0) | |
except IndexError: | |
raise KeyboardInterrupt() | |
print "$", obj | |
return obj | |
# override raw_input builtin | |
console.raw_input = input_func | |
# run interactive console | |
inter = console.Interactive() | |
inter.repl() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment