FIRStorageTestHelpers.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 valid URL for an object stored.
  50. */
  51. + (NSURL *)objectURL;
  52. /**
  53. * Returns a valid URL for a bucket.
  54. */
  55. + (NSURL *)bucketURL;
  56. /**
  57. * Returns a valid URL for an object not found in the current storage bucket.
  58. */
  59. + (NSURL *)notFoundURL;
  60. /**
  61. * Returns a valid FIRStoragePath for an object stored.
  62. */
  63. + (FIRStoragePath *)objectPath;
  64. /**
  65. * Returns a valid FIRStoragePath for a bucket (no object).
  66. */
  67. + (FIRStoragePath *)bucketPath;
  68. /**
  69. * Returns a valid FIRStoragePath for an object not found in the current storage bucket.
  70. */
  71. + (FIRStoragePath *)notFoundPath;
  72. /**
  73. * Returns a successful response block.
  74. */
  75. + (GTMSessionFetcherTestBlock)successBlock;
  76. /**
  77. * Returns a successful response block containing object metadata.
  78. * @param metadata Metadata returned in the request.
  79. */
  80. + (GTMSessionFetcherTestBlock)successBlockWithMetadata:(nullable FIRStorageMetadata *)metadata;
  81. /**
  82. * Returns a unsuccessful response block due to improper authentication.
  83. */
  84. + (GTMSessionFetcherTestBlock)unauthenticatedBlock;
  85. /**
  86. * Returns a unsuccessful response block due to improper authorization.
  87. */
  88. + (GTMSessionFetcherTestBlock)unauthorizedBlock;
  89. /**
  90. * Returns a unsuccessful response block due the object not being found.
  91. */
  92. + (GTMSessionFetcherTestBlock)notFoundBlock;
  93. /**
  94. * Returns a unsuccessful response block due invalid JSON returned by the server.
  95. */
  96. + (GTMSessionFetcherTestBlock)invalidJSONBlock;
  97. /**
  98. * Waits for the given test case to time out by wrapping -waitForExpectation.
  99. */
  100. + (void)waitForExpectation:(id)test;
  101. @end
  102. NS_ASSUME_NONNULL_END