FIRStorageTestHelpers.h 3.5 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/FIRApp.h>
  20. #import <FirebaseCore/FIROptions.h>
  21. #import "FIRStorageConstants.h"
  22. #import "FIRStorageConstants_Private.h"
  23. #import "FIRStorageErrors.h"
  24. #import "FIRStorageMetadata.h"
  25. #import "FIRStorageReference.h"
  26. #import "FIRStorageReference_Private.h"
  27. #import "FIRStorageTask.h"
  28. #import "FIRStorageTask_Private.h"
  29. #import "FIRStorageTokenAuthorizer.h"
  30. #import "FIRStorageUtils.h"
  31. #import <GTMSessionFetcher/GTMSessionFetcher.h>
  32. NS_ASSUME_NONNULL_BEGIN
  33. FOUNDATION_EXPORT NSString *const kGoogleHTTPErrorDomain;
  34. FOUNDATION_EXPORT NSString *const kHTTPVersion;
  35. FOUNDATION_EXPORT NSString *const kUnauthenticatedResponseString;
  36. FOUNDATION_EXPORT NSString *const kUnauthorizedResponseString;
  37. FOUNDATION_EXPORT NSString *const kNotFoundResponseString;
  38. FOUNDATION_EXPORT NSString *const kInvalidJSONResponseString;
  39. FOUNDATION_EXPORT NSString *const kFIRStorageValidURL;
  40. FOUNDATION_EXPORT NSString *const kFIRStorageNotFoundURL;
  41. FOUNDATION_EXPORT NSString *const kFIRStorageTestAuthToken;
  42. FOUNDATION_EXPORT NSString *const kFIRStorageAppName;
  43. /**
  44. * Standard timeout for all async tests.
  45. */
  46. static NSTimeInterval kExpectationTimeoutSeconds = 10;
  47. @interface FIRStorageTestHelpers : NSObject
  48. /**
  49. * Returns a mocked FIRApp with an injected container for interop and instance creation. No other
  50. * properties are set.
  51. */
  52. + (FIRApp *)mockedApp;
  53. /**
  54. * Returns a valid URL for an object stored.
  55. */
  56. + (NSURL *)objectURL;
  57. /**
  58. * Returns a valid URL for a bucket.
  59. */
  60. + (NSURL *)bucketURL;
  61. /**
  62. * Returns a valid URL for an object not found in the current storage bucket.
  63. */
  64. + (NSURL *)notFoundURL;
  65. /**
  66. * Returns a valid FIRStoragePath for an object stored.
  67. */
  68. + (FIRStoragePath *)objectPath;
  69. /**
  70. * Returns a valid FIRStoragePath for a bucket (no object).
  71. */
  72. + (FIRStoragePath *)bucketPath;
  73. /**
  74. * Returns a valid FIRStoragePath for an object not found in the current storage bucket.
  75. */
  76. + (FIRStoragePath *)notFoundPath;
  77. /**
  78. * Returns a successful response block.
  79. */
  80. + (GTMSessionFetcherTestBlock)successBlock;
  81. /**
  82. * Returns a successful response block containing object metadata.
  83. * @param metadata Metadata returned in the request.
  84. */
  85. + (GTMSessionFetcherTestBlock)successBlockWithMetadata:(nullable FIRStorageMetadata *)metadata;
  86. /**
  87. * Returns a unsuccessful response block due to improper authentication.
  88. */
  89. + (GTMSessionFetcherTestBlock)unauthenticatedBlock;
  90. /**
  91. * Returns a unsuccessful response block due to improper authorization.
  92. */
  93. + (GTMSessionFetcherTestBlock)unauthorizedBlock;
  94. /**
  95. * Returns a unsuccessful response block due the object not being found.
  96. */
  97. + (GTMSessionFetcherTestBlock)notFoundBlock;
  98. /**
  99. * Returns a unsuccessful response block due invalid JSON returned by the server.
  100. */
  101. + (GTMSessionFetcherTestBlock)invalidJSONBlock;
  102. /**
  103. * Waits for the given test case to time out by wrapping -waitForExpectation.
  104. */
  105. + (void)waitForExpectation:(id)test;
  106. @end
  107. NS_ASSUME_NONNULL_END