     waitForExpectations()
   }
 
+  func testUnauthenticatedGetMetadataUnauthorized() {
+    let expectation = self.expectation(description: #function)
+    let ref = storage.reference().child("ios/private/secretfile.txt")
+    ref.getMetadata(completion: { (metadata, error) -> Void in
+      XCTAssertNil(metadata, "Metadata should be nil")
+      XCTAssertNotNil(error, "Error should not be nil")
+      XCTAssertEqual((error! as NSError).code, StorageErrorCode.unauthorized.rawValue)
+      expectation.fulfill()
+    })
+    waitForExpectations()
+  }
+
   func testUnauthenticatedUpdateMetadata() {
     let expectation = self.expectation(description: #function)
 

    let fileURL = tmpDirURL.appendingPathComponent("hello.txt")
    try data.write(to: fileURL, options: .atomicWrite)
    ref.putFile(from: fileURL, metadata: nil, completion: { metadata, error in
      XCTAssertNotNil(metadata, "Metadata should not be nil")
      XCTAssertNil(error, "Error should be nil")
      expectation.fulfill()

    waitForExpectations()
  }

  func testUnauthenticatedDeleteNonExistingFile() {
    let expectation = self.expectation(description: #function)
    let ref = storage.reference(withPath: "ios/public/fileThatDoesNotExist")
    ref.delete { error in
      XCTAssertNotNil(error, "Error should not be nil")
      XCTAssertEqual((error! as NSError).code, StorageErrorCode.objectNotFound.rawValue)
      expectation.fulfill()
    }
    waitForExpectations()
  }

  func testUnauthenticatedDeleteFileUnauthorized() {
    let expectation = self.expectation(description: #function)
    let ref = storage.reference(withPath: "ios/private/secretfile.txt")
    ref.delete { error in
      XCTAssertNotNil(error, "Error should not be nil")
      XCTAssertEqual((error! as NSError).code, StorageErrorCode.unauthorized.rawValue)
      expectation.fulfill()
    }
    waitForExpectations()
  }

  func testDeleteWithNilCompletion() throws {
    let expectation = self.expectation(description: #function)
    let ref = storage.reference(withPath: "ios/public/fileToDelete")
