FIRStorageTestHelpers.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #import <OCMock/OCMock.h>
  18. #import <XCTest/XCTest.h>
  19. #import "FirebaseCore/Sources/Private/FirebaseCoreInternal.h"
  20. #import "FirebaseStorage/Sources/Public/FIRStorageConstants.h"
  21. #import "FirebaseStorage/Sources/Public/FIRStorageMetadata.h"
  22. #import "FirebaseStorage/Sources/Public/FIRStorageReference.h"
  23. #import "FirebaseStorage/Sources/Public/FIRStorageTask.h"
  24. #import "FirebaseStorage/Sources/FIRStorageConstants_Private.h"
  25. #import "FirebaseStorage/Sources/FIRStorageErrors.h"
  26. #import "FirebaseStorage/Sources/FIRStorageReference_Private.h"
  27. #import "FirebaseStorage/Sources/FIRStorageTask_Private.h"
  28. #import "FirebaseStorage/Sources/FIRStorageTokenAuthorizer.h"
  29. #import "FirebaseStorage/Sources/FIRStorageUtils.h"
  30. #import <GTMSessionFetcher/GTMSessionFetcher.h>
  31. NS_ASSUME_NONNULL_BEGIN
  32. FOUNDATION_EXPORT NSString *const kGoogleHTTPErrorDomain;
  33. FOUNDATION_EXPORT NSString *const kHTTPVersion;
  34. FOUNDATION_EXPORT NSString *const kUnauthenticatedResponseString;
  35. FOUNDATION_EXPORT NSString *const kUnauthorizedResponseString;
  36. FOUNDATION_EXPORT NSString *const kNotFoundResponseString;
  37. FOUNDATION_EXPORT NSString *const kInvalidJSONResponseString;
  38. FOUNDATION_EXPORT NSString *const kFIRStorageValidURL;
  39. FOUNDATION_EXPORT NSString *const kFIRStorageNotFoundURL;
  40. FOUNDATION_EXPORT NSString *const kFIRStorageTestAuthToken;
  41. FOUNDATION_EXPORT NSString *const kFIRStorageAppName;
  42. /**
  43. * Standard timeout for all async tests.
  44. */
  45. static NSTimeInterval kExpectationTimeoutSeconds = 10;
  46. @interface FIRStorageTestHelpers : NSObject
  47. /**
  48. * Returns a mocked FIRApp with an injected container for interop and instance creation. No other
  49. * properties are set.
  50. */
  51. + (FIRApp *)mockedApp;
  52. /**
  53. * Returns a valid URL for an object stored.
  54. */
  55. + (NSURL *)objectURL;
  56. /**
  57. * Returns a valid URL for a bucket.
  58. */
  59. + (NSURL *)bucketURL;
  60. /**
  61. * Returns a valid URL for an object not found in the current storage bucket.
  62. */
  63. + (NSURL *)notFoundURL;
  64. /**
  65. * Returns a valid FIRStoragePath for an object stored.
  66. */
  67. + (FIRStoragePath *)objectPath;
  68. /**
  69. * Returns a valid FIRStoragePath for a bucket (no object).
  70. */
  71. + (FIRStoragePath *)bucketPath;
  72. /**
  73. * Returns a valid FIRStoragePath for an object not found in the current storage bucket.
  74. */
  75. + (FIRStoragePath *)notFoundPath;
  76. /**
  77. * Returns a successful response block.
  78. */
  79. + (GTMSessionFetcherTestBlock)successBlock;
  80. /**
  81. * Returns a successful response block containing object metadata.
  82. * @param metadata Metadata returned in the request.
  83. */
  84. + (GTMSessionFetcherTestBlock)successBlockWithMetadata:(nullable FIRStorageMetadata *)metadata;
  85. /**
  86. * Returns a unsuccessful response block due to improper authentication.
  87. */
  88. + (GTMSessionFetcherTestBlock)unauthenticatedBlock;
  89. /**
  90. * Returns a unsuccessful response block due to improper authorization.
  91. */
  92. + (GTMSessionFetcherTestBlock)unauthorizedBlock;
  93. /**
  94. * Returns a unsuccessful response block due the object not being found.
  95. */
  96. + (GTMSessionFetcherTestBlock)notFoundBlock;
  97. /**
  98. * Returns a unsuccessful response block due invalid JSON returned by the server.
  99. */
  100. + (GTMSessionFetcherTestBlock)invalidJSONBlock;
  101. /**
  102. * Waits for the given test case to time out by wrapping -waitForExpectation.
  103. */
  104. + (void)waitForExpectation:(id)test;
  105. @end
  106. NS_ASSUME_NONNULL_END