<s> from oslo_config import cfg <EOL> from nova . cloudpipe import pipelib <EOL> from nova import context <EOL> from nova import crypto <EOL> from nova import test <EOL> from nova import utils <EOL> CONF = cfg . CONF <EOL> class PipelibTest ( test . TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( PipelibTest , self ) . setUp ( ) <EOL> self . cloudpipe = pipelib . CloudPipe ( ) <EOL> self . project = "<STR_LIT>" <EOL> self . user = "<STR_LIT>" <EOL> self . context = context . RequestContext ( self . user , self . project ) <EOL> def test_get_encoded_zip ( self ) : <EOL> with utils . tempdir ( ) as tmpdir : <EOL> self . flags ( ca_path = tmpdir , group = '<STR_LIT>' ) <EOL> crypto . ensure_ca_filesystem ( ) <EOL> ret = self . cloudpipe . get_encoded_zip ( self . project ) <EOL> self . assertTrue ( ret ) <EOL> def test_launch_vpn_instance ( self ) : <EOL> self . stubs . Set ( self . cloudpipe . compute_api , <EOL> "<STR_LIT>" , <EOL> lambda * a , ** kw : ( None , "<STR_LIT>" ) ) <EOL> with utils . tempdir ( ) as tmpdir : <EOL> self . flags ( ca_path = tmpdir , keys_path = tmpdir , group = '<STR_LIT>' ) <EOL> crypto . ensure_ca_filesystem ( ) <EOL> self . cloudpipe . launch_vpn_instance ( self . context ) <EOL> def test_setup_security_group ( self ) : <EOL> group_name = "<STR_LIT>" % ( self . project , CONF . vpn_key_suffix ) <EOL> res1_group = self . cloudpipe . setup_security_group ( self . context ) <EOL> self . assertEqual ( res1_group , group_name ) <EOL> res2_group = self . cloudpipe . setup_security_group ( self . context ) <EOL> self . assertEqual ( res1_group , res2_group ) <EOL> def test_setup_key_pair ( self ) : <EOL> key_name = "<STR_LIT>" % ( self . project , CONF . vpn_key_suffix ) <EOL> with utils . tempdir ( ) as tmpdir : <EOL> self . flags ( keys_path = tmpdir , group = '<STR_LIT>' ) <EOL> res1_key = self . cloudpipe . setup_key_pair ( self . context ) <EOL> self . assertEqual ( res1_key , key_name ) <EOL> res2_key = self . cloudpipe . setup_key_pair ( self . context ) <EOL> self . assertEqual ( res2_key , res1_key ) </s>
