Skip to content

Test and Changelog for 10370 #10379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion FirebaseStorage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# 10.1.0
- [fixed] Fixed an issue where metadata passed to `putFile` was not properly initialized. (#10353)
- [fixed] Fixed a 10.0.0 regression where metadata passed to `putFile` was not properly initialized. (#10353)
- [fixed] Fixed a 10.0.0 regression handling an empty JSON metadata field from the emulator. (#10370)

# 10.0.0
- [changed] FirebaseStorage is now completely implemented in Swift. Swift-specific API improvements
Expand Down
21 changes: 21 additions & 0 deletions FirebaseStorage/Tests/Unit/StorageMetadataTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,27 @@ class StorageMetadataTests: StorageTestHelpers {
XCTAssertEqual(actualURL?.absoluteString, expectedURL)
}

// Regression test for #10370
func testInitializeDownloadURLFromTokenWithEmptyMetadata() {
let metaDict = [
"bucket": "bucket",
"downloadTokens": "12345,ignored",
"name": "path/to/object",
"metadata": {},
] as [String: Any]

let rootReference = rootReference()
let escapedPath = StorageUtils.GCSEscapedString("path/to/object")
let expectedURL =
"https://firebasestorage.googleapis.com:443/v0/b/bucket/o/\(escapedPath)?alt=media&token=12345"
let task = StorageGetDownloadURLTask(reference: rootReference,
fetcherService: GTMSessionFetcherService(),
queue: DispatchQueue.main,
completion: nil)
let actualURL = task.downloadURLFromMetadataDictionary(metaDict)
XCTAssertEqual(actualURL?.absoluteString, expectedURL)
}

func testInitializeMetadataWithFile() {
let metaDict = ["bucket": "bucket", "name": "/path/to/file"]
let metadata = StorageMetadata(dictionary: metaDict)
Expand Down