Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Tests for issue #20 #21

Merged
merged 3 commits into from
Sep 13, 2018

Conversation

ravijayaramappa
Copy link
Contributor

@ravijayaramappa ravijayaramappa commented Aug 21, 2018

Tests for issue #20

@ravijayaramappa ravijayaramappa force-pushed the ravi/master/byPassMembrane branch 2 times, most recently from 5c0a1c8 to b7b93f8 Compare August 21, 2018 23:48
@ravijayaramappa ravijayaramappa changed the title Tests for issue #20 test: Tests for issue #20 Aug 21, 2018
@ravijayaramappa ravijayaramappa force-pushed the ravi/master/byPassMembrane branch from b7b93f8 to 6e96cfc Compare August 21, 2018 23:51
@@ -43,7 +43,7 @@ function lockShadowTarget(membrane: ReactiveMembrane, shadowTarget: ReactiveMemb
targetKeys.forEach((key: PropertyKey) => {
let descriptor = getOwnPropertyDescriptor(originalTarget, key) as PropertyDescriptor;

// We do not need to wrap the descriptor if not configurable
// We do not need to wrap the descriptor if configurable
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 51 does the opposite of the original comment.

Test to demostrate that membrane containment can be bypassed using getOwnPropertyDescriptor()
@ravijayaramappa ravijayaramappa force-pushed the ravi/master/byPassMembrane branch from 6e96cfc to bcd1d28 Compare August 21, 2018 23:55
const { get } = desc;
expect(() => {
get().foo = '';
}).toThrow();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps this should become a test of its own?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second assertion(L292) is verifying that the data wasn't mutated. To separate it to its own test case I would have to copy the whole thing, place the mutation attempt(L290) in a try-catch. Seems too much duplication for asserting that read only proxy is blocking the mutation.

And I have the test case description wrong, will fix that.

}).toThrow();
expect(todos['entry'].foo).toEqual('bar');
});
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aside from assertion to throw, what is the difference between the tests in this file and reactive-handler.spec.ts? Wondering if we are duplicating here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are testing two different APIs. Test cases in reactive-handler.spec.ts is testing that the inner object is wrapped in a reactive proxy. The test cases in this file is testing that the readonly proxy cannot be bypassed.

The testcase name is wrong. Will fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both the tests exploit the same loop hole in the implementation.

@ravijayaramappa ravijayaramappa force-pushed the ravi/master/byPassMembrane branch from 30e5206 to 67c16cd Compare August 24, 2018 17:05
@caridy
Copy link
Contributor

caridy commented Sep 7, 2018

Looking good! We will fix this soon.

@caridy caridy merged commit 35ad3a4 into salesforce:master Sep 13, 2018
@ravijayaramappa ravijayaramappa deleted the ravi/master/byPassMembrane branch September 15, 2018 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants