FIRStorageTestHelpers.h 3.4 KB

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