. * * @link https://www.librenms.org * * @copyright 2019 Tony Murray * @author Tony Murray */ namespace LibreNMS\Tests; use App\Models\ApiToken; use App\Models\Device; use App\Models\User; use Illuminate\Foundation\Testing\DatabaseTransactions; class BasicApiTest extends DBTestCase { use DatabaseTransactions; public function testListDevices() { $user = User::factory()->admin()->create(); $token = ApiToken::generateToken($user); $device = Device::factory()->create(); $this->json('GET', '/api/v0/devices', [], ['X-Auth-Token' => $token->token_hash]) ->assertStatus(200) ->assertJson([ 'status' => 'ok', 'devices' => [$device->toArray()], 'count'=> 1, ]); } }