 .../EntityResource/Media/MediaHalJsonAnonTest.php  | 176 ++++++++++++++
 .../Media/MediaHalJsonBasicAuthTest.php            |  24 ++
 .../Media/MediaHalJsonCookieTest.php               |  19 ++
 .../MediaType/MediaTypeHalJsonAnonTest.php         |  30 +++
 .../MediaType/MediaTypeHalJsonBasicAuthTest.php    |  35 +++
 .../MediaType/MediaTypeHalJsonCookieTest.php       |  35 +++
 .../EntityResource/Media/MediaJsonAnonTest.php     |  24 ++
 .../Media/MediaJsonBasicAuthTest.php               |  34 +++
 .../EntityResource/Media/MediaJsonCookieTest.php   |  29 +++
 .../EntityResource/Media/MediaResourceTestBase.php | 264 +++++++++++++++++++++
 .../MediaType/MediaTypeJsonAnonTest.php            |  24 ++
 .../MediaType/MediaTypeJsonBasicAuthTest.php       |  34 +++
 .../MediaType/MediaTypeJsonCookieTest.php          |  29 +++
 .../MediaType/MediaTypeResourceTestBase.php        |  78 ++++++
 14 files changed, 835 insertions(+)

diff --git a/core/modules/hal/tests/src/Functional/EntityResource/Media/MediaHalJsonAnonTest.php b/core/modules/hal/tests/src/Functional/EntityResource/Media/MediaHalJsonAnonTest.php
new file mode 100644
index 0000000..afa9465
--- /dev/null
+++ b/core/modules/hal/tests/src/Functional/EntityResource/Media/MediaHalJsonAnonTest.php
@@ -0,0 +1,176 @@
+<?php
+
+namespace Drupal\Tests\hal\Functional\EntityResource\Media;
+
+use Drupal\file\Entity\File;
+use Drupal\Tests\hal\Functional\EntityResource\HalEntityNormalizationTrait;
+use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
+use Drupal\Tests\rest\Functional\EntityResource\Media\MediaResourceTestBase;
+use Drupal\user\Entity\User;
+
+/**
+ * @group hal
+ */
+class MediaHalJsonAnonTest extends MediaResourceTestBase {
+
+  use HalEntityNormalizationTrait;
+  use AnonResourceTestTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['hal'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $format = 'hal_json';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $mimeType = 'application/hal+json';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getExpectedNormalizedEntity() {
+    $default_normalization = parent::getExpectedNormalizedEntity();
+
+    $normalization = $this->applyHalFieldNormalization($default_normalization);
+
+    $file = File::load(1);
+    $thumbnail = File::load(2);
+    $author = User::load($this->entity->getOwnerId());
+    return $normalization + [
+      '_links' => [
+        'self' => [
+          'href' => $this->baseUrl . '/media/1?_format=hal_json',
+        ],
+        'type' => [
+          'href' => $this->baseUrl . '/rest/type/media/camelids',
+        ],
+        $this->baseUrl . '/rest/relation/media/camelids/field_media_file_1' => [
+          [
+            'href' => $file->url(),
+            'lang' => 'en',
+          ],
+        ],
+        $this->baseUrl . '/rest/relation/media/camelids/revision_user' => [
+          [
+            'href' => $this->baseUrl . '/user/' . $author->id() . '?_format=hal_json',
+          ],
+        ],
+        $this->baseUrl . '/rest/relation/media/camelids/thumbnail' => [
+          [
+            'href' => $thumbnail->url(),
+            'lang' => 'en',
+          ],
+        ],
+        $this->baseUrl . '/rest/relation/media/camelids/uid' => [
+          [
+            'href' => $this->baseUrl . '/user/' . $author->id() . '?_format=hal_json',
+            'lang' => 'en',
+          ],
+        ],
+      ],
+      '_embedded' => [
+        $this->baseUrl . '/rest/relation/media/camelids/field_media_file_1' => [
+          [
+            '_links' => [
+              'self' => [
+                'href' => $file->url(),
+              ],
+              'type' => [
+                'href' => $this->baseUrl . '/rest/type/file/file',
+              ],
+            ],
+            'lang' => 'en',
+            'uri' => [
+              [
+                'value' => $file->url(),
+              ],
+            ],
+            'uuid' => [
+              [
+                'value' => $file->uuid(),
+              ],
+            ],
+          ],
+        ],
+        $this->baseUrl . '/rest/relation/media/camelids/revision_user' => [
+          [
+            '_links' => [
+              'self' => [
+                'href' => $this->baseUrl . '/user/' . $author->id() . '?_format=hal_json',
+              ],
+              'type' => [
+                'href' => $this->baseUrl . '/rest/type/user/user',
+              ],
+            ],
+            'uuid' => [
+              [
+                'value' => $author->uuid(),
+              ],
+            ],
+          ],
+        ],
+        $this->baseUrl . '/rest/relation/media/camelids/thumbnail' => [
+          [
+            '_links' => [
+              'self' => [
+                'href' => $thumbnail->url(),
+              ],
+              'type' => [
+                'href' => $this->baseUrl . '/rest/type/file/file',
+              ],
+            ],
+            'lang' => 'en',
+            'uri' => [
+              [
+                'value' => $thumbnail->url(),
+              ],
+            ],
+            'uuid' => [
+              [
+                'value' => $thumbnail->uuid(),
+              ],
+            ],
+          ],
+        ],
+        $this->baseUrl . '/rest/relation/media/camelids/uid' => [
+          [
+            '_links' => [
+              'self' => [
+                'href' => $this->baseUrl . '/user/' . $author->id() . '?_format=hal_json',
+              ],
+              'type' => [
+                'href' => $this->baseUrl . '/rest/type/user/user',
+              ],
+            ],
+            'uuid' => [
+              [
+                'value' => $author->uuid(),
+              ],
+            ],
+            'lang' => 'en',
+          ],
+        ],
+      ],
+    ];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getNormalizedPostEntity() {
+    return parent::getNormalizedPostEntity() + [
+      '_links' => [
+        'type' => [
+          'href' => $this->baseUrl . '/rest/type/media/camelids',
+        ],
+      ],
+    ];
+  }
+
+}
diff --git a/core/modules/hal/tests/src/Functional/EntityResource/Media/MediaHalJsonBasicAuthTest.php b/core/modules/hal/tests/src/Functional/EntityResource/Media/MediaHalJsonBasicAuthTest.php
new file mode 100644
index 0000000..a645cbf
--- /dev/null
+++ b/core/modules/hal/tests/src/Functional/EntityResource/Media/MediaHalJsonBasicAuthTest.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace Drupal\Tests\hal\Functional\EntityResource\Media;
+
+use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
+
+/**
+ * @group hal
+ */
+class MediaHalJsonBasicAuthTest extends MediaHalJsonAnonTest {
+
+  use BasicAuthResourceTestTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['basic_auth'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $auth = 'basic_auth';
+
+}
diff --git a/core/modules/hal/tests/src/Functional/EntityResource/Media/MediaHalJsonCookieTest.php b/core/modules/hal/tests/src/Functional/EntityResource/Media/MediaHalJsonCookieTest.php
new file mode 100644
index 0000000..a197eab
--- /dev/null
+++ b/core/modules/hal/tests/src/Functional/EntityResource/Media/MediaHalJsonCookieTest.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace Drupal\Tests\hal\Functional\EntityResource\Media;
+
+use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
+
+/**
+ * @group hal
+ */
+class MediaHalJsonCookieTest extends MediaHalJsonAnonTest {
+
+  use CookieResourceTestTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $auth = 'cookie';
+
+}
diff --git a/core/modules/hal/tests/src/Functional/EntityResource/MediaType/MediaTypeHalJsonAnonTest.php b/core/modules/hal/tests/src/Functional/EntityResource/MediaType/MediaTypeHalJsonAnonTest.php
new file mode 100644
index 0000000..1b83df1
--- /dev/null
+++ b/core/modules/hal/tests/src/Functional/EntityResource/MediaType/MediaTypeHalJsonAnonTest.php
@@ -0,0 +1,30 @@
+<?php
+
+namespace Drupal\Tests\hal\Functional\EntityResource\MediaType;
+
+use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
+use Drupal\Tests\rest\Functional\EntityResource\MediaType\MediaTypeResourceTestBase;
+
+/**
+ * @group hal
+ */
+class MediaTypeHalJsonAnonTest extends MediaTypeResourceTestBase {
+
+  use AnonResourceTestTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['hal'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $format = 'hal_json';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $mimeType = 'application/hal+json';
+
+}
diff --git a/core/modules/hal/tests/src/Functional/EntityResource/MediaType/MediaTypeHalJsonBasicAuthTest.php b/core/modules/hal/tests/src/Functional/EntityResource/MediaType/MediaTypeHalJsonBasicAuthTest.php
new file mode 100644
index 0000000..20c29f2
--- /dev/null
+++ b/core/modules/hal/tests/src/Functional/EntityResource/MediaType/MediaTypeHalJsonBasicAuthTest.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Drupal\Tests\hal\Functional\EntityResource\MediaType;
+
+use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
+use Drupal\Tests\rest\Functional\EntityResource\MediaType\MediaTypeResourceTestBase;
+
+/**
+ * @group hal
+ */
+class MediaTypeHalJsonBasicAuthTest extends MediaTypeResourceTestBase {
+
+  use BasicAuthResourceTestTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['hal', 'basic_auth'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $format = 'hal_json';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $mimeType = 'application/hal+json';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $auth = 'basic_auth';
+
+}
diff --git a/core/modules/hal/tests/src/Functional/EntityResource/MediaType/MediaTypeHalJsonCookieTest.php b/core/modules/hal/tests/src/Functional/EntityResource/MediaType/MediaTypeHalJsonCookieTest.php
new file mode 100644
index 0000000..8c60485
--- /dev/null
+++ b/core/modules/hal/tests/src/Functional/EntityResource/MediaType/MediaTypeHalJsonCookieTest.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Drupal\Tests\hal\Functional\EntityResource\MediaType;
+
+use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
+use Drupal\Tests\rest\Functional\EntityResource\MediaType\MediaTypeResourceTestBase;
+
+/**
+ * @group hal
+ */
+class MediaTypeHalJsonCookieTest extends MediaTypeResourceTestBase {
+
+  use CookieResourceTestTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['hal'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $format = 'hal_json';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $mimeType = 'application/hal+json';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $auth = 'cookie';
+
+}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Media/MediaJsonAnonTest.php b/core/modules/rest/tests/src/Functional/EntityResource/Media/MediaJsonAnonTest.php
new file mode 100644
index 0000000..d9a3550
--- /dev/null
+++ b/core/modules/rest/tests/src/Functional/EntityResource/Media/MediaJsonAnonTest.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace Drupal\Tests\rest\Functional\EntityResource\Media;
+
+use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
+
+/**
+ * @group rest
+ */
+class MediaJsonAnonTest extends MediaResourceTestBase {
+
+  use AnonResourceTestTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $format = 'json';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $mimeType = 'application/json';
+
+}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Media/MediaJsonBasicAuthTest.php b/core/modules/rest/tests/src/Functional/EntityResource/Media/MediaJsonBasicAuthTest.php
new file mode 100644
index 0000000..f499b79
--- /dev/null
+++ b/core/modules/rest/tests/src/Functional/EntityResource/Media/MediaJsonBasicAuthTest.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace Drupal\Tests\rest\Functional\EntityResource\Media;
+
+use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
+
+/**
+ * @group rest
+ */
+class MediaJsonBasicAuthTest extends MediaResourceTestBase {
+
+  use BasicAuthResourceTestTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['basic_auth'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $format = 'json';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $mimeType = 'application/json';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $auth = 'basic_auth';
+
+}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Media/MediaJsonCookieTest.php b/core/modules/rest/tests/src/Functional/EntityResource/Media/MediaJsonCookieTest.php
new file mode 100644
index 0000000..0cb8626
--- /dev/null
+++ b/core/modules/rest/tests/src/Functional/EntityResource/Media/MediaJsonCookieTest.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Drupal\Tests\rest\Functional\EntityResource\Media;
+
+use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
+
+/**
+ * @group rest
+ */
+class MediaJsonCookieTest extends MediaResourceTestBase {
+
+  use CookieResourceTestTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $format = 'json';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $mimeType = 'application/json';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $auth = 'cookie';
+
+}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Media/MediaResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/Media/MediaResourceTestBase.php
new file mode 100644
index 0000000..41476c4
--- /dev/null
+++ b/core/modules/rest/tests/src/Functional/EntityResource/Media/MediaResourceTestBase.php
@@ -0,0 +1,264 @@
+<?php
+
+namespace Drupal\Tests\rest\Functional\EntityResource\Media;
+
+use Drupal\file\Entity\File;
+use Drupal\media\Entity\Media;
+use Drupal\media\Entity\MediaType;
+use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
+use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
+use Drupal\user\Entity\User;
+
+abstract class MediaResourceTestBase extends EntityResourceTestBase {
+
+  use BcTimestampNormalizerUnixTestTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['media'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $entityTypeId = 'media';
+
+  /**
+   * @var \Drupal\media\MediaInterface
+   */
+  protected $entity;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $patchProtectedFieldNames = [
+    'changed',
+  ];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUpAuthorization($method) {
+    switch ($method) {
+      case 'GET':
+        $this->grantPermissionsToTestedRole(['view media']);
+        break;
+
+      case 'POST':
+        $this->grantPermissionsToTestedRole(['create media']);
+        break;
+
+      case 'PATCH':
+        $this->grantPermissionsToTestedRole(['update any media']);
+        break;
+
+      case 'DELETE':
+        $this->grantPermissionsToTestedRole(['delete any media']);
+        break;
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function createEntity() {
+    if (!MediaType::load('camelids')) {
+      // Create a "Camelids" media type.
+      $media_type = MediaType::create([
+        'name' => 'Camelids',
+        'id' => 'camelids',
+        'description' => 'Camelids are large, strictly herbivorous animals with slender necks and long legs.',
+        'source' => 'file',
+      ]);
+      $media_type->save();
+      // Create the source field.
+      $source_field = $media_type->getSource()->createSourceField($media_type);
+      $source_field->getFieldStorageDefinition()->save();
+      $source_field->save();
+      $media_type
+        ->set('source_configuration', [
+          'source_field' => $source_field->getName(),
+        ])
+        ->save();
+    }
+
+    // Create a file to upload.
+    $file = File::create([
+      'uri' => 'public://llama.txt',
+    ]);
+    $file->setPermanent();
+    $file->save();
+
+    // Create a "Llama" media item.
+    $media = Media::create([
+      'bundle' => 'camelids',
+      'field_media_file_1' => [
+        'target_id' => $file->id(),
+      ],
+    ]);
+    $media
+      ->setName('Llama')
+      ->setPublished(TRUE)
+      ->setCreatedTime(123456789)
+      ->setOwnerId(static::$auth ? $this->account->id() : 0)
+      ->setRevisionUserId(static::$auth ? $this->account->id() : 0)
+      ->save();
+
+    return $media;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getExpectedNormalizedEntity() {
+    $file = File::load(1);
+    $thumbnail = File::load(2);
+    $author = User::load($this->entity->getOwnerId());
+    return [
+      'mid' => [
+        [
+          'value' => 1,
+        ],
+      ],
+      'uuid' => [
+        [
+          'value' => $this->entity->uuid(),
+        ],
+      ],
+      'vid' => [
+        [
+          'value' => 1,
+        ],
+      ],
+      'langcode' => [
+        [
+          'value' => 'en',
+        ],
+      ],
+      'bundle' => [
+        [
+          'target_id' => 'camelids',
+          'target_type' => 'media_type',
+          'target_uuid' => MediaType::load('camelids')->uuid(),
+        ],
+      ],
+      'name' => [
+        [
+          'value' => 'Llama',
+        ],
+      ],
+      'field_media_file_1' => [
+        [
+          'description' => NULL,
+          'display' => NULL,
+          'target_id' => (int) $file->id(),
+          'target_type' => 'file',
+          'target_uuid' => $file->uuid(),
+          'url' => $file->url(),
+        ],
+      ],
+      'thumbnail' => [
+        [
+          'alt' => 'Thumbnail',
+          'width' => 180,
+          'height' => 180,
+          'target_id' => (int) $thumbnail->id(),
+          'target_type' => 'file',
+          'target_uuid' => $thumbnail->uuid(),
+          'title' => 'Llama',
+          'url' => $thumbnail->url(),
+        ],
+      ],
+      'status' => [
+        [
+          'value' => TRUE,
+        ],
+      ],
+      'created' => [
+        $this->formatExpectedTimestampItemValues(123456789),
+      ],
+      'changed' => [
+        $this->formatExpectedTimestampItemValues($this->entity->getChangedTime()),
+      ],
+      'revision_created' => [
+        $this->formatExpectedTimestampItemValues((int) $this->entity->getRevisionCreationTime()),
+      ],
+      'default_langcode' => [
+        [
+          'value' => TRUE,
+        ],
+      ],
+      'uid' => [
+        [
+          'target_id' => (int) $author->id(),
+          'target_type' => 'user',
+          'target_uuid' => $author->uuid(),
+          'url' => base_path() . 'user/' . $author->id(),
+        ],
+      ],
+      'revision_user' => [
+        [
+          'target_id' => (int) $author->id(),
+          'target_type' => 'user',
+          'target_uuid' => $author->uuid(),
+          'url' => base_path() . 'user/' . $author->id(),
+        ],
+      ],
+      'revision_log_message' => [],
+      'revision_translation_affected' => [
+        [
+          'value' => true,
+        ],
+      ],
+    ];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getNormalizedPostEntity() {
+    return [
+      'bundle' => [
+        [
+          'target_id' => 'camelids',
+        ],
+      ],
+      'name' => [
+        [
+          'value' => 'Dramallama',
+        ],
+      ],
+    ];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getExpectedUnauthorizedAccessMessage($method) {
+    if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
+      return parent::getExpectedUnauthorizedAccessMessage($method);
+    }
+
+    switch ($method) {
+      case 'GET';
+        return "The 'view media' permission is required and the media item must be published.";
+
+      case 'PATCH':
+        return 'You are not authorized to update this media entity of bundle camelids.';
+
+      case 'DELETE':
+        return 'You are not authorized to delete this media entity of bundle camelids.';
+
+      default:
+        return parent::getExpectedUnauthorizedAccessMessage($method);
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function testPost() {
+    $this->markTestSkipped('POSTing File Media items is not supported until https://www.drupal.org/node/1927648 is solved.');
+  }
+
+}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/MediaType/MediaTypeJsonAnonTest.php b/core/modules/rest/tests/src/Functional/EntityResource/MediaType/MediaTypeJsonAnonTest.php
new file mode 100644
index 0000000..2e4b630
--- /dev/null
+++ b/core/modules/rest/tests/src/Functional/EntityResource/MediaType/MediaTypeJsonAnonTest.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace Drupal\Tests\rest\Functional\EntityResource\MediaType;
+
+use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
+
+/**
+ * @group rest
+ */
+class MediaTypeJsonAnonTest extends MediaTypeResourceTestBase {
+
+  use AnonResourceTestTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $format = 'json';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $mimeType = 'application/json';
+
+}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/MediaType/MediaTypeJsonBasicAuthTest.php b/core/modules/rest/tests/src/Functional/EntityResource/MediaType/MediaTypeJsonBasicAuthTest.php
new file mode 100644
index 0000000..052b19d
--- /dev/null
+++ b/core/modules/rest/tests/src/Functional/EntityResource/MediaType/MediaTypeJsonBasicAuthTest.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace Drupal\Tests\rest\Functional\EntityResource\MediaType;
+
+use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
+
+/**
+ * @group rest
+ */
+class MediaTypeJsonBasicAuthTest extends MediaTypeResourceTestBase {
+
+  use BasicAuthResourceTestTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['basic_auth'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $format = 'json';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $mimeType = 'application/json';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $auth = 'basic_auth';
+
+}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/MediaType/MediaTypeJsonCookieTest.php b/core/modules/rest/tests/src/Functional/EntityResource/MediaType/MediaTypeJsonCookieTest.php
new file mode 100644
index 0000000..b956c98
--- /dev/null
+++ b/core/modules/rest/tests/src/Functional/EntityResource/MediaType/MediaTypeJsonCookieTest.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Drupal\Tests\rest\Functional\EntityResource\MediaType;
+
+use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
+
+/**
+ * @group rest
+ */
+class MediaTypeJsonCookieTest extends MediaTypeResourceTestBase {
+
+  use CookieResourceTestTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $format = 'json';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $mimeType = 'application/json';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $auth = 'cookie';
+
+}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/MediaType/MediaTypeResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/MediaType/MediaTypeResourceTestBase.php
new file mode 100644
index 0000000..ac72737
--- /dev/null
+++ b/core/modules/rest/tests/src/Functional/EntityResource/MediaType/MediaTypeResourceTestBase.php
@@ -0,0 +1,78 @@
+<?php
+
+namespace Drupal\Tests\rest\Functional\EntityResource\MediaType;
+
+use Drupal\media\Entity\MediaType;
+use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
+
+abstract class MediaTypeResourceTestBase extends EntityResourceTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['media'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $entityTypeId = 'media_type';
+
+  /**
+   * @var \Drupal\media\MediaTypeInterface
+   */
+  protected $entity;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUpAuthorization($method) {
+    $this->grantPermissionsToTestedRole(['administer media types']);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function createEntity() {
+    // Create a "Camelids" media type.
+    $camelids = MediaType::create([
+      'name' => 'Camelids',
+      'id' => 'camelids',
+      'description' => 'Camelids are large, strictly herbivorous animals with slender necks and long legs.',
+      'source' => 'file',
+    ]);
+
+    $camelids->save();
+
+    return $camelids;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getExpectedNormalizedEntity() {
+    return [
+      'dependencies' => [],
+      'description' => 'Camelids are large, strictly herbivorous animals with slender necks and long legs.',
+      'field_map' => [],
+      'id' => 'camelids',
+      'label' => NULL,
+      'langcode' => 'en',
+      'new_revision' => FALSE,
+      'queue_thumbnail_downloads' => FALSE,
+      'source' => 'file',
+      'source_configuration' => [
+        'source_field' => '',
+      ],
+      'status' => TRUE,
+      'uuid' => $this->entity->uuid(),
+    ];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getNormalizedPostEntity() {
+    // @todo Update in https://www.drupal.org/node/2300677.
+  }
+
+}
