securityTest.cpp 758 B

123456789101112131415161718192021222324252627
  1. #include "securityTest.h"
  2. #include "Resources/validyMacros.h"
  3. #include "../../Source/JSONValidator.h"
  4. void testJSONValidator__securityTest::testsecurity(void){
  5. #ifdef JSON_SECURITY_MAX_NEST_LEVEL
  6. #if (JSON_SECURITY_MAX_NEST_LEVEL != 128)
  7. #error, test suite only wants a nest security level of 100
  8. #endif
  9. {
  10. json_string json(JSON_TEXT("{"));
  11. for(unsigned int i = 0; i < 127; ++i){
  12. json += JSON_TEXT("\"n\":{");
  13. }
  14. json += json_string(128, '}');
  15. assertTrue(JSONValidator::isValidRoot(json.c_str()));
  16. }
  17. {
  18. json_string json(JSON_TEXT("{"));
  19. for(unsigned int i = 0; i < 128; ++i){
  20. json += JSON_TEXT("\"n\":{");
  21. }
  22. json += json_string(129, '}');
  23. assertFalse(JSONValidator::isValidRoot(json.c_str()));
  24. }
  25. #endif
  26. }