emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] netsec f8d9d00 2/4: Add tests for network-lookup-address-i


From: Robert Pluim
Subject: [Emacs-diffs] netsec f8d9d00 2/4: Add tests for network-lookup-address-info
Date: Tue, 17 Jul 2018 14:05:25 -0400 (EDT)

branch: netsec
commit f8d9d00b0e95a7a62cd4fe8483793c26c3b753db
Author: Robert Pluim <address@hidden>
Commit: Robert Pluim <address@hidden>

    Add tests for network-lookup-address-info
    
    * test/src/process-tests.el (lookup-family-specification): Test
    network-lookup-address-info api.
    (lookup-unicode-domains): Test that unicode domains fail.
    (lookup-google): Test that normal lookups succeed.
    (non-existent-lookup-failure): Check that known non-existent
    domains fail.
---
 test/src/process-tests.el | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/test/src/process-tests.el b/test/src/process-tests.el
index 551b34f..2cc646e 100644
--- a/test/src/process-tests.el
+++ b/test/src/process-tests.el
@@ -22,6 +22,7 @@
 ;;; Code:
 
 (require 'ert)
+(require 'puny)
 
 ;; Timeout in seconds; the test fails if the timeout is reached.
 (defvar process-test-sentinel-wait-timeout 2.0)
@@ -215,5 +216,29 @@
                                       (string-to-list "stdout\n")
                                       (string-to-list "stderr\n"))))))
 
+(ert-deftest lookup-family-specification ()
+  "network-lookup-address-info should only accept valid family symbols."
+  (should-error (network-lookup-address-info "google.com" 'both))
+  (should (network-lookup-address-info "google.com" 'ipv4))
+  (should (network-lookup-address-info "google.com" 'ipv6)))
+
+(ert-deftest lookup-unicode-domains ()
+  "Unicode domains should fail"
+  (should-error (network-lookup-address-info "faß.de"))
+  (should (length (network-lookup-address-info (puny-encode-domain 
"faß.de")))))
+
+(ert-deftest lookup-google ()
+  "Check that we can look up google IP addresses"
+  (let ((addresses-both (network-lookup-address-info "google.com"))
+        (addresses-v4 (network-lookup-address-info "google.com" 'ipv4))
+        (addresses-v6 (network-lookup-address-info "google.com" 'ipv6)))
+    (should (length addresses-both))
+    (should (length addresses-v4))
+    (should (length addresses-v6))))
+
+(ert-deftest non-existent-lookup-failure ()
+  "Check that looking up non-existent domain returns nil"
+  (should (eq nil (network-lookup-address-info "emacs.invalid"))))
+
 (provide 'process-tests)
 ;; process-tests.el ends here.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]