Esempio n. 1
0
 /**
  * Returns a Splunk_Context connected to a real Splunk server.
  */
 protected function loginToRealContext()
 {
     global $SplunkTests_connectArguments;
     $context = new Splunk_Context($SplunkTests_connectArguments);
     $context->login();
     return $context;
 }
Esempio n. 2
0
    /**
     * @expectedException           Splunk_HttpException
     * @expectedExceptionMessage    Login failed
     */
    public function testLoginFailDueToBadPassword()
    {
        $http = $this->getMock('Splunk_Http');
        $context = new Splunk_Context(array('http' => $http));
        $httpResponse = (object) array('status' => 401, 'reason' => 'Unauthorized', 'headers' => array(), 'body' => '
<response>
<messages>
<msg type="WARN">Login failed</msg>
</messages>
</response>');
        $http->expects($this->once())->method('post')->will($this->throwException(new Splunk_HttpException($httpResponse)));
        $context->login();
    }