Skip to content

Commit

Permalink
Merge pull request #235 from wordpress-mobile/release/1.8.10
Browse files Browse the repository at this point in the history
Merge Release/1.8.10 into master
  • Loading branch information
pinarol authored Dec 16, 2019
2 parents 3a60d1c + bbf4c2a commit 7c2c126
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 14 deletions.
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ workflows:
jobs:
- ios/test:
name: Test
xcode-version: "10.2.0"
xcode-version: "11.2.1"
workspace: WordPressShared.xcworkspace
scheme: WordPressShared
device: iPhone XS
ios-version: "12.2"
device: iPhone 11
ios-version: "13.2.2"
bundle-install: true
pod-install: true
- ios/validate-podspec:
name: Validate Podspec
xcode-version: "10.2.0"
xcode-version: "11.2.1"
podspec-path: WordPressShared.podspec
bundle-install: true
- ios/publish-podspec:
name: Publish to Trunk
xcode-version: "10.2.0"
xcode-version: "11.2.1"
podspec-path: WordPressShared.podspec
bundle-install: true
post-to-slack: true
Expand Down
3 changes: 1 addition & 2 deletions WordPressShared.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "WordPressShared"
s.version = "1.8.9"
s.version = "1.8.10"
s.summary = "Shared components used in building the WordPress iOS apps and other library components."

s.description = <<-DESC
Expand All @@ -27,4 +27,3 @@ Pod::Spec.new do |s|
s.dependency 'CocoaLumberjack', '~> 3.4'
s.dependency 'FormatterKit/TimeIntervalFormatter', '1.8.2'
end

8 changes: 8 additions & 0 deletions WordPressShared.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
B5A7881F202B3A92007874FB /* WPTextFieldTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = B5A7881B202B3A92007874FB /* WPTextFieldTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; };
B5A78820202B3A92007874FB /* WPTextFieldTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B5A7881C202B3A92007874FB /* WPTextFieldTableViewCell.m */; };
B5A78821202B3A92007874FB /* WPTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = B5A7881D202B3A92007874FB /* WPTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; };
E157E126239527700051AE41 /* Secret.swift in Sources */ = {isa = PBXBuildFile; fileRef = E157E125239527700051AE41 /* Secret.swift */; };
E157E128239527AD0051AE41 /* SecretTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E157E127239527AD0051AE41 /* SecretTests.swift */; };
E18EABEA1F0E2C6800BFCB0B /* TestAnalyticsTracker.m in Sources */ = {isa = PBXBuildFile; fileRef = E18EABE81F0E2C6800BFCB0B /* TestAnalyticsTracker.m */; };
E18EABEB1F0E2C6800BFCB0B /* WPAnalyticsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E18EABE91F0E2C6800BFCB0B /* WPAnalyticsTests.m */; };
E1A444281F063CAB00F6AA8A /* WPAnalytics.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A444261F063CAB00F6AA8A /* WPAnalytics.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -191,6 +193,8 @@
B5A78823202B3B3C007874FB /* WordPressUIKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = WordPressUIKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
BAD47F9FCABF8C12D6352A20 /* Pods-WordPressSharedTests.release-internal.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressSharedTests.release-internal.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressSharedTests/Pods-WordPressSharedTests.release-internal.xcconfig"; sourceTree = "<group>"; };
D62D565031D4683172615BAC /* Pods-WordPressSharedTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressSharedTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressSharedTests/Pods-WordPressSharedTests.release.xcconfig"; sourceTree = "<group>"; };
E157E125239527700051AE41 /* Secret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Secret.swift; sourceTree = "<group>"; };
E157E127239527AD0051AE41 /* SecretTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecretTests.swift; sourceTree = "<group>"; };
E18EABE71F0E2C6800BFCB0B /* TestAnalyticsTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestAnalyticsTracker.h; sourceTree = "<group>"; };
E18EABE81F0E2C6800BFCB0B /* TestAnalyticsTracker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestAnalyticsTracker.m; sourceTree = "<group>"; };
E18EABE91F0E2C6800BFCB0B /* WPAnalyticsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WPAnalyticsTests.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -299,6 +303,7 @@
7430C9D01F19302D0051B8E6 /* PhotonImageURLHelper.h */,
7430C9D11F19302D0051B8E6 /* PhotonImageURLHelper.m */,
7430C9DA1F1933F40051B8E6 /* RichContentFormatter.swift */,
E157E125239527700051AE41 /* Secret.swift */,
7414BD541F13CBE0005759F8 /* String+Helpers.swift */,
F19847DB226F92420004A8BC /* String+URLValidation.swift */,
7414BD5F1F13D084005759F8 /* UIDevice+Helpers.h */,
Expand Down Expand Up @@ -347,6 +352,7 @@
93A73ABE1EE9DDB000C0F2F9 /* WPMapFilterReduceTest.m */,
8270708F1ECA4E1C00155CBF /* WordPressSharedTests-Bridging-Header.h */,
F19847DD226F92EA0004A8BC /* StringURLValidationTests.swift */,
E157E127239527AD0051AE41 /* SecretTests.swift */,
);
name = Tests;
sourceTree = "<group>";
Expand Down Expand Up @@ -653,6 +659,7 @@
buildActionMask = 2147483647;
files = (
E1A444291F063CAB00F6AA8A /* WPAnalytics.m in Sources */,
E157E126239527700051AE41 /* Secret.swift in Sources */,
827070101ECA43AA00155CBF /* WPImageSource.m in Sources */,
93C674F51EE83D4B00BFAF05 /* Languages.swift in Sources */,
B5A787E6202B2BD3007874FB /* WPDeviceIdentification.m in Sources */,
Expand Down Expand Up @@ -704,6 +711,7 @@
B5393FDD206D6169007BF9D4 /* EmailTypoCheckerTests.swift in Sources */,
F1134A292270C19200B8F75F /* DebouncerTests.swift in Sources */,
7430C9D51F1930460051B8E6 /* PhotonImageURLHelperTest.m in Sources */,
E157E128239527AD0051AE41 /* SecretTests.swift in Sources */,
740B23CF1F17F28E00067A2A /* DisplayableImageHelperTest.m in Sources */,
E18EABEB1F0E2C6800BFCB0B /* WPAnalyticsTests.m in Sources */,
7430C9DD1F1934190051B8E6 /* RichContentFormatterTests.swift in Sources */,
Expand Down
16 changes: 15 additions & 1 deletion WordPressShared/Core/Analytics/WPAnalytics.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ typedef NS_ENUM(NSUInteger, WPAnalyticsStat) {
WPAnalyticsStatEditorAddedPhotoViaGiphy,
WPAnalyticsStatEditorAddedPhotoViaOtherApps,
WPAnalyticsStatEditorAddedPhotoViaStockPhotos,
WPAnalyticsStatEditorAddedPhotoViaMediaEditor,
WPAnalyticsStatEditorAddedVideoViaOtherApps,
WPAnalyticsStatEditorAztecBetaLink,
WPAnalyticsStatEditorAztecPromoLink,
Expand Down Expand Up @@ -198,6 +199,8 @@ typedef NS_ENUM(NSUInteger, WPAnalyticsStat) {
WPAnalyticsStatLoginSocialErrorUnknownUser,
WPAnalyticsStatLogout,
WPAnalyticsStatLowMemoryWarning,
WPAnalyticsStatMediaEditorShown,
WPAnalyticsStatMediaEditorUsed,
WPAnalyticsStatMediaLibraryDeletedItems,
WPAnalyticsStatMediaLibraryEditedItemMetadata,
WPAnalyticsStatMediaLibraryPreviewedItem,
Expand Down Expand Up @@ -559,7 +562,18 @@ typedef NS_ENUM(NSUInteger, WPAnalyticsStat) {
WPAnalyticsStatTwoFactorSentSMS,
WPAnalyticsStatShareExtensionError,
WPAnalyticsStatSearchAdsAttribution,
WPAnalyticsStatMaxValue
WPAnalyticsStatMaxValue,
/// Logged when there are orphaned entities (e.g. has NULL blog values).
///
/// These are invalid rows in the database and will cause a crash in Core Data during saving.
///
/// Event Properties:
///
/// - entity_name: String. The Core Data entity name.
/// - deleted_count: Int. The number of deleted entities.
///
/// This event is not logged when there are no entities to delete.
WPAnalyticsStatDebugDeletedOrphanedEntities
};

extern NSString *const WPAnalyticsStatEditorPublishedPostPropertyCategory;
Expand Down
6 changes: 4 additions & 2 deletions WordPressShared/Core/Logging/WPSharedLogging.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
int WPSharedGetLoggingLevel(void);
void WPSharedSetLoggingLevel(int level);
@import CocoaLumberjack;

DDLogLevel WPSharedGetLoggingLevel(void);
void WPSharedSetLoggingLevel(DDLogLevel level);
4 changes: 2 additions & 2 deletions WordPressShared/Core/Logging/WPSharedLogging.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#import "WPSharedLogging.h"
#import "WPSharedLoggingPrivate.h"

int WPSharedGetLoggingLevel() {
DDLogLevel WPSharedGetLoggingLevel() {
return ddLogLevel;
}

void WPSharedSetLoggingLevel(int level) {
void WPSharedSetLoggingLevel(DDLogLevel level) {
ddLogLevel = level;
}
49 changes: 49 additions & 0 deletions WordPressShared/Core/Utility/Secret.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import Foundation

/// Wraps a value that contains sensitive information to prevent accidental logging
///
/// Usage example
///
/// ```
/// let password = Secret("my secret password")
/// print(password) // Prints "--redacted--"
/// print(password.secretValue) // Prints "my secret password"
/// ```
///
public struct Secret<T> {
public let secretValue: T

public init(_ secretValue: T) {
self.secretValue = secretValue
}
}

extension Secret: RawRepresentable {
public typealias RawValue = T

public init?(rawValue: Self.RawValue) {
self.init(rawValue)
}

public var rawValue: T {
return secretValue
}
}

extension Secret: CustomStringConvertible, CustomDebugStringConvertible, CustomReflectable {
private static var redacted: String {
return "--redacted--"
}

public var description: String {
return Secret.redacted
}

public var debugDescription: String {
return Secret.redacted
}

public var customMirror: Mirror {
return Mirror(reflecting: Secret.redacted)
}
}
2 changes: 1 addition & 1 deletion WordPressShared/Private/WPSharedLoggingPrivate.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@import CocoaLumberjack;
extern int ddLogLevel;
extern DDLogLevel ddLogLevel;
2 changes: 1 addition & 1 deletion WordPressShared/Private/WPSharedLoggingPrivate.m
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#import "WPSharedLoggingPrivate.h"
int ddLogLevel = DDLogLevelWarning;
DDLogLevel ddLogLevel = DDLogLevelWarning;
24 changes: 24 additions & 0 deletions WordPressSharedTests/SecretTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import WordPressShared
import XCTest

class SecretTests: XCTestCase {
func testSecretDescription() {
let secret = Secret("my secret")
XCTAssertEqual("--redacted--", secret.description, "Description should be redacted")
}

func testSecretDebugDescription() {
let secret = Secret("my secret")
XCTAssertEqual("--redacted--", secret.debugDescription, "Debug description should be redacted")
}

func testSecretMirror() {
let secret = Secret("my secret")
XCTAssertEqual("--redacted--", String(reflecting: secret), "Mirror should be redacted")
}

func testSecretUnwrapsValue() {
let secret = Secret("my secret")
XCTAssertEqual("my secret", secret.secretValue, "secretValue should not be redacted")
}
}

0 comments on commit 7c2c126

Please sign in to comment.