Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
6ec27f0d
Commit
6ec27f0d
authored
Aug 29, 2019
by
Thomas Van Lenten
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an explicit test using secure coding for added safety.
parent
829bb1d7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
3 deletions
+27
-3
GPBMessageTests.m
objectivec/Tests/GPBMessageTests.m
+27
-3
No files found.
objectivec/Tests/GPBMessageTests.m
View file @
6ec27f0d
...
...
@@ -338,14 +338,38 @@
}
-
(
void
)
testCoding
{
GPBMessage
*
original
=
[
self
mergeResult
];
NSData
*
data
=
[
NSKeyedArchiver
archivedDataWithRootObject
:
[
self
mergeResult
]
];
[
NSKeyedArchiver
archivedDataWithRootObject
:
original
];
id
unarchivedObject
=
[
NSKeyedUnarchiver
unarchiveObjectWithData
:
data
];
XCTAssertEqualObjects
(
unarchivedObject
,
[
self
mergeResult
]
);
XCTAssertEqualObjects
(
unarchivedObject
,
original
);
// Intentionally doing a pointer comparison.
XCTAssertNotEqual
(
unarchivedObject
,
[
self
mergeResult
]);
XCTAssertNotEqual
(
unarchivedObject
,
original
);
}
-
(
void
)
testSecureCoding
{
GPBMessage
*
original
=
[
self
mergeResult
];
NSString
*
key
=
@"testing123"
;
NSMutableData
*
data
=
[
NSMutableData
data
];
NSKeyedArchiver
*
archiver
=
[[
NSKeyedArchiver
alloc
]
initForWritingWithMutableData
:
data
];
[
archiver
setRequiresSecureCoding
:
YES
];
[
archiver
encodeObject
:
obj
forKey
:
key
];
[
archiver
finishEncoding
];
NSKeyedUnarchiver
*
unarchiver
=
[[
NSKeyedUnarchiver
alloc
]
initForReadingWithData
:
data
];
[
unarchiver
setRequiresSecureCoding
:
YES
];
id
unarchivedObject
=
[
unarchiver
decodeObjectOfClass
:[
GPBMessage
class
]
forKey
:
key
];
[
unarchiver
finishDecoding
];
XCTAssertEqualObjects
(
unarchivedObject
,
original
);
// Intentionally doing a pointer comparison.
XCTAssertNotEqual
(
unarchivedObject
,
original
);
}
-
(
void
)
testObjectReset
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment