/** * @covers IcecastAuth\IcecastAuth::execute * @runInSeparateProcess */ public function testExecuteAddAuthlistener() { $_POST = array('action' => 'listener_add', 'server' => 'www.test.fr', 'port' => 8000, 'client' => 397154, 'mount' => '/test.mp3?test=test', 'user' => '', 'pass' => '', 'ip' => '1.1.1.1', 'duration' => 33, 'sent' => 68805); $iceAuth = new IcecastAuth(); $mock = $this->getMock('stdClass', array('testCallback')); $mock->expects($this->any())->method('testCallback1')->with($this->logicalAnd($this->arrayHasKey('test'), $this->arrayHasKey('mountpoint'), $this->arrayHasKey('port')))->will($this->returnValue(true)); $mock->expects($this->any())->method('testCallback2')->with($this->logicalAnd($this->arrayHasKey('test'), $this->arrayHasKey('mountpoint'), $this->arrayHasKey('port')))->will($this->returnValue(true)); $iceAuth->setAuthCallback(array($mock, 'testCallback1')); $iceAuth->setAddListenerCallback(array($mock, 'testCallback2')); $iceAuth->execute(); }
<?php require_once '../vendor/autoload.php'; use IcecastAuth\IcecastAuth; $IceAuth = new IcecastAuth(); // Setup $IceAuth->setAuthCallback('\\authFunc'); // set the callback for authentification // Execute $IceAuth->execute(); // Authetication will work if there is a parameter azerty in the stream url called by user (ex : http://myserver.com/mystream.mp3?azerty=1) function authFunc($parameters) { if (isset($parameters['azerty'])) { return true; } else { return false; } } /* MOUNT CONFIGURATION ON ICECAST SERVER <mount> <mount-name>/mystream.mp3</mount-name> <authentication type="url"> <option name="listener_add" value="[URL OF THIS SCRIPT]"/> <option name="auth_header" value="icecast-auth-user: 1"/> </authentication> </mount> */