<s> """<STR_LIT>""" <EOL> import mox <EOL> import stubout <EOL> from google . apputils import app <EOL> from google . apputils import basetest <EOL> from tests . simian import test_settings <EOL> from simian . auth import util <EOL> class SettingsModuleTest ( mox . MoxTestBase ) : <EOL> def setUp ( self ) : <EOL> mox . MoxTestBase . setUp ( self ) <EOL> self . stubs = stubout . StubOutForTesting ( ) <EOL> self . settings = self . _GetTestSettings ( ) <EOL> def tearDown ( self ) : <EOL> self . mox . UnsetStubs ( ) <EOL> self . stubs . UnsetAll ( ) <EOL> def _GetTestSettings ( self ) : <EOL> """<STR_LIT>""" <EOL> m = type ( test_settings ) ( '<STR_LIT>' ) <EOL> for k in dir ( test_settings ) : <EOL> if k [ <NUM_LIT:0> ] >= '<STR_LIT:A>' and k [ <NUM_LIT:0> ] <= '<STR_LIT>' : <EOL> setattr ( m , k , getattr ( test_settings , k ) ) <EOL> return m <EOL> def testCaIdRe ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertTrue ( util . CA_ID_RE . search ( '<STR_LIT>' ) is not None ) <EOL> self . assertTrue ( util . CA_ID_RE . search ( '<STR_LIT>' ) is not None ) <EOL> self . assertTrue ( util . CA_ID_RE . search ( '<STR_LIT>' ) is None ) <EOL> self . assertTrue ( util . CA_ID_RE . search ( '<STR_LIT>' ) is None ) <EOL> self . assertTrue ( util . CA_ID_RE . search ( '<STR_LIT>' ) is None ) <EOL> def testGetCaIdWhenNone ( self ) : <EOL> """<STR_LIT>""" <EOL> self . settings . CA_ID = None <EOL> self . mox . ReplayAll ( ) <EOL> ca_id = util . GetCaId ( self . settings ) <EOL> self . assertTrue ( ca_id is None ) <EOL> self . mox . VerifyAll ( ) <EOL> def testGetCaIdWhenFoo ( self ) : <EOL> """<STR_LIT>""" <EOL> self . settings . CA_ID = '<STR_LIT>' <EOL> self . mox . ReplayAll ( ) <EOL> ca_id = util . GetCaId ( self . settings ) <EOL> self . assertEqual ( ca_id , '<STR_LIT>' ) <EOL> self . mox . VerifyAll ( ) <EOL> def testGetCaParametersWithOmitServerPrivateKey ( self ) : <EOL> """<STR_LIT>""" <EOL> self . settings . CA_ID = None <EOL> self . mox . StubOutWithMock ( util , '<STR_LIT>' ) <EOL> util . GetCaId ( self . settings ) . AndReturn ( None ) <EOL> self . mox . ReplayAll ( ) <EOL> p = util . GetCaParameters ( self . settings , omit_server_private_key = True ) <EOL> self . assertEqual ( p . ca_public_cert_pem , self . settings . CA_PUBLIC_CERT_PEM ) <EOL> self . assertEqual ( <EOL> p . server_public_cert_pem , self . settings . SERVER_PUBLIC_CERT_PEM ) <EOL> self . assertEqual ( p . required_issuer , self . settings . REQUIRED_ISSUER ) <EOL> self . assertEqual ( p . server_private_key_pem , None ) <EOL> self . assertTrue ( p . ca_id is None ) <EOL> self . mox . VerifyAll ( ) <EOL> def testGetCaParametersWhenFollowCaIdValueNone ( self ) : <EOL> """<STR_LIT>""" <EOL> self . settings . CA_ID = None <EOL> self . mox . StubOutWithMock ( util , '<STR_LIT>' ) <EOL> util . GetCaId ( self . settings ) . AndReturn ( None ) <EOL> self . mox . ReplayAll ( ) <EOL> p = util . GetCaParameters ( self . settings ) <EOL> self . assertEqual ( p . ca_public_cert_pem , self . settings . CA_PUBLIC_CERT_PEM ) <EOL> self . assertEqual ( <EOL> p . server_public_cert_pem , self . settings . SERVER_PUBLIC_CERT_PEM ) <EOL> self . assertEqual ( p . server_private_key_pem , '<STR_LIT>' ) <EOL> self . assertEqual ( p . required_issuer , self . settings . REQUIRED_ISSUER ) <EOL> self . assertTrue ( p . ca_id is None ) <EOL> self . mox . VerifyAll ( ) <EOL> def testGetCaParametersWhenForcePrimaryCaSettings ( self ) : <EOL> """<STR_LIT>""" <EOL> self . mox . StubOutWithMock ( util , '<STR_LIT>' ) <EOL> self . mox . ReplayAll ( ) <EOL> p = util . GetCaParameters ( self . settings , None ) <EOL> self . assertEqual ( p . ca_public_cert_pem , self . settings . CA_PUBLIC_CERT_PEM ) <EOL> self . assertEqual ( <EOL> p . server_public_cert_pem , self . settings . SERVER_PUBLIC_CERT_PEM ) <EOL> self . assertEqual ( p . server_private_key_pem , '<STR_LIT>' ) <EOL> self . assertEqual ( p . required_issuer , self . settings . REQUIRED_ISSUER ) <EOL> self . assertTrue ( p . ca_id is None ) <EOL> self . mox . VerifyAll ( ) <EOL> def testGetCaParametersWhenCaIdFoo ( self ) : <EOL> """<STR_LIT>""" <EOL> ca_id = '<STR_LIT>' <EOL> self . mox . StubOutWithMock ( util , '<STR_LIT>' ) <EOL> util . GetCaId ( self . settings ) . AndReturn ( ca_id ) <EOL> self . settings . CA_ID = ca_id <EOL> self . settings . FOO_CA_PUBLIC_CERT_PEM = '<STR_LIT>' <EOL> self . settings . FOO_SERVER_PUBLIC_CERT_PEM = '<STR_LIT>' <EOL> self . settings . FOO_SERVER_PRIVATE_KEY_PEM = '<STR_LIT>' <EOL> self . settings . FOO_REQUIRED_ISSUER = '<STR_LIT>' <EOL> self . mox . ReplayAll ( ) <EOL> p = util . GetCaParameters ( self . settings ) <EOL> self . assertEqual ( p . ca_public_cert_pem , '<STR_LIT>' ) <EOL> self . assertEqual ( p . server_public_cert_pem , '<STR_LIT>' ) <EOL> self . assertEqual ( p . server_private_key_pem , '<STR_LIT>' ) <EOL> self . assertEqual ( p . required_issuer , '<STR_LIT>' ) <EOL> self . assertEqual ( p . ca_id , ca_id ) <EOL> self . mox . VerifyAll ( ) <EOL> def testGetCaParametersWhenCaIdFooAndOptionalParam ( self ) : <EOL> """<STR_LIT>""" <EOL> ca_id = '<STR_LIT>' <EOL> self . mox . StubOutWithMock ( util , '<STR_LIT>' ) <EOL> util . GetCaId ( self . settings ) . AndReturn ( ca_id ) <EOL> self . settings . CA_ID = ca_id <EOL> self . settings . FOO_CA_PUBLIC_CERT_PEM = '<STR_LIT>' <EOL> self . settings . FOO_SERVER_PUBLIC_CERT_PEM = '<STR_LIT>' <EOL> self . settings . FOO_REQUIRED_ISSUER = '<STR_LIT>' <EOL> self . mox . ReplayAll ( ) <EOL> p = util . GetCaParameters ( self . settings ) <EOL> self . assertEqual ( p . ca_public_cert_pem , '<STR_LIT>' ) <EOL> self . assertEqual ( p . server_public_cert_pem , '<STR_LIT>' ) <EOL> self . assertEqual ( p . server_private_key_pem , None ) <EOL> self . assertEqual ( p . required_issuer , '<STR_LIT>' ) <EOL> self . assertEqual ( p . ca_id , ca_id ) <EOL> self . mox . VerifyAll ( ) <EOL> def testGetCaParametersWhenCaIdBarAndMissingParam ( self ) : <EOL> """<STR_LIT>""" <EOL> ca_id = '<STR_LIT>' <EOL> self . mox . StubOutWithMock ( util , '<STR_LIT>' ) <EOL> util . GetCaId ( self . settings ) . AndReturn ( ca_id ) <EOL> self . settings . CA_ID = ca_id <EOL> self . settings . BAR_CA_PUBLIC_CERT_PEM = '<STR_LIT>' <EOL> self . settings . BAR_SERVER_PUBLIC_CERT_PEM = '<STR_LIT>' <EOL> self . settings . BAR_SERVER_PRIVATE_KEY_PEM = '<STR_LIT>' <EOL> self . mox . ReplayAll ( ) <EOL> self . assertRaises ( <EOL> util . CaParametersError , util . GetCaParameters , self . settings ) <EOL> self . mox . VerifyAll ( ) <EOL> def testGetCaParametersWhenInvalidCaId ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertRaises ( <EOL> util . CaParametersError , util . GetCaParameters , self . settings , '<STR_LIT>' ) <EOL> def main ( unused_argv ) : <EOL> basetest . main ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> app . run ( ) </s>
