setAuthToken(AuthKeysFixture::ADMIN_API_KEY); $faker = \Faker\Factory::create(); $uuid = $faker->uuid; $this->post( self::ENDPOINT, [ 'uuid' => $uuid, 'name' => 'Brood A', 'url' => $faker->url, 'description' => $faker->text, 'organisation_id' => OrganisationsFixture::ORGANISATION_A_ID, 'trusted' => true, 'pull' => true, 'skip_proxy' => true, 'authkey' => $faker->sha1, ] ); $this->assertResponseOk(); $this->assertResponseContains(sprintf('"uuid": "%s"', $uuid)); $this->assertDbRecordExists('Broods', ['uuid' => $uuid]); //TODO: $this->assertRequestMatchesOpenApiSpec(); $this->assertResponseMatchesOpenApiSpec(self::ENDPOINT, 'post'); } public function testAddBroodNotAllowedAsRegularUser(): void { $this->setAuthToken(AuthKeysFixture::REGULAR_USER_API_KEY); $faker = \Faker\Factory::create(); $uuid = $faker->uuid; $this->post( self::ENDPOINT, [ 'uuid' => $uuid, 'name' => 'Brood A', 'url' => $faker->url, 'description' => $faker->text, 'organisation_id' => OrganisationsFixture::ORGANISATION_A_ID, 'trusted' => true, 'pull' => true, 'skip_proxy' => true, 'authkey' => $faker->sha1, ] ); $this->assertResponseCode(405); $this->assertDbRecordNotExists('Broods', ['uuid' => $uuid]); //TODO: $this->assertRequestMatchesOpenApiSpec(); $this->assertResponseMatchesOpenApiSpec(self::ENDPOINT, 'post'); } }