Test Author: Kevin
If it breaks: Kevin 

This will test our ability to generate and enforce keycodes.

1) Find spark_private.pem and spark_public.pem in bts\spark\src\lib\utils\crypto copy them to your sparkd binary location

2) Now generate a keycode to a file:  

./sparkd keycode encode -keyfile:spark_private.pem -pass:BT5u53r -users:1 -expiration:2020-05-18 > test.pem

3) Now decode the keycode 

./sparkd keycode decode -keyfile:spark_public.pem -source:test.pem

You should see keycode details printed to screen

4) Now test concurrent logins.  Start a sparkd.  Make sure bts_2 and bts_3 have market data permission
	a) Start a spark -multiple login as bts and go to where you would see some market data
	b) Start another spark -multiple but log in as bts_2 and display some data
	c) Start a third spark -multiple, log in as bts_2 and display some data.  
	
	-You should see the data zero out on the first instance logged in as bts_2 and data ticking on the bts instance as well as 
	the second bts_2 instance
	
	d) Kill your sparkd but leave your shells open
   e) bring sparkd back up, you should see market data in the shell logged in as bts AND one of the other shells
	
4.5) For extra credit generate a keycode with -allow_concurrent and make sure we don't zero the market data for concurrent logins

5) Test expiration.  Generate a keycode in the past:

./sparkd keycode encode -keyfile:spark_private.pem -pass:BT5u53r -users:1 -expiration:2018-05-18 > ~/sparkdata/conf/keycode.conf

	a) start sparkd again.
	b) Start a spark -multiple login as bts_2 and go to where you would see some market data.  You should NOT see data
	c) Start a spark -multiple login as bts, you should see data.
	d) remove the expired keycode you just generated by:
	rm ~/sparkdata/conf/keycode.conf
	e) restart sparkd, you should see data as normal in bts_2
	
6) Test admin vs trading logins
Note that an admin login is one that does not have trading permission in any account
AND does not have the ability to see any market data

	a) start sparkd again.  make sure bts_2 and bts_3 have market data and trading permissions in webui
	b) Start a spark -multiple login as bts_2 and go to where you would see some market data.  You should see data
	c) Start a webui and log in as bts_3, you should see data
	d) close your shell and log out of web ui, now log in bts_3 into the webui and log in bts_2 in a shell (
	this is the reverse of the previous order), you should see a message in the shell about keycodes, but it will let you log in, just not see market data
	e) from the webui, de-permission bts_3 from trading AND market data, 
	f) exit shell, log out of webui and kill sparkd, restart sparkd
	
	g)now try d again-- you should not get the same shell error


