1
0
Fork 0
mirror of https://codeberg.org/demostf/api.git synced 2026-06-03 18:04:08 +02:00

add option to limit uploads to a single key

This commit is contained in:
Robin Appelman 2018-04-24 23:24:47 +02:00
commit 96a9803e30
4 changed files with 68 additions and 12 deletions

View file

@ -81,7 +81,8 @@ class UploadProviderTest extends TestCase {
$this->demoStore,
$this->userProvider,
$this->demoProvider,
$this->demoSaver
$this->demoSaver,
''
);
}
@ -306,4 +307,46 @@ class UploadProviderTest extends TestCase {
$this->assertEquals(0, $demo->getBlueScore());
$this->assertEquals(3, $demo->getRedScore());
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Not an HL2 demo
*/
public function testUploadKey() {
$uploadProvider = new UploadProvider(
$this->getDatabaseConnection(),
'http://example.com',
$this->headerParser,
$this->parser,
$this->demoStore,
$this->userProvider,
$this->demoProvider,
$this->demoSaver,
'foo'
);
$steamId = $this->getSteamId('123', 'a');
$token = $this->userProvider->store($steamId);
$this->assertEquals(
'Invalid key',
$uploadProvider->upload($token, 'RED', 'BLU', 'asdasd', 'asdas')
);
$uploadProvider = new UploadProvider(
$this->getDatabaseConnection(),
'http://example.com',
$this->headerParser,
$this->parser,
$this->demoStore,
$this->userProvider,
$this->demoProvider,
$this->demoSaver,
$token
);
file_put_contents($this->tmpDir . '/foo.dem', 'asd');
$uploadProvider->upload($token, 'RED', 'BLU', 'asdasd', $this->tmpDir . '/foo.dem');
}
}