TAILIEUCHUNG - Phát triển Javascript - part 39

Tham khảo tài liệu 'phát triển javascript - part 39', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | The Controller 353 Unfortunately this doesn t play out exactly as planned. The previous test which also calls post is now attempting to call addMessage on chatRoom which is undefined in that test. We can fix the issue by moving the chatRoom stub into setUp as Listing does. Listing Sharing the chatRoom stub function controllerSetUp . addMessage stub All the tests go back to a soothing green and we can turn our attention to the duplicated logic we just introduced in the second test. In particular both tests simulates sending a request with a body. We can simplify the tests considerably by extracting this logic into the setup. Listing shows the updated tests. Listing Cleaning up post tests function controllerSetUp . function data var str encodeURI data data 0 2 data 2 end testCase exports . should parse request body as JSON function test var data data user cjno message hi stub data data 0 data . Download from 354 Server-Side JavaScript with The cleaned up tests certainly are a lot easier to follow and with the sendRequest helper method writing new tests that make requests will be easier as well. All tests pass and we can move on. Malicious Data Notice that we are currently accepting messages completely unfiltered. This can lead to all kinds of scary situations for instance consider the effects of the request in Listing Listing Malicious request topic message data user cjno message script http hacked script Before deploying an application like the one we are currently building we should take care to not blindly accept any end user data unfiltered. Responding to Requests When the controller has added the

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.