def testStep1(self):
    """Test Step1 of client auth."""
    cn = '111'
    sn = '555'
    s_b64 = 'signature b64'
    s = 'signature'
    m = '%s %s %s' % (cn, sn, s)
    self.ba._ca_cert = 'ca cert'
    self.ba._cert_str = 'client cert raw string'
    self.ba._session.Set('cn', cn)
    self.ba._server_cert_pem = '---- server pem ----'
    c_b64 = 'client_cert raw string in b64'
    msg = ':'.join((c_b64, cn, sn))
    cn_sn_m = '%s %s' % (cn, sn)

    mock_server_cert = self.mox.CreateMockAnything()

    self.mox.StubOutWithMock(self.ba, '_SplitMessage')
    self.mox.StubOutWithMock(self.ba, '_AssembleMessage')
    self.mox.StubOutWithMock(base.base64, 'urlsafe_b64decode')
    self.mox.StubOutWithMock(base.base64, 'urlsafe_b64encode')
    self.mox.StubOutWithMock(self.ba, 'LoadOtherCert')
    self.mox.StubOutWithMock(self.ba, 'VerifyCertSignedByCA')
    self.mox.StubOutWithMock(self.ba, 'VerifyDataSignedWithCert')
    self.mox.StubOutWithMock(self.ba, 'Sign')
    self.mox.StubOutWithMock(self.ba._session, 'Get')

    self.ba._SplitMessage(m, 3).AndReturn((cn, sn, s_b64))
    base.base64.urlsafe_b64decode(s_b64).AndReturn(s)
    self.ba.LoadOtherCert(self.ba._server_cert_pem).AndReturn(mock_server_cert)
    self.ba.VerifyCertSignedByCA(mock_server_cert).AndReturn(True)
    self.ba._session.Get('cn').AndReturn(cn)
    self.ba._AssembleMessage(cn, sn).AndReturn(cn_sn_m)
    self.ba.VerifyDataSignedWithCert(
        cn_sn_m, s, mock_server_cert).AndReturn(True)

    base.base64.urlsafe_b64encode(self.ba._cert_str).AndReturn(c_b64)
    self.ba._AssembleMessage(c_b64, cn, sn).AndReturn(msg)
    self.ba.Sign(msg).AndReturn(s)
    base.base64.urlsafe_b64encode(s).AndReturn(s_b64)
    expect_output = {'m': msg, 's': s_b64}

    self.mox.ReplayAll()
    self.AssertState(self.ba.DefaultState())
    self.AssertAuthState(base.AuthState.UNKNOWN)
    self.ba.Input(m=m)
    self.AssertState(base.State.OUTPUT)
    self.assertEqual(expect_output, self.ba.Output())
    self.AssertState(self.ba.DefaultState())
    self.mox.VerifyAll()
dataset/ETHPy150Open google/simian/src/tests/simian/auth/base_medium_test.py/Auth1ClientTest.testStep1/original