1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727
|
/*
* SPDX-FileCopyrightText: 2019-2025 Sébastien Helleu <flashcode@flashtux.org>
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
* This file is part of WeeChat, the extensible chat client.
*
* WeeChat is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* WeeChat is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/
/* Test IRC protocol functions */
#include "CppUTest/TestHarness.h"
#include "tests.h"
#include "tests-record.h"
extern "C"
{
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
#include "src/core/core-arraylist.h"
#include "src/core/core-config-file.h"
#include "src/core/core-hashtable.h"
#include "src/core/core-hook.h"
#include "src/core/core-input.h"
#include "src/core/core-string.h"
#include "src/gui/gui-buffer.h"
#include "src/gui/gui-color.h"
#include "src/plugins/plugin.h"
#include "src/plugins/irc/irc-batch.h"
#include "src/plugins/irc/irc-ctcp.h"
#include "src/plugins/irc/irc-protocol.h"
#include "src/plugins/irc/irc-channel.h"
#include "src/plugins/irc/irc-config.h"
#include "src/plugins/irc/irc-nick.h"
#include "src/plugins/irc/irc-server.h"
#include "src/plugins/logger/logger-config.h"
#include "src/plugins/typing/typing-config.h"
#include "src/plugins/typing/typing-status.h"
#include "src/plugins/xfer/xfer-buffer.h"
extern int irc_protocol_is_numeric_command (const char *str);
extern int irc_protocol_log_level_for_command (const char *command);
extern const char *irc_protocol_nick_address (struct t_irc_server *server,
int server_message,
struct t_irc_nick *nick,
const char *nickname,
const char *address);
extern char *irc_protocol_string_params (const char **params,
int arg_start, int arg_end);
extern char *irc_protocol_cap_to_enable (const char *capabilities,
int sasl_requested);
}
#define IRC_FAKE_SERVER "fake"
#define IRC_MSG_005 "PREFIX=(ohv)@%+ MAXLIST=bqeI:100 MODES=4 " \
"NETWORK=StaticBox STATUSMSG=@+ CALLERID=g " \
"CASEMAPPING=strict-rfc1459 LINELEN=4096 NICKLEN=30 MAXNICKLEN=31 " \
"USERLEN=16 HOSTLEN=32 CHANNELLEN=50 TOPICLEN=390 DEAF=D " \
"CHANTYPES=# CHANMODES=eIbq,k,flj,CFLMPQScgimnprstuz " \
"MONITOR=100 UTF8MAPPING=rfc8265 UTF8ONLY"
#define IRC_ALL_CAPS "account-notify,account-tag,away-notify,batch," \
"cap-notify,chghost,draft/multiline,echo-message,extended-join," \
"invite-notify,message-tags,multi-prefix,server-time,setname," \
"userhost-in-names"
#define WEE_CHECK_PROTOCOL_TAGS(__result, __server, __command, __tags, \
__extra_tags) \
ctxt.server = __server; \
ctxt.command = (char *)__command; \
ctxt.tags = __tags; \
STRCMP_EQUAL(__result, irc_protocol_tags (&ctxt, __extra_tags));
#define WEE_CHECK_CAP_TO_ENABLE(__result, __string, __sasl_requested) \
str = irc_protocol_cap_to_enable (__string, __sasl_requested); \
STRCMP_EQUAL(__result, str); \
free (str);
#define RECV(__irc_msg) \
server_recv (__irc_msg);
#define CHECK_CORE(__prefix, __message) \
if (!record_search ("core.weechat", __prefix, __message, NULL)) \
{ \
char **msg = build_error ( \
"Core message not displayed", \
__prefix, \
__message, \
NULL, \
"All messages displayed"); \
record_dump (msg); \
FAIL(string_dyn_free (msg, 0)); \
}
#define CHECK_SRV(__prefix, __message, __tags) \
if (!record_search ("irc.server." IRC_FAKE_SERVER, __prefix, \
__message, __tags)) \
{ \
char **msg = build_error ( \
"Server message not displayed", \
__prefix, \
__message, \
__tags, \
"All messages displayed"); \
record_dump (msg); \
FAIL(string_dyn_free (msg, 0)); \
}
#define CHECK_ERROR_PARAMS(__command, __params, __expected_params) \
CHECK_SRV("=!=", \
"irc: too few parameters received in command " \
"\"" __command "\" (received: " #__params ", " \
"expected: at least " #__expected_params ")", \
"");
#define CHECK_ERROR_NICK(__command) \
CHECK_SRV("=!=", \
"irc: command \"" __command "\" received without nick", \
"");
#define CHECK_ERROR_PARSE(__command, __message) \
CHECK_SRV("=!=", \
"irc: failed to parse command \"" __command "\" " \
"(please report to developers): \"" __message "\"", \
"");
#define CHECK_CHAN(__prefix, __message, __tags) \
if (!record_search ("irc." IRC_FAKE_SERVER ".#test", __prefix, \
__message, __tags)) \
{ \
char **msg = build_error ( \
"Channel message not displayed", \
__prefix, \
__message, \
__tags, \
"All messages displayed"); \
record_dump (msg); \
FAIL(string_dyn_free (msg, 0)); \
}
#define CHECK_CHAN_DATE_VALUE(__prefix, __message, __tags, \
__date_sec, __date_usec) \
{ \
struct timeval tv_now; \
const char *ptr_date; \
long value; \
char *error; \
gettimeofday (&tv_now, NULL); \
struct t_hashtable *record = record_search ( \
"irc." IRC_FAKE_SERVER ".#test", \
__prefix, __message, __tags); \
if (!record) \
{ \
char **msg = build_error ( \
"Channel message not displayed", \
__prefix, \
__message, \
__tags, \
"All messages displayed"); \
record_dump (msg); \
FAIL(string_dyn_free (msg, 0)); \
} \
ptr_date = (const char *)hashtable_get (record, "date"); \
CHECK(ptr_date); \
value = strtol (ptr_date, &error, 10); \
CHECK(error && !error[0]); \
LONGS_EQUAL(__date_sec, value); \
ptr_date = (const char *)hashtable_get (record, "date_usec"); \
CHECK(ptr_date); \
value = strtol (ptr_date, &error, 10); \
CHECK(error && !error[0]); \
LONGS_EQUAL(__date_usec, value); \
}
#define CHECK_CHAN_DATE_NOW(__prefix, __message, __tags) \
{ \
struct timeval tv_now; \
const char *ptr_date; \
long value; \
char *error; \
gettimeofday (&tv_now, NULL); \
struct t_hashtable *record = record_search ( \
"irc." IRC_FAKE_SERVER ".#test", \
__prefix, __message, __tags); \
if (!record) \
{ \
char **msg = build_error ( \
"Channel message not displayed", \
__prefix, \
__message, \
__tags, \
"All messages displayed"); \
record_dump (msg); \
FAIL(string_dyn_free (msg, 0)); \
} \
ptr_date = (const char *)hashtable_get (record, "date"); \
CHECK(ptr_date); \
value = strtol (ptr_date, &error, 10); \
CHECK(error && !error[0]); \
CHECK(value >= tv_now.tv_sec - 5); \
CHECK(value <= tv_now.tv_sec + 5); \
}
#define CHECK_PV(__nick, __prefix, __message, __tags) \
if (!record_search ("irc." IRC_FAKE_SERVER "." __nick, \
__prefix, __message, __tags)) \
{ \
char **msg = build_error ( \
"Private message not displayed", \
__prefix, \
__message, \
__tags, \
"All messages displayed"); \
record_dump (msg); \
FAIL(string_dyn_free (msg, 0)); \
}
#define CHECK_PV_CLOSE(__nick, __prefix, __message, __tags) \
CHECK_PV(__nick, __prefix, __message, __tags); \
gui_buffer_close ( \
gui_buffer_search_by_full_name ("irc." IRC_FAKE_SERVER \
"." __nick));
#define CHECK_NO_MSG \
if (arraylist_size (recorded_messages) > 0) \
{ \
char **msg = build_error ( \
"Unexpected message(s) displayed", \
NULL, \
NULL, \
NULL, \
NULL); \
record_dump (msg); \
FAIL(string_dyn_free (msg, 0)); \
}
#define CHECK_SENT(__message) \
if ((__message != NULL) \
&& !arraylist_search (sent_messages, (void *)__message, \
NULL, NULL)) \
{ \
char **msg = build_error ( \
"Message not sent to the IRC server", \
NULL, \
__message, \
NULL, \
"All messages sent"); \
sent_msg_dump (msg); \
FAIL(string_dyn_free (msg, 0)); \
} \
else if ((__message == NULL) \
&& (arraylist_size (sent_messages) > 0)) \
{ \
char **msg = build_error ( \
"Unexpected response(s) sent to the IRC server", \
NULL, \
NULL, \
NULL, \
NULL); \
sent_msg_dump (msg); \
FAIL(string_dyn_free (msg, 0)); \
}
#define SRV_INIT \
RECV(":server 001 alice :Welcome on this server, alice!"); \
CHECK_SRV("--", "Welcome on this server, alice!", \
"irc_001,irc_numeric,nick_server,log3");
#define SRV_INIT_JOIN \
SRV_INIT; \
RECV(":alice!user_a@host_a JOIN #test"); \
CHECK_CHAN("-->", "alice (user_a@host_a) has joined #test", \
"irc_join,nick_alice,host_user_a@host_a,log4");
#define SRV_INIT_JOIN2 \
SRV_INIT_JOIN; \
RECV(":bob!user_b@host_b JOIN #test"); \
CHECK_CHAN("-->", "bob (user_b@host_b) has joined #test", \
"irc_join,irc_smart_filter,nick_bob,host_user_b@host_b," \
"log4");
TEST_GROUP(IrcProtocol)
{
};
TEST_GROUP(IrcProtocolWithServer)
{
struct t_irc_server *ptr_server = NULL;
struct t_arraylist *sent_messages = NULL;
struct t_hook *hook_signal_irc_out = NULL;
void server_recv (const char *command)
{
char str_command[4096];
record_start ();
arraylist_clear (sent_messages);
snprintf (str_command, sizeof (str_command),
"/command -buffer irc.server." IRC_FAKE_SERVER " irc "
"/server fakerecv \"%s\"",
command);
run_cmd_quiet (str_command);
record_stop ();
}
void server_input_data (const char *buffer, const char *data)
{
struct t_gui_buffer *ptr_buffer;
record_start ();
arraylist_clear (sent_messages);
ptr_buffer = gui_buffer_search_by_full_name (buffer);
if (ptr_buffer)
input_data (ptr_buffer, data, NULL, 0, 0);
record_stop ();
}
char **build_error (const char *msg1,
const char *prefix,
const char *message,
const char *tags,
const char *msg2)
{
char **msg;
msg = string_dyn_alloc (1024);
string_dyn_concat (msg, msg1, -1);
if (message)
{
string_dyn_concat (msg, ": prefix=\"", -1);
string_dyn_concat (msg, prefix, -1);
string_dyn_concat (msg, "\", message=\"", -1);
string_dyn_concat (msg, message, -1);
string_dyn_concat (msg, "\", tags=\"", -1);
string_dyn_concat (msg, tags, -1);
string_dyn_concat (msg, "\"\n", -1);
}
else
{
string_dyn_concat (msg, ":\n", -1);
}
if (msg2)
{
string_dyn_concat (msg, msg2, -1);
string_dyn_concat (msg, ":\n", -1);
}
return msg;
}
static int signal_irc_out_cb (const void *pointer, void *data,
const char *signal, const char *type_data,
void *signal_data)
{
/* make C++ compiler happy */
(void) data;
(void) signal;
(void) type_data;
if (signal_data)
{
arraylist_add ((struct t_arraylist *)pointer,
strdup ((const char *)signal_data));
}
return WEECHAT_RC_OK;
}
static int sent_msg_cmp_cb (void *data, struct t_arraylist *arraylist,
void *pointer1, void *pointer2)
{
/* make C++ compiler happy */
(void) data;
(void) arraylist;
return strcmp ((char *)pointer1, (char *)pointer2);
}
static void sent_msg_free_cb (void *data, struct t_arraylist *arraylist,
void *pointer)
{
/* make C++ compiler happy */
(void) data;
(void) arraylist;
free (pointer);
}
void sent_msg_dump (char **msg)
{
int i;
for (i = 0; i < arraylist_size (sent_messages); i++)
{
string_dyn_concat (msg, " \"", -1);
string_dyn_concat (msg,
(const char *)arraylist_get (sent_messages, i),
-1);
string_dyn_concat (msg, "\"\n", -1);
}
}
void setup ()
{
/* initialize list of messages sent to the server */
if (sent_messages)
{
arraylist_clear (sent_messages);
}
else
{
sent_messages = arraylist_new (16, 0, 1,
&sent_msg_cmp_cb, NULL,
&sent_msg_free_cb, NULL);
}
if (!hook_signal_irc_out)
{
hook_signal_irc_out = hook_signal (
NULL,
IRC_FAKE_SERVER ",irc_out1_*",
&signal_irc_out_cb, sent_messages, NULL);
}
/*
* disable backlog feature during tests, so we are not polluted by
* these messages when buffers are opened
*/
config_file_option_set (logger_config_look_backlog, "0", 1);
/* create a fake server (no I/O) */
run_cmd_quiet ("/mute /server add " IRC_FAKE_SERVER " fake:127.0.0.1 "
"-nicks=nick1,nick2,nick3");
/* connect to the fake server */
run_cmd_quiet ("/connect " IRC_FAKE_SERVER);
/* get the server pointer */
ptr_server = irc_server_search (IRC_FAKE_SERVER);
}
void teardown ()
{
/* disconnect and delete the fake server */
run_cmd_quiet ("/mute /disconnect " IRC_FAKE_SERVER);
run_cmd_quiet ("/mute /server del " IRC_FAKE_SERVER);
ptr_server = NULL;
/* restore backlog feature */
config_file_option_reset (logger_config_look_backlog, 1);
}
};
/*
* Tests functions:
* irc_protocol_is_numeric_command
*/
TEST(IrcProtocol, IsNumericCommand)
{
LONGS_EQUAL(0, irc_protocol_is_numeric_command (NULL));
LONGS_EQUAL(0, irc_protocol_is_numeric_command (""));
LONGS_EQUAL(0, irc_protocol_is_numeric_command ("abc"));
LONGS_EQUAL(1, irc_protocol_is_numeric_command ("0"));
LONGS_EQUAL(1, irc_protocol_is_numeric_command ("1"));
LONGS_EQUAL(1, irc_protocol_is_numeric_command ("12"));
LONGS_EQUAL(1, irc_protocol_is_numeric_command ("123"));
}
/*
* Tests functions:
* irc_protocol_log_level_for_command
*/
TEST(IrcProtocol, LogLevelForCommand)
{
LONGS_EQUAL(0, irc_protocol_log_level_for_command (NULL));
LONGS_EQUAL(0, irc_protocol_log_level_for_command (""));
LONGS_EQUAL(1, irc_protocol_log_level_for_command ("privmsg"));
LONGS_EQUAL(1, irc_protocol_log_level_for_command ("notice"));
LONGS_EQUAL(2, irc_protocol_log_level_for_command ("nick"));
LONGS_EQUAL(4, irc_protocol_log_level_for_command ("join"));
LONGS_EQUAL(4, irc_protocol_log_level_for_command ("part"));
LONGS_EQUAL(4, irc_protocol_log_level_for_command ("quit"));
LONGS_EQUAL(4, irc_protocol_log_level_for_command ("nick_back"));
LONGS_EQUAL(3, irc_protocol_log_level_for_command ("001"));
LONGS_EQUAL(3, irc_protocol_log_level_for_command ("away"));
LONGS_EQUAL(3, irc_protocol_log_level_for_command ("kick"));
LONGS_EQUAL(3, irc_protocol_log_level_for_command ("topic"));
}
/*
* Tests functions:
* irc_protocol_tags
*/
TEST(IrcProtocolWithServer, Tags)
{
struct t_irc_protocol_ctxt ctxt;
struct t_hashtable *tags_empty, *tags_1, *tags_2;
SRV_INIT;
memset (&ctxt, 0, sizeof (ctxt));
ctxt.nick = strdup ("alice");
ctxt.nick_is_me = 1;
ctxt.address = strdup ("user@example.com");
tags_empty = hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL, NULL);
tags_1 = hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL, NULL);
hashtable_set (tags_1, "key1", "value1");
tags_2 = hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL, NULL);
hashtable_set (tags_2, "key1", "value1");
hashtable_set (tags_2, "key_2,comma", "value2,comma");
hashtable_set (tags_2, "key_3_empty", "");
hashtable_set (tags_2, "key_4_null", NULL);
WEE_CHECK_PROTOCOL_TAGS("nick_alice,host_user@example.com",
NULL, NULL, NULL, NULL);
/* command */
WEE_CHECK_PROTOCOL_TAGS("irc_privmsg,nick_alice,host_user@example.com,log1",
NULL, "privmsg", NULL, NULL);
WEE_CHECK_PROTOCOL_TAGS("irc_join,nick_alice,host_user@example.com,log4",
NULL, "join", NULL, NULL);
/* command + irc_msg_tags */
WEE_CHECK_PROTOCOL_TAGS(
"irc_privmsg,nick_alice,host_user@example.com,log1",
NULL, "privmsg", tags_empty, NULL);
WEE_CHECK_PROTOCOL_TAGS(
"irc_join,nick_alice,host_user@example.com,log4",
NULL, "join", tags_empty, NULL);
WEE_CHECK_PROTOCOL_TAGS(
"irc_privmsg,irc_tag_key1=value1,nick_alice,host_user@example.com,log1",
NULL, "privmsg", tags_1, NULL);
WEE_CHECK_PROTOCOL_TAGS(
"irc_join,irc_tag_key1=value1,nick_alice,host_user@example.com,log4",
NULL, "join", tags_1, NULL);
WEE_CHECK_PROTOCOL_TAGS(
"irc_privmsg,irc_tag_key1=value1,"
"irc_tag_key_2;comma=value2;comma,"
"irc_tag_key_3_empty=,irc_tag_key_4_null,nick_alice,"
"host_user@example.com,log1",
NULL, "privmsg", tags_2, NULL);
WEE_CHECK_PROTOCOL_TAGS(
"irc_join,irc_tag_key1=value1,"
"irc_tag_key_2;comma=value2;comma,"
"irc_tag_key_3_empty=,irc_tag_key_4_null,nick_alice,"
"host_user@example.com,log4",
NULL, "join", tags_2, NULL);
/* command + extra_tags */
WEE_CHECK_PROTOCOL_TAGS(
"irc_privmsg,nick_alice,host_user@example.com,log1",
NULL, "privmsg", NULL, "");
WEE_CHECK_PROTOCOL_TAGS(
"irc_join,nick_alice,host_user@example.com,log4",
NULL, "join", NULL, "");
WEE_CHECK_PROTOCOL_TAGS(
"irc_privmsg,tag1,tag2,nick_alice,host_user@example.com,log1",
NULL, "privmsg", NULL, "tag1,tag2");
WEE_CHECK_PROTOCOL_TAGS(
"irc_join,tag1,tag2,nick_alice,host_user@example.com,log4",
NULL, "join", NULL, "tag1,tag2");
/* command + irc_msg_tags + extra_tags + nick */
WEE_CHECK_PROTOCOL_TAGS(
"irc_privmsg,irc_tag_key1=value1,irc_tag_key_2;comma=value2;comma,"
"irc_tag_key_3_empty=,irc_tag_key_4_null,tag1,tag2,nick_bob,log1",
NULL, "privmsg", tags_2, "tag1,tag2,nick_bob");
/* command + irc_msg_tags + extra_tags + nick + address */
WEE_CHECK_PROTOCOL_TAGS(
"irc_privmsg,irc_tag_key1=value1,irc_tag_key_2;comma=value2;comma,"
"irc_tag_key_3_empty=,irc_tag_key_4_null,tag1,tag2,nick_bob,"
"host_user@host,log1",
NULL, "privmsg", tags_2,
"tag1,tag2,nick_bob,host_user@host");
/* self message */
WEE_CHECK_PROTOCOL_TAGS(
"irc_privmsg,self_msg,host_user@example.com,log1",
NULL, "privmsg", NULL, "self_msg");
/* server + self message */
WEE_CHECK_PROTOCOL_TAGS(
"irc_privmsg,self_msg,nick_alice,host_user@example.com,log1",
ptr_server, "privmsg", NULL, "self_msg");
/* server + self message + host */
WEE_CHECK_PROTOCOL_TAGS(
"irc_privmsg,self_msg,host_user@host,nick_alice,log1",
ptr_server, "privmsg", NULL, "self_msg,host_user@host");
/* server + self message (other nick) + host */
ctxt.nick_is_me = 0;
WEE_CHECK_PROTOCOL_TAGS(
"irc_privmsg,self_msg,nick_bob,log1",
ptr_server, "privmsg", NULL, "self_msg,nick_bob");
hashtable_free (tags_empty);
hashtable_free (tags_1);
hashtable_free (tags_2);
free (ctxt.nick);
free (ctxt.address);
}
/*
* Tests functions:
* irc_protocol_string_params
*/
TEST(IrcProtocol, StringParams)
{
char *str;
const char *params_empty[] = { "", NULL };
const char *params_1[] = { "param1", NULL };
const char *params_2[] = { "param1", "param2", NULL };
const char *params_3[] = { "param1", "param2", "param3", NULL };
/* invalid arguments */
WEE_TEST_STR("", irc_protocol_string_params (NULL, -1, -1));
WEE_TEST_STR("", irc_protocol_string_params (NULL, 0, 0));
WEE_TEST_STR("", irc_protocol_string_params (NULL, 0, -1));
WEE_TEST_STR("", irc_protocol_string_params (params_1, 1, 0));
/* empty parameter */
WEE_TEST_STR("", irc_protocol_string_params (params_empty, 0, 0));
WEE_TEST_STR("", irc_protocol_string_params (params_empty, 1, 1));
/* one parameter */
WEE_TEST_STR("param1", irc_protocol_string_params (params_1, 0, 0));
WEE_TEST_STR("", irc_protocol_string_params (params_1, 1, 1));
/* two parameters */
WEE_TEST_STR("param1 param2", irc_protocol_string_params (params_2, 0, 1));
WEE_TEST_STR("param2", irc_protocol_string_params (params_2, 1, 1));
WEE_TEST_STR("", irc_protocol_string_params (params_2, 2, 2));
/* three parameters */
WEE_TEST_STR("param1 param2 param3", irc_protocol_string_params (params_3, 0, 2));
WEE_TEST_STR("param2 param3", irc_protocol_string_params (params_3, 1, 2));
WEE_TEST_STR("param2", irc_protocol_string_params (params_3, 1, 1));
WEE_TEST_STR("param3", irc_protocol_string_params (params_3, 2, 2));
WEE_TEST_STR("", irc_protocol_string_params (params_3, 3, 3));
}
/*
* Tests send of messages to channel (STATUSMSG and normal) and nick,
* without capability "echo-message" enabled:
* - message (text)
* - notice (/notice)
* - action (/me + /ctcp)
* - CTCP (/ctcp)
*/
TEST(IrcProtocolWithServer, SendMessagesWithoutEchoMessage)
{
const char *buffer_server = "irc.server." IRC_FAKE_SERVER;
const char *buffer_chan = "irc." IRC_FAKE_SERVER ".#test";
const char *buffer_pv = "irc." IRC_FAKE_SERVER ".bob";
SRV_INIT_JOIN;
/* open private buffer */
RECV(":bob!user@host PRIVMSG alice :hi Alice!");
/* message to channel (text in buffer) */
server_input_data (buffer_chan, "\002msg chan 1");
CHECK_SENT("PRIVMSG #test :\002msg chan 1");
CHECK_CHAN("alice", "msg chan 1",
"irc_privmsg,self_msg,notify_none,no_highlight,prefix_nick_white,"
"nick_alice,log1");
/* message to channel (with /msg <channel>) */
server_input_data (buffer_server, "/msg #test \002msg chan 2");
CHECK_SENT("PRIVMSG #test :\002msg chan 2");
CHECK_CHAN("alice", "msg chan 2",
"irc_privmsg,self_msg,notify_none,no_highlight,prefix_nick_white,"
"nick_alice,log1");
/* message to channel (with /msg <channel>), channel not joined */
server_input_data (buffer_server, "/msg #zzz \002msg chan not joined");
CHECK_SENT("PRIVMSG #zzz :\002msg chan not joined");
CHECK_SRV("--", "Msg(alice) -> #zzz: msg chan not joined",
"irc_privmsg,self_msg,notify_none,no_highlight,nick_alice,log1");
/* STATUSMSG message to channel (with /msg @<channel>) */
server_input_data (buffer_server, "/msg @#test \002msg chan ops");
CHECK_SENT("PRIVMSG @#test :\002msg chan ops");
CHECK_CHAN("--", "Msg(alice) -> @#test: msg chan ops",
"irc_privmsg,self_msg,notify_none,no_highlight,nick_alice,log1");
/* STATUSMSG message to channel (with /msg @<channel>), channel not joined */
server_input_data (buffer_server, "/msg @#zzz \002msg chan ops not joined");
CHECK_SENT("PRIVMSG @#zzz :\002msg chan ops not joined");
CHECK_SRV("--", "Msg(alice) -> @#zzz: msg chan ops not joined",
"irc_privmsg,self_msg,notify_none,no_highlight,nick_alice,log1");
/* message to a nick (text in private buffer) */
server_input_data (buffer_pv, "\002msg pv 1");
CHECK_SENT("PRIVMSG bob :\002msg pv 1");
CHECK_PV("bob", "alice", "msg pv 1",
"irc_privmsg,self_msg,notify_none,no_highlight,prefix_nick_white,"
"nick_alice,log1");
/* message to a nick (with /msg <nick>) */
server_input_data (buffer_server, "/msg bob \002msg pv 2");
CHECK_SENT("PRIVMSG bob :\002msg pv 2");
CHECK_PV("bob", "alice", "msg pv 2",
"irc_privmsg,self_msg,notify_none,no_highlight,prefix_nick_white,"
"nick_alice,log1");
/* message to a nick (with /msg <nick>), hidden password */
server_input_data (buffer_server, "/msg nickserv identify secret");
CHECK_SENT("PRIVMSG nickserv :identify secret");
CHECK_SRV("--", "Msg(alice) -> nickserv: identify ******",
"irc_privmsg,self_msg,notify_none,no_highlight,nick_alice,log1");
/* message to a nick (with /query <nick>) */
server_input_data (buffer_server, "/query bob \002msg pv 3");
CHECK_SENT("PRIVMSG bob :\002msg pv 3");
CHECK_PV("bob", "alice", "msg pv 3",
"irc_privmsg,self_msg,notify_none,no_highlight,prefix_nick_white,"
"nick_alice,log1");
/* message to a nick (with /query <nick>), private buffer does not exist */
server_input_data (buffer_server, "/query bob_query \002msg pv 4");
CHECK_SENT("PRIVMSG bob_query :\002msg pv 4");
CHECK_PV("bob_query", "alice", "msg pv 4",
"irc_privmsg,self_msg,notify_none,no_highlight,prefix_nick_white,"
"nick_alice,log1");
/* notice to channel */
server_input_data (buffer_server, "/notice #test \002notice chan");
CHECK_SENT("NOTICE #test :\002notice chan");
CHECK_CHAN("--", "Notice(alice) -> #test: notice chan",
"irc_notice,self_msg,notify_none,no_highlight,nick_alice,log1");
/* STATUSMSG notice to channel */
server_input_data (buffer_server, "/notice @#test \002notice chan ops");
CHECK_SENT("NOTICE @#test :\002notice chan ops");
CHECK_CHAN("--", "Notice(alice) -> @#test: notice chan ops",
"irc_notice,self_msg,notify_none,no_highlight,nick_alice,log1");
/* notice to a nick */
server_input_data (buffer_server, "/notice bob \002notice pv");
CHECK_SENT("NOTICE bob :\002notice pv");
CHECK_PV("bob", "--", "Notice(alice) -> bob: notice pv",
"irc_notice,self_msg,notify_none,no_highlight,nick_alice,log1");
/* action on channel (with /me) */
server_input_data (buffer_chan, "/me \002action chan 1");
CHECK_SENT("PRIVMSG #test :\001ACTION \002action chan 1\001");
CHECK_CHAN(" *", "alice action chan 1",
"irc_privmsg,irc_action,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
/* action on channel (with /me), no message */
server_input_data (buffer_chan, "/me");
CHECK_SENT("PRIVMSG #test :\001ACTION\001");
CHECK_CHAN(" *", "alice",
"irc_privmsg,irc_action,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
/* action on channel (with raw code: "\001ACTION") */
server_input_data (buffer_chan, "\001ACTION \002is testing\001");
CHECK_SENT("PRIVMSG #test :\001ACTION \002is testing\001");
CHECK_CHAN(" *", "alice is testing",
"irc_privmsg,irc_action,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
/* action on channel (with raw code: "\001ACTION"), no message */
server_input_data (buffer_chan, "\001ACTION\001");
CHECK_SENT("PRIVMSG #test :\001ACTION\001");
CHECK_CHAN(" *", "alice",
"irc_privmsg,irc_action,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
/* action on channel (with /action *) */
server_input_data (buffer_chan, "/action * \002action chan 2");
CHECK_SENT("PRIVMSG #test :\001ACTION \002action chan 2\001");
CHECK_CHAN(" *", "alice action chan 2",
"irc_privmsg,irc_action,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
/* action on channel (with /action <channel>) */
server_input_data (buffer_server, "/action #test \002action chan 3");
CHECK_SENT("PRIVMSG #test :\001ACTION \002action chan 3\001");
CHECK_CHAN(" *", "alice action chan 3",
"irc_privmsg,irc_action,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
/* action on channel (with /action <channel>), no message */
server_input_data (buffer_chan, "/action #test");
CHECK_SENT("PRIVMSG #test :\001ACTION\001");
CHECK_CHAN(" *", "alice",
"irc_privmsg,irc_action,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
/* STATUSMSG action on channel (with /action @<channel>) */
server_input_data (buffer_server, "/action @#test \002action chan 4");
CHECK_SENT("PRIVMSG @#test :\001ACTION \002action chan 4\001");
CHECK_CHAN("--", "Action -> @#test: alice action chan 4",
"irc_privmsg,irc_action,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
/* STATUSMSG action on channel (with /action @<channel>), no message */
server_input_data (buffer_server, "/action @#test");
CHECK_SENT("PRIVMSG @#test :\001ACTION\001");
CHECK_CHAN("--", "Action -> @#test: alice",
"irc_privmsg,irc_action,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
/* action on channel (with /ctcp <channel> action) */
server_input_data (buffer_server, "/ctcp #test action \002action chan 5");
CHECK_SENT("PRIVMSG #test :\001ACTION \002action chan 5\001");
CHECK_CHAN(" *", "alice action chan 5",
"irc_privmsg,irc_action,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
/* action on channel (with /ctcp <channel> action), no message */
server_input_data (buffer_server, "/ctcp #test action");
CHECK_SENT("PRIVMSG #test :\001ACTION\001");
CHECK_CHAN(" *", "alice",
"irc_privmsg,irc_action,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
/* STATUSMSG action on channel (with /ctcp @<channel> action) */
server_input_data (buffer_server, "/ctcp @#test action \002action chan ops");
CHECK_SENT("PRIVMSG @#test :\001ACTION \002action chan ops\001");
CHECK_CHAN("--", "Action -> @#test: alice action chan ops",
"irc_privmsg,irc_action,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
/* action in private (with /me) */
server_input_data (buffer_pv, "/me \002action pv 1");
CHECK_SENT("PRIVMSG bob :\001ACTION \002action pv 1\001");
CHECK_PV("bob", " *", "alice action pv 1",
"irc_privmsg,irc_action,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
/* action in private (with /ctcp) */
server_input_data (buffer_server, "/ctcp bob action \002action pv 2");
CHECK_SENT("PRIVMSG bob :\001ACTION \002action pv 2\001");
CHECK_PV("bob", " *", "alice action pv 2",
"irc_privmsg,irc_action,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
/* action in private (with /ctcp), without private buffer */
server_input_data (buffer_server, "/ctcp bob2 action \002action pv 3");
CHECK_SENT("PRIVMSG bob2 :\001ACTION \002action pv 3\001");
CHECK_SRV("--", "Action -> bob2: alice action pv 3",
"irc_privmsg,irc_action,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
/* CTCP version to channel */
server_input_data (buffer_server, "/ctcp #test version");
CHECK_SENT("PRIVMSG #test :\001VERSION\001");
CHECK_CHAN("--", "CTCP query to #test: VERSION",
"irc_privmsg,irc_ctcp,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
/* unknown CTCP to channel */
server_input_data (buffer_server, "/ctcp #test unknown1 \002some args");
CHECK_SENT("PRIVMSG #test :\001UNKNOWN1 \002some args\001");
CHECK_CHAN("--", "CTCP query to #test: UNKNOWN1 some args",
"irc_privmsg,irc_ctcp,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
/* CTCP version to nick */
server_input_data (buffer_server, "/ctcp bob version");
CHECK_SENT("PRIVMSG bob :\001VERSION\001");
CHECK_PV("bob", "--", "CTCP query to bob: VERSION",
"irc_privmsg,irc_ctcp,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
/* CTCP version to other nick (no private buffer) */
server_input_data (buffer_server, "/ctcp other_nick version");
CHECK_SENT("PRIVMSG other_nick :\001VERSION\001");
CHECK_SRV("--", "CTCP query to other_nick: VERSION",
"irc_privmsg,irc_ctcp,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
/* unknown CTCP to nick */
server_input_data (buffer_server, "/ctcp bob unknown2 \002some args");
CHECK_SENT("PRIVMSG bob :\001UNKNOWN2 \002some args\001");
CHECK_PV("bob", "--", "CTCP query to bob: UNKNOWN2 some args",
"irc_privmsg,irc_ctcp,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
}
/*
* Tests send of messages to channel (STATUSMSG and normal) and nick,
* with capability "echo-message" enabled:
* - message (text)
* - notice (/notice)
* - action (/me + /ctcp)
* - CTCP (/ctcp)
*/
TEST(IrcProtocolWithServer, SendMessagesWithEchoMessage)
{
const char *buffer_server = "irc.server." IRC_FAKE_SERVER;
const char *buffer_chan = "irc." IRC_FAKE_SERVER ".#test";
const char *buffer_pv = "irc." IRC_FAKE_SERVER ".bob";
/* assume "echo-message" capability is enabled in server */
hashtable_set (ptr_server->cap_list, "echo-message", NULL);
SRV_INIT_JOIN;
/* open private buffer */
RECV(":bob!user@host PRIVMSG alice :hi Alice!");
/* message to channel (text in buffer) */
server_input_data (buffer_chan, "\002msg chan 1");
CHECK_SENT("PRIVMSG #test :\002msg chan 1");
CHECK_NO_MSG;
/* message to channel (with /msg <channel>) */
server_input_data (buffer_server, "/msg #test \002msg chan 2");
CHECK_SENT("PRIVMSG #test :\002msg chan 2");
CHECK_NO_MSG;
/* message to channel (with /msg <channel>), channel not joined */
server_input_data (buffer_server, "/msg #zzz \002msg chan not joined");
CHECK_SENT("PRIVMSG #zzz :\002msg chan not joined");
CHECK_NO_MSG;
/* STATUSMSG message to channel (with /msg @<channel>) */
server_input_data (buffer_server, "/msg @#test \002msg chan ops");
CHECK_SENT("PRIVMSG @#test :\002msg chan ops");
CHECK_NO_MSG;
/* STATUSMSG message to channel (with /msg @<channel>), channel not joined */
server_input_data (buffer_server, "/msg @#zzz \002msg chan ops not joined");
CHECK_SENT("PRIVMSG @#zzz :\002msg chan ops not joined");
CHECK_NO_MSG;
/* message to a nick (text in private buffer) */
server_input_data (buffer_pv, "\002msg pv 1");
CHECK_SENT("PRIVMSG bob :\002msg pv 1");
CHECK_NO_MSG;
/* message to a nick (with /msg <nick>) */
server_input_data (buffer_server, "/msg bob \002msg pv 2");
CHECK_SENT("PRIVMSG bob :\002msg pv 2");
CHECK_NO_MSG;
/* message to a nick (with /msg <nick>), hidden password */
server_input_data (buffer_server, "/msg nickserv identify secret");
CHECK_SENT("PRIVMSG nickserv :identify secret");
CHECK_NO_MSG;
/* message to a nick (with /query <nick>) */
server_input_data (buffer_server, "/query bob \002msg pv 3");
CHECK_SENT("PRIVMSG bob :\002msg pv 3");
CHECK_NO_MSG;
/* message to a nick (with /query <nick>), private buffer does not exist */
server_input_data (buffer_server, "/query bob_query \002msg pv 4");
CHECK_SENT("PRIVMSG bob_query :\002msg pv 4");
CHECK_NO_MSG;
/* notice to channel */
server_input_data (buffer_server, "/notice #test \002notice chan");
CHECK_SENT("NOTICE #test :\002notice chan");
CHECK_NO_MSG;
/* STATUSMSG notice to channel */
server_input_data (buffer_server, "/notice @#test \002notice chan ops");
CHECK_SENT("NOTICE @#test :\002notice chan ops");
CHECK_NO_MSG;
/* notice to a nick */
server_input_data (buffer_server, "/notice bob \002notice pv");
CHECK_SENT("NOTICE bob :\002notice pv");
CHECK_NO_MSG;
/* action on channel (with /me) */
server_input_data (buffer_chan, "/me \002action chan 1");
CHECK_SENT("PRIVMSG #test :\001ACTION \002action chan 1\001");
CHECK_NO_MSG;
/* action on channel (with /me), no message */
server_input_data (buffer_chan, "/me");
CHECK_SENT("PRIVMSG #test :\001ACTION\001");
CHECK_NO_MSG;
/* action on channel (with raw code: "\001ACTION") */
server_input_data (buffer_chan, "\001ACTION \002is testing\001");
CHECK_SENT("PRIVMSG #test :\001ACTION \002is testing\001");
CHECK_NO_MSG;
/* action on channel (with raw code: "\001ACTION"), no message */
server_input_data (buffer_chan, "\001ACTION\001");
CHECK_SENT("PRIVMSG #test :\001ACTION\001");
CHECK_NO_MSG;
/* action on channel (with /action *) */
server_input_data (buffer_chan, "/action * \002action chan 2");
CHECK_SENT("PRIVMSG #test :\001ACTION \002action chan 2\001");
CHECK_NO_MSG;
/* action on channel (with /action <channel>) */
server_input_data (buffer_server, "/action #test \002action chan 3");
CHECK_SENT("PRIVMSG #test :\001ACTION \002action chan 3\001");
CHECK_NO_MSG;
/* action on channel (with /action <channel>), no message */
server_input_data (buffer_chan, "/action #test");
CHECK_SENT("PRIVMSG #test :\001ACTION\001");
CHECK_NO_MSG;
/* STATUSMSG action on channel (with /action @<channel>) */
server_input_data (buffer_server, "/action @#test \002action chan 4");
CHECK_SENT("PRIVMSG @#test :\001ACTION \002action chan 4\001");
CHECK_NO_MSG;
/* STATUSMSG action on channel (with /action @<channel>), no message */
server_input_data (buffer_server, "/action @#test");
CHECK_SENT("PRIVMSG @#test :\001ACTION\001");
CHECK_NO_MSG;
/* action on channel (with /ctcp <channel> action) */
server_input_data (buffer_server, "/ctcp #test action \002action chan 5");
CHECK_SENT("PRIVMSG #test :\001ACTION \002action chan 5\001");
CHECK_NO_MSG;
/* STATUSMSG action on channel (with /ctcp @<channel> action) */
server_input_data (buffer_server, "/ctcp @#test action \002action chan ops");
CHECK_SENT("PRIVMSG @#test :\001ACTION \002action chan ops\001");
CHECK_NO_MSG;
/* action in private (with /me) */
server_input_data (buffer_pv, "/me \002action pv 1");
CHECK_SENT("PRIVMSG bob :\001ACTION \002action pv 1\001");
CHECK_NO_MSG;
/* action in private (with /ctcp) */
server_input_data (buffer_server, "/ctcp bob action \002action pv 2");
CHECK_SENT("PRIVMSG bob :\001ACTION \002action pv 2\001");
CHECK_NO_MSG;
/* action in private (with /ctcp), without private buffer */
server_input_data (buffer_server, "/ctcp bob2 action \002action pv 3");
CHECK_SENT("PRIVMSG bob2 :\001ACTION \002action pv 3\001");
CHECK_NO_MSG;
/* CTCP version to channel */
server_input_data (buffer_server, "/ctcp #test version");
CHECK_SENT("PRIVMSG #test :\001VERSION\001");
CHECK_NO_MSG;
/* unknown CTCP to channel */
server_input_data (buffer_server, "/ctcp #test unknown1 \002some args");
CHECK_SENT("PRIVMSG #test :\001UNKNOWN1 \002some args\001");
CHECK_NO_MSG;
/* CTCP version to nick */
server_input_data (buffer_server, "/ctcp bob version");
CHECK_SENT("PRIVMSG bob :\001VERSION\001");
CHECK_NO_MSG;
/* CTCP version to other nick (no private buffer) */
server_input_data (buffer_server, "/ctcp other_nick version");
CHECK_SENT("PRIVMSG other_nick :\001VERSION\001");
CHECK_NO_MSG;
/* unknown CTCP to nick */
server_input_data (buffer_server, "/ctcp bob unknown2 \002some args");
CHECK_SENT("PRIVMSG bob :\001UNKNOWN2 \002some args\001");
CHECK_NO_MSG;
hashtable_remove (ptr_server->cap_list, "echo-message");
}
/*
* Tests functions:
* irc_protocol_nick_address
*/
TEST(IrcProtocolWithServer, NickAddress)
{
struct t_irc_nick *ptr_nick;
char result[1024];
SRV_INIT_JOIN;
ptr_nick = ptr_server->channels->nicks;
STRCMP_EQUAL("", irc_protocol_nick_address (NULL, 0, NULL,
NULL, NULL));
STRCMP_EQUAL("", irc_protocol_nick_address (ptr_server, 0, NULL,
NULL, NULL));
STRCMP_EQUAL("", irc_protocol_nick_address (ptr_server, 0, ptr_nick,
NULL, NULL));
STRCMP_EQUAL("", irc_protocol_nick_address (ptr_server, 0, ptr_nick,
NULL, NULL));
snprintf (result, sizeof (result),
"%s%s%s",
ptr_nick->color,
"alice",
gui_color_get_custom ("reset"));
STRCMP_EQUAL(result, irc_protocol_nick_address (ptr_server, 0, ptr_nick,
"alice", NULL));
snprintf (result, sizeof (result),
"%s%s %s(%s%s%s)%s",
ptr_nick->color,
"alice",
gui_color_search_config ("chat_delimiters"),
gui_color_search_config ("chat_host"),
"example.com",
gui_color_search_config ("chat_delimiters"),
gui_color_get_custom ("reset"));
STRCMP_EQUAL(result, irc_protocol_nick_address (ptr_server, 0, ptr_nick,
"alice", "example.com"));
config_file_option_set (irc_config_look_color_nicks_in_server_messages,
"off", 1);
snprintf (result, sizeof (result),
"%s%s %s(%s%s%s)%s",
ptr_nick->color,
"alice",
gui_color_search_config ("chat_delimiters"),
gui_color_search_config ("chat_host"),
"example.com",
gui_color_search_config ("chat_delimiters"),
gui_color_get_custom ("reset"));
STRCMP_EQUAL(result, irc_protocol_nick_address (ptr_server, 0, ptr_nick,
"alice", "example.com"));
snprintf (result, sizeof (result),
"%s%s %s(%s%s%s)%s",
gui_color_search_config ("chat_nick"),
"alice",
gui_color_search_config ("chat_delimiters"),
gui_color_search_config ("chat_host"),
"example.com",
gui_color_search_config ("chat_delimiters"),
gui_color_get_custom ("reset"));
STRCMP_EQUAL(result, irc_protocol_nick_address (ptr_server, 1, ptr_nick,
"alice", "example.com"));
config_file_option_reset (irc_config_look_color_nicks_in_server_messages, 1);
}
/*
* Tests functions:
* irc_protocol_recv_command (command not found)
*/
TEST(IrcProtocolWithServer, recv_command_not_found)
{
SRV_INIT;
RECV(":alice!user@host XYZ");
CHECK_SRV("=!=", "irc: command \"XYZ\" not found: \":alice!user@host XYZ\"",
"");
RECV(":alice!user@host XYZ abc :\002def");
CHECK_SRV("=!=",
"irc: command \"XYZ\" not found: \":alice!user@host XYZ abc :\002def\"",
"");
RECV(":alice!user@host 099");
CHECK_ERROR_PARAMS("099", 0, 1);
RECV(":alice!user@host 099 abc :\002def");
CHECK_SRV("--", "abc def",
"irc_099,irc_numeric,nick_alice,host_user@host,log3");
}
/*
* Tests functions:
* irc_protocol_recv_command (invalid message)
*/
TEST(IrcProtocolWithServer, recv_command_invalid_message)
{
SRV_INIT;
RECV(":");
CHECK_NO_MSG;
RECV("abc");
CHECK_SRV("=!=", "irc: command \"abc\" not found: \"abc\"", "");
RECV(":alice!user@host");
CHECK_NO_MSG;
RECV("@");
CHECK_SRV("=!=", "irc: command \"@\" not found: \"@\"", "");
RECV("@test");
CHECK_SRV("=!=", "irc: command \"@test\" not found: \"@test\"", "");
RECV("@test :");
CHECK_NO_MSG;
RECV("@test :abc");
CHECK_NO_MSG;
}
/*
* Tests functions:
* irc_protocol_cb_account (without account-notify capability)
*/
TEST(IrcProtocolWithServer, account_without_account_notify_cap)
{
struct t_irc_nick *ptr_nick;
SRV_INIT_JOIN2;
RECV(":bob!user@host PRIVMSG alice :hi Alice!");
ptr_nick = ptr_server->channels->last_nick;
STRCMP_EQUAL(NULL, ptr_nick->account);
/* not enough parameters */
RECV(":bob!user@host ACCOUNT");
CHECK_ERROR_PARAMS("account", 0, 1);
STRCMP_EQUAL(NULL, ptr_nick->account);
RECV(":bob!user@host ACCOUNT *");
CHECK_CHAN("--", "bob has unidentified",
"irc_account,irc_smart_filter,nick_bob,host_user@host,log3");
CHECK_PV("bob", "--", "bob has unidentified",
"irc_account,nick_bob,host_user@host,log3");
STRCMP_EQUAL(NULL, ptr_nick->account);
RECV(":bob!user@host ACCOUNT :*");
CHECK_CHAN("--", "bob has unidentified",
"irc_account,irc_smart_filter,nick_bob,host_user@host,log3");
CHECK_PV("bob", "--", "bob has unidentified",
"irc_account,nick_bob,host_user@host,log3");
STRCMP_EQUAL(NULL, ptr_nick->account);
RECV(":bob!user@host ACCOUNT new_account");
CHECK_CHAN("--", "bob has identified as new_account",
"irc_account,irc_smart_filter,nick_bob,host_user@host,log3");
CHECK_PV("bob", "--", "bob has identified as new_account",
"irc_account,nick_bob,host_user@host,log3");
STRCMP_EQUAL(NULL, ptr_nick->account);
RECV(":bob!user@host ACCOUNT :\002new_account");
CHECK_CHAN("--", "bob has identified as new_account",
"irc_account,irc_smart_filter,nick_bob,host_user@host,log3");
CHECK_PV("bob", "--", "bob has identified as new_account",
"irc_account,nick_bob,host_user@host,log3");
STRCMP_EQUAL(NULL, ptr_nick->account);
}
/*
* Tests functions:
* irc_protocol_cb_account (with account-notify capability)
*/
TEST(IrcProtocolWithServer, account_with_account_notify_cap)
{
struct t_irc_nick *ptr_nick;
/* assume "account-notify" capability is enabled in server */
hashtable_set (ptr_server->cap_list, "account-notify", NULL);
SRV_INIT_JOIN;
ptr_nick = ptr_server->channels->nicks;
STRCMP_EQUAL(NULL, ptr_nick->account);
RECV(":alice!user@host ACCOUNT new_account");
CHECK_CHAN("--", "alice has identified as new_account",
"irc_account,nick_alice,host_user@host,log3");
STRCMP_EQUAL("new_account", ptr_nick->account);
RECV(":alice!user@host ACCOUNT : \002new account with spaces ");
CHECK_CHAN("--", "alice has identified as new account with spaces ",
"irc_account,nick_alice,host_user@host,log3");
STRCMP_EQUAL(" \002new account with spaces ", ptr_nick->account);
RECV(":alice!user@host ACCOUNT *");
CHECK_CHAN("--", "alice has unidentified",
"irc_account,nick_alice,host_user@host,log3");
STRCMP_EQUAL(NULL, ptr_nick->account);
RECV(":alice!user@host ACCOUNT :new_account2");
CHECK_CHAN("--", "alice has identified as new_account2",
"irc_account,nick_alice,host_user@host,log3");
STRCMP_EQUAL("new_account2", ptr_nick->account);
RECV(":alice!user@host ACCOUNT :*");
CHECK_CHAN("--", "alice has unidentified",
"irc_account,nick_alice,host_user@host,log3");
STRCMP_EQUAL(NULL, ptr_nick->account);
hashtable_remove (ptr_server->cap_list, "account-notify");
}
/*
* Tests functions:
* irc_protocol_cb_authenticate
*/
TEST(IrcProtocolWithServer, authenticate)
{
SRV_INIT;
/* not enough parameters */
RECV("AUTHENTICATE");
CHECK_ERROR_PARAMS("authenticate", 0, 1);
RECV(":server.address AUTHENTICATE");
CHECK_ERROR_PARAMS("authenticate", 0, 1);
RECV("AUTHENTICATE "
"QQDaUzXAmVffxuzFy77XWBGwABBQAgdinelBrKZaR3wE7nsIETuTVY= ");
CHECK_NO_MSG;
RECV(":server.address AUTHENTICATE "
"QQDaUzXAmVffxuzFy77XWBGwABBQAgdinelBrKZaR3wE7nsIETuTVY= ");
CHECK_NO_MSG;
}
/*
* Tests functions:
* irc_protocol_cb_away
*/
TEST(IrcProtocolWithServer, away)
{
struct t_irc_nick *ptr_nick;
SRV_INIT_JOIN;
/* missing nick */
RECV("AWAY");
CHECK_ERROR_NICK("away");
ptr_nick = ptr_server->channels->nicks;
LONGS_EQUAL(0, ptr_nick->away);
RECV(":alice!user@host AWAY Bye");
CHECK_NO_MSG;
LONGS_EQUAL(1, ptr_nick->away);
RECV(":alice!user@host AWAY : \002Holidays now! ");
CHECK_NO_MSG;
LONGS_EQUAL(1, ptr_nick->away);
RECV(":alice!user@host AWAY");
CHECK_NO_MSG;
LONGS_EQUAL(0, ptr_nick->away);
}
/*
* Tests functions:
* irc_protocol_cb_batch (without batch cap)
*/
TEST(IrcProtocolWithServer, batch_without_batch_cap)
{
SRV_INIT_JOIN2;
/* not enough parameters */
RECV(":server BATCH");
CHECK_ERROR_PARAMS("batch", 0, 1);
RECV(":server BATCH +test");
CHECK_NO_MSG;
/* invalid reference: does not start with '+' or '-' */
RECV(":server BATCH zzz type");
CHECK_NO_MSG;
POINTERS_EQUAL(NULL, ptr_server->batches);
/* start batch without parameters */
RECV(":server BATCH +ref example");
CHECK_NO_MSG;
POINTERS_EQUAL(NULL, irc_batch_search (ptr_server, "ref"));
/* new messages with batch reference */
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test : \002this is a test ");
CHECK_CHAN("bob", " this is a test ",
"irc_privmsg,irc_tag_batch=ref,notify_message,"
"prefix_nick_248,nick_bob,host_user_b@host_b,log1");
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :second test");
CHECK_CHAN("bob", "second test",
"irc_privmsg,irc_tag_batch=ref,notify_message,"
"prefix_nick_248,nick_bob,host_user_b@host_b,log1");
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :third test");
CHECK_CHAN("bob", "third test",
"irc_privmsg,irc_tag_batch=ref,notify_message,"
"prefix_nick_248,nick_bob,host_user_b@host_b,log1");
/* end batch */
RECV(":server BATCH -ref");
CHECK_NO_MSG;
/* start batch with parameters */
RECV(":server BATCH +ref example param1 param2 param3");
CHECK_NO_MSG;
POINTERS_EQUAL(NULL, irc_batch_search (ptr_server, "ref"));
/* new messages with batch reference */
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :test 1");
CHECK_CHAN("bob", "test 1",
"irc_privmsg,irc_tag_batch=ref,notify_message,"
"prefix_nick_248,nick_bob,host_user_b@host_b,log1");
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :test 2");
CHECK_CHAN("bob", "test 2",
"irc_privmsg,irc_tag_batch=ref,notify_message,"
"prefix_nick_248,nick_bob,host_user_b@host_b,log1");
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :test 3");
CHECK_CHAN("bob", "test 3",
"irc_privmsg,irc_tag_batch=ref,notify_message,"
"prefix_nick_248,nick_bob,host_user_b@host_b,log1");
/* end batch */
RECV(":server BATCH -ref");
CHECK_NO_MSG;
/* start/end batch without parameters */
RECV(":server BATCH +ref example");
RECV(":server BATCH -ref");
CHECK_NO_MSG;
POINTERS_EQUAL(NULL, irc_batch_search (ptr_server, "ref"));
/* interleaving batches */
RECV(":server BATCH +1 example");
CHECK_NO_MSG;
RECV("@batch=1 :bob!user_b@host_b PRIVMSG #test :message 1");
CHECK_CHAN("bob", "message 1",
"irc_privmsg,irc_tag_batch=1,notify_message,"
"prefix_nick_248,nick_bob,host_user_b@host_b,log1");
RECV(":server BATCH +2 example");
CHECK_NO_MSG;
RECV("@batch=1 :bob!user_b@host_b PRIVMSG #test :message 2");
CHECK_CHAN("bob", "message 2",
"irc_privmsg,irc_tag_batch=1,notify_message,"
"prefix_nick_248,nick_bob,host_user_b@host_b,log1");
RECV("@batch=2 :bob!user_b@host_b PRIVMSG #test :message 4");
CHECK_CHAN("bob", "message 4",
"irc_privmsg,irc_tag_batch=2,notify_message,"
"prefix_nick_248,nick_bob,host_user_b@host_b,log1");
RECV("@batch=1 :bob!user_b@host_b PRIVMSG #test :message 3");
CHECK_CHAN("bob", "message 3",
"irc_privmsg,irc_tag_batch=1,notify_message,"
"prefix_nick_248,nick_bob,host_user_b@host_b,log1");
RECV(":server BATCH -1");
CHECK_NO_MSG;
RECV("@batch=2 :bob!user_b@host_b PRIVMSG #test :message 5");
CHECK_CHAN("bob", "message 5",
"irc_privmsg,irc_tag_batch=2,notify_message,"
"prefix_nick_248,nick_bob,host_user_b@host_b,log1");
RECV(":server BATCH -2");
CHECK_NO_MSG;
/* nested batch */
RECV(":server BATCH +ref1 example1");
CHECK_NO_MSG;
RECV("@batch=ref1 :server BATCH +ref2 example2");
RECV("@batch=ref1 :bob!user_b@host_b PRIVMSG #test :test ref1");
CHECK_CHAN("bob", "test ref1",
"irc_privmsg,irc_tag_batch=ref1,notify_message,"
"prefix_nick_248,nick_bob,host_user_b@host_b,log1");
RECV("@batch=ref2 :bob!user_b@host_b PRIVMSG #test :test ref2");
CHECK_CHAN("bob", "test ref2",
"irc_privmsg,irc_tag_batch=ref2,notify_message,"
"prefix_nick_248,nick_bob,host_user_b@host_b,log1");
RECV(":server BATCH -ref2");
CHECK_NO_MSG;
RECV(":server BATCH -ref1");
CHECK_NO_MSG;
/* multiline */
RECV(":server BATCH +ref draft/multiline #test");
CHECK_NO_MSG;
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :line 1");
CHECK_CHAN("bob", "line 1",
"irc_privmsg,irc_tag_batch=ref,notify_message,"
"prefix_nick_248,nick_bob,host_user_b@host_b,log1");
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :line 2");
CHECK_CHAN("bob", "line 2",
"irc_privmsg,irc_tag_batch=ref,notify_message,"
"prefix_nick_248,nick_bob,host_user_b@host_b,log1");
RECV(":server BATCH -ref");
CHECK_NO_MSG;
/* multiline with CTCP */
RECV(":server BATCH +ref draft/multiline #test");
CHECK_NO_MSG;
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :\001ACTION is testing");
CHECK_CHAN(" *", "bob is testing",
"irc_privmsg,irc_tag_batch=ref,irc_action,notify_message,"
"nick_bob,host_user_b@host_b,log1");
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :again\001");
CHECK_CHAN("bob", "again\001",
"irc_privmsg,irc_tag_batch=ref,notify_message,"
"prefix_nick_248,nick_bob,host_user_b@host_b,log1");
RECV(":server BATCH -ref");
CHECK_NO_MSG;
}
/*
* Tests functions:
* irc_protocol_cb_batch (with batch cap)
*/
TEST(IrcProtocolWithServer, batch_with_batch_cap)
{
struct t_irc_batch *ptr_batch;
/* assume "batch" capability is enabled in server */
hashtable_set (ptr_server->cap_list, "batch", NULL);
SRV_INIT_JOIN2;
/* not enough parameters */
RECV(":server BATCH");
CHECK_ERROR_PARAMS("batch", 0, 1);
RECV(":server BATCH +test");
CHECK_ERROR_PARSE("batch", ":server BATCH +test");
/* invalid reference: does not start with '+' or '-' */
RECV(":server BATCH zzz type");
CHECK_NO_MSG;
POINTERS_EQUAL(NULL, ptr_server->batches);
/* start batch without parameters */
RECV(":server BATCH +ref example ");
CHECK_NO_MSG;
ptr_batch = irc_batch_search (ptr_server, "ref");
CHECK(ptr_batch);
STRCMP_EQUAL(NULL, ptr_batch->parent_ref);
STRCMP_EQUAL("example", ptr_batch->type);
STRCMP_EQUAL(NULL, ptr_batch->parameters);
POINTERS_EQUAL(NULL, ptr_batch->messages);
LONGS_EQUAL(0, ptr_batch->end_received);
LONGS_EQUAL(0, ptr_batch->messages_processed);
/* new messages with batch reference */
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test : \002this is a test ");
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :second test");
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :third test");
CHECK_NO_MSG;
/* end batch */
RECV(":server BATCH -ref");
CHECK_CHAN("bob", " this is a test ",
"irc_privmsg,irc_tag_batch=ref,irc_batch_type_example,"
"notify_message,prefix_nick_248,nick_bob,"
"host_user_b@host_b,log1");
CHECK_CHAN("bob", "second test",
"irc_privmsg,irc_tag_batch=ref,irc_batch_type_example,"
"notify_message,prefix_nick_248,nick_bob,"
"host_user_b@host_b,log1");
CHECK_CHAN("bob", "third test",
"irc_privmsg,irc_tag_batch=ref,irc_batch_type_example,"
"notify_message,prefix_nick_248,nick_bob,"
"host_user_b@host_b,log1");
POINTERS_EQUAL(NULL, irc_batch_search (ptr_server, "ref"));
/* start batch with parameters */
RECV(":server BATCH +ref example param1 param2 param3 ");
CHECK_NO_MSG;
ptr_batch = irc_batch_search (ptr_server, "ref");
CHECK(ptr_batch);
STRCMP_EQUAL(NULL, ptr_batch->parent_ref);
STRCMP_EQUAL("example", ptr_batch->type);
STRCMP_EQUAL("param1 param2 param3", ptr_batch->parameters);
POINTERS_EQUAL(NULL, ptr_batch->messages);
LONGS_EQUAL(0, ptr_batch->end_received);
LONGS_EQUAL(0, ptr_batch->messages_processed);
/* new messages with batch reference */
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :test 1");
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :test 2");
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :test 3");
CHECK_NO_MSG;
/* end batch */
RECV(":server BATCH -ref");
CHECK_CHAN("bob", "test 1",
"irc_privmsg,irc_tag_batch=ref,irc_batch_type_example,"
"notify_message,prefix_nick_248,nick_bob,"
"host_user_b@host_b,log1");
CHECK_CHAN("bob", "test 2",
"irc_privmsg,irc_tag_batch=ref,irc_batch_type_example,"
"notify_message,prefix_nick_248,nick_bob,"
"host_user_b@host_b,log1");
CHECK_CHAN("bob", "test 3",
"irc_privmsg,irc_tag_batch=ref,irc_batch_type_example,"
"notify_message,prefix_nick_248,nick_bob,"
"host_user_b@host_b,log1");
POINTERS_EQUAL(NULL, irc_batch_search (ptr_server, "ref"));
/* start/end batch without parameters */
RECV(":server BATCH +ref example");
RECV(":server BATCH -ref");
CHECK_NO_MSG;
POINTERS_EQUAL(NULL, irc_batch_search (ptr_server, "ref"));
/* interleaving batches */
RECV(":server BATCH +1 example");
CHECK_NO_MSG;
CHECK(irc_batch_search (ptr_server, "1"));
RECV("@batch=1 :bob!user_b@host_b PRIVMSG #test :message 1");
CHECK_NO_MSG;
RECV(":server BATCH +2 example");
CHECK_NO_MSG;
CHECK(irc_batch_search (ptr_server, "2"));
RECV("@batch=1 :bob!user_b@host_b PRIVMSG #test :message 2");
CHECK_NO_MSG;
RECV("@batch=2 :bob!user_b@host_b PRIVMSG #test :message 4");
CHECK_NO_MSG;
RECV("@batch=1 :bob!user_b@host_b PRIVMSG #test :message 3");
CHECK_NO_MSG;
RECV(":server BATCH -1");
CHECK_CHAN("bob", "message 1",
"irc_privmsg,irc_tag_batch=1,irc_batch_type_example,"
"notify_message,prefix_nick_248,nick_bob,"
"host_user_b@host_b,log1");
CHECK_CHAN("bob", "message 2",
"irc_privmsg,irc_tag_batch=1,irc_batch_type_example,"
"notify_message,prefix_nick_248,nick_bob,"
"host_user_b@host_b,log1");
CHECK_CHAN("bob", "message 3",
"irc_privmsg,irc_tag_batch=1,irc_batch_type_example,"
"notify_message,prefix_nick_248,nick_bob,"
"host_user_b@host_b,log1");
POINTERS_EQUAL(NULL, irc_batch_search (ptr_server, "1"));
RECV("@batch=2 :bob!user_b@host_b PRIVMSG #test :message 5");
CHECK_NO_MSG;
RECV(":server BATCH -2");
CHECK_CHAN("bob", "message 4",
"irc_privmsg,irc_tag_batch=2,irc_batch_type_example,"
"notify_message,prefix_nick_248,nick_bob,"
"host_user_b@host_b,log1");
CHECK_CHAN("bob", "message 5",
"irc_privmsg,irc_tag_batch=2,irc_batch_type_example,"
"notify_message,prefix_nick_248,nick_bob,"
"host_user_b@host_b,log1");
POINTERS_EQUAL(NULL, irc_batch_search (ptr_server, "2"));
/* nested batch */
RECV(":server BATCH +ref1 example1");
CHECK_NO_MSG;
CHECK(irc_batch_search (ptr_server, "ref1"));
RECV("@batch=ref1 :server BATCH +ref2 example2");
CHECK_NO_MSG;
CHECK(irc_batch_search (ptr_server, "ref2"));
RECV("@batch=ref1 :bob!user_b@host_b PRIVMSG #test :test ref1");
CHECK_NO_MSG;
RECV("@batch=ref2 :bob!user_b@host_b PRIVMSG #test :test ref2");
CHECK_NO_MSG;
RECV(":server BATCH -ref2");
CHECK_NO_MSG;
CHECK(irc_batch_search (ptr_server, "ref2"));
RECV(":server BATCH -ref1");
CHECK_CHAN("bob", "test ref1",
"irc_privmsg,irc_tag_batch=ref1,irc_batch_type_example1,"
"notify_message,prefix_nick_248,nick_bob,"
"host_user_b@host_b,log1");
CHECK_CHAN("bob", "test ref2",
"irc_privmsg,irc_tag_batch=ref2,irc_batch_type_example2,"
"notify_message,prefix_nick_248,nick_bob,"
"host_user_b@host_b,log1");
POINTERS_EQUAL(NULL, irc_batch_search (ptr_server, "ref1"));
POINTERS_EQUAL(NULL, irc_batch_search (ptr_server, "ref2"));
/* multiline */
RECV("@time=2023-08-09T07:43:01.830Z;msgid=icqfzy7zdbpix4gy8pvzuv49kw "
":server BATCH +ref draft/multiline #test");
CHECK_NO_MSG;
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :line 1");
CHECK_NO_MSG;
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :line 2");
CHECK_NO_MSG;
RECV(":server BATCH -ref");
CHECK_CHAN("bob", "line 1",
"irc_privmsg,irc_tag_batch=ref,irc_tag_time=2023-08-09T07:43:01.830Z,"
"irc_tag_msgid=icqfzy7zdbpix4gy8pvzuv49kw,"
"irc_batch_type_draft/multiline,notify_message,prefix_nick_248,"
"nick_bob,host_user_b@host_b,log1");
CHECK_CHAN("bob", "line 2",
"irc_privmsg,irc_tag_batch=ref,irc_tag_time=2023-08-09T07:43:01.830Z,"
"irc_tag_msgid=icqfzy7zdbpix4gy8pvzuv49kw,irc_batch_type_draft/multiline,"
"notify_message,prefix_nick_248,nick_bob,host_user_b@host_b,log1");
/* multiline with CTCP */
RECV(":server BATCH +ref draft/multiline #test");
CHECK_NO_MSG;
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :\001ACTION is testing");
CHECK_NO_MSG;
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :again\001");
CHECK_NO_MSG;
RECV(":server BATCH -ref");
CHECK_CHAN(" *", "bob is testing",
"irc_privmsg,irc_tag_batch=ref,irc_batch_type_draft/multiline,"
"irc_action,notify_message,nick_bob,host_user_b@host_b,log1");
CHECK_CHAN("bob", "again\001",
"irc_privmsg,irc_tag_batch=ref,irc_batch_type_draft/multiline,"
"notify_message,prefix_nick_248,nick_bob,"
"host_user_b@host_b,log1");
RECV(":bob!user_b@host_b PRIVMSG #test :prout\001");
CHECK_CHAN("bob", "prout\001",
"irc_privmsg,notify_message,prefix_nick_248,nick_bob,"
"host_user_b@host_b,log1");
/* assume "draft/multiline" capability is enabled in server */
hashtable_set (ptr_server->cap_list, "draft/multiline", NULL);
irc_server_set_buffer_input_multiline (ptr_server, 1);
/* multiline */
RECV("@time=2023-08-09T07:43:01.830Z;msgid=icqfzy7zdbpix4gy8pvzuv49kw "
":server BATCH +ref draft/multiline #test");
CHECK_NO_MSG;
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :line 1");
CHECK_NO_MSG;
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :line 2");
CHECK_NO_MSG;
RECV(":server BATCH -ref");
CHECK_CHAN("bob", "line 1\n"
"line 2",
"irc_privmsg,irc_tag_batch=ref,irc_tag_time=2023-08-09T07:43:01.830Z,"
"irc_tag_msgid=icqfzy7zdbpix4gy8pvzuv49kw,"
"irc_batch_type_draft/multiline,notify_message,prefix_nick_248,"
"nick_bob,host_user_b@host_b,log1");
/* multiline with CTCP */
RECV(":server BATCH +ref draft/multiline #test");
CHECK_NO_MSG;
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :\001ACTION is testing");
CHECK_NO_MSG;
RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :again\001");
CHECK_NO_MSG;
RECV(":server BATCH -ref");
CHECK_CHAN(" *", "bob is testing\n"
"again",
"irc_privmsg,irc_tag_batch=ref,irc_batch_type_draft/multiline,"
"irc_action,notify_message,nick_bob,host_user_b@host_b,log1");
hashtable_remove (ptr_server->cap_list, "draft/multiline");
irc_server_set_buffer_input_multiline (ptr_server, 0);
hashtable_remove (ptr_server->cap_list, "batch");
}
/*
* Tests functions:
* irc_protocol_cap_to_enable
*/
TEST(IrcProtocol, cap_to_enable)
{
char *str;
WEE_CHECK_CAP_TO_ENABLE("", NULL, 0);
WEE_CHECK_CAP_TO_ENABLE("", "", 0);
WEE_CHECK_CAP_TO_ENABLE("extended-join", "extended-join", 0);
WEE_CHECK_CAP_TO_ENABLE("extended-join,sasl", "extended-join", 1);
WEE_CHECK_CAP_TO_ENABLE(IRC_ALL_CAPS, "*", 0);
WEE_CHECK_CAP_TO_ENABLE(IRC_ALL_CAPS ",sasl", "*", 1);
WEE_CHECK_CAP_TO_ENABLE(IRC_ALL_CAPS ",!away-notify,!extended-join,sasl",
"*,!away-notify,!extended-join", 1);
}
/*
* Tests functions:
* irc_protocol_cb_cap
*/
TEST(IrcProtocolWithServer, cap)
{
SRV_INIT;
/* not enough parameters */
RECV("CAP");
CHECK_ERROR_PARAMS("cap", 0, 2);
RECV("CAP *");
CHECK_ERROR_PARAMS("cap", 1, 2);
RECV(":server CAP");
CHECK_ERROR_PARAMS("cap", 0, 2);
RECV(":server CAP *");
CHECK_ERROR_PARAMS("cap", 1, 2);
/* CAP LS */
RECV("CAP * LS :multi-prefix sasl ");
CHECK_SRV("--", "irc: client capability, server supports: multi-prefix sasl",
"irc_cap,log3");
RECV("CAP * LS * :multi-prefix sasl");
CHECK_NO_MSG;
RECV(":server CAP * LS :multi-prefix sasl");
CHECK_SRV("--", "irc: client capability, server supports: multi-prefix sasl",
"irc_cap,log3");
RECV(":server CAP * LS * :multi-prefix sasl");
CHECK_NO_MSG;
/* CAP LIST */
RECV("CAP * LIST : multi-prefix sasl ");
CHECK_SRV("--", "irc: client capability, currently enabled: multi-prefix sasl",
"irc_cap,log3");
RECV("CAP * LIST * :multi-prefix sasl");
CHECK_NO_MSG;
RECV(":server CAP * LIST :multi-prefix sasl");
CHECK_SRV("--", "irc: client capability, currently enabled: multi-prefix sasl",
"irc_cap,log3");
RECV(":server CAP * LIST * :multi-prefix sasl");
CHECK_NO_MSG;
/* CAP NEW */
RECV("CAP * NEW : multi-prefix sasl ");
CHECK_SRV("--", "irc: client capability, now available: multi-prefix sasl ",
"irc_cap,log3");
RECV(":server CAP * NEW :multi-prefix sasl");
CHECK_SRV("--", "irc: client capability, now available: multi-prefix sasl",
"irc_cap,log3");
/* CAP DEL */
RECV("CAP * DEL : multi-prefix sasl ");
CHECK_SRV("--", "irc: client capability, removed: multi-prefix sasl ",
"irc_cap,log3");
RECV(":server CAP * DEL :multi-prefix sasl");
CHECK_SRV("--", "irc: client capability, removed: multi-prefix sasl",
"irc_cap,log3");
/* CAP ACK */
RECV("CAP * ACK : sasl ");
CHECK_SRV("--", "irc: client capability, enabled: sasl", "irc_cap,log3");
RECV(":server CAP * ACK :sasl");
CHECK_SRV("--", "irc: client capability, enabled: sasl", "irc_cap,log3");
/* CAP NAK */
RECV("CAP * NAK : sasl ");
CHECK_SRV("=!=", "irc: client capability, refused: sasl ", "irc_cap,log3");
RECV(":server CAP * NAK :sasl");
CHECK_SRV("=!=", "irc: client capability, refused: sasl", "irc_cap,log3");
}
/*
* Tests functions:
* irc_protocol_cb_chghost
*/
TEST(IrcProtocolWithServer, chghost)
{
struct t_irc_nick *ptr_nick, *ptr_nick2;
SRV_INIT_JOIN2;
RECV(":bob!user_\00304red@host_\00304red PRIVMSG alice :hi Alice!");
ptr_nick = ptr_server->channels->nicks;
ptr_nick2 = ptr_server->channels->last_nick;
STRCMP_EQUAL("user_a@host_a", ptr_nick->host);
/* not enough parameters */
RECV(":alice!user@host CHGHOST");
CHECK_ERROR_PARAMS("chghost", 0, 2);
RECV(":alice!user@host CHGHOST user2");
CHECK_ERROR_PARAMS("chghost", 1, 2);
/* missing nick */
RECV("CHGHOST user2 host2");
CHECK_ERROR_NICK("chghost");
STRCMP_EQUAL("user_a@host_a", ptr_nick->host);
/* self nick */
RECV(":alice!user@host CHGHOST user2 host2 ");
CHECK_CHAN("--", "alice (user@host) has changed host to user2@host2",
"irc_chghost,new_host_user2@host2,nick_alice,host_user@host,log3");
STRCMP_EQUAL("user2@host2", ptr_nick->host);
RECV(":alice!user@host CHGHOST user2 host2");
CHECK_CHAN("--", "alice (user@host) has changed host to user2@host2",
"irc_chghost,new_host_user2@host2,nick_alice,host_user@host,log3");
STRCMP_EQUAL("user2@host2", ptr_nick->host);
RECV(":alice!user2@host2 CHGHOST user3 :host3");
CHECK_CHAN("--", "alice (user2@host2) has changed host to user3@host3",
"irc_chghost,new_host_user3@host3,nick_alice,host_user2@host2,log3");
STRCMP_EQUAL("user3@host3", ptr_nick->host);
/* another nick */
RECV(":bob!user_\00304red@host_\00304red CHGHOST user_\00302blue host_\00302blue");
CHECK_CHAN("--",
"bob (user_red@host_red) has changed host to user_blue@host_blue",
"irc_chghost,new_host_user_\00302blue@host_\00302blue,irc_smart_filter,"
"nick_bob,host_user_\00304red@host_\00304red,log3");
STRCMP_EQUAL("user_\00302blue@host_\00302blue", ptr_nick2->host);
CHECK_PV("bob",
"--",
"bob (user_red@host_red) has changed host to user_blue@host_blue",
"irc_chghost,new_host_user_\00302blue@host_\00302blue,nick_bob,"
"host_user_\00304red@host_\00304red,log3");
}
/*
* Tests functions:
* irc_protocol_cb_error
*/
TEST(IrcProtocolWithServer, error)
{
SRV_INIT;
/* not enough parameters */
RECV("ERROR");
CHECK_ERROR_PARAMS("error", 0, 1);
RECV("ERROR test");
CHECK_SRV("=!=", "test", "irc_error,log3");
RECV("ERROR : Closing Link: irc.server.org (\002Bad Password\002) ");
CHECK_SRV("=!=", " Closing Link: irc.server.org (Bad Password) ",
"irc_error,log3");
}
/*
* Tests functions:
* irc_protocol_cb_fail
*/
TEST(IrcProtocolWithServer, fail)
{
SRV_INIT;
/* not enough parameters */
RECV(":server FAIL");
CHECK_ERROR_PARAMS("fail", 0, 2);
RECV(":server FAIL *");
CHECK_ERROR_PARAMS("fail", 1, 2);
RECV(":server FAIL COMMAND");
CHECK_ERROR_PARAMS("fail", 1, 2);
RECV(":server FAIL * TEST");
CHECK_SRV("=!=", "Failure: [] TEST", "irc_fail,nick_server,log3");
RECV(":server FAIL * TEST : \002the message ");
CHECK_SRV("=!=", "Failure: [TEST] the message ", "irc_fail,nick_server,log3");
RECV(":server FAIL * TEST TEST2");
CHECK_SRV("=!=", "Failure: [TEST] TEST2", "irc_fail,nick_server,log3");
RECV(":server FAIL * TEST TEST2 :the message");
CHECK_SRV("=!=", "Failure: [TEST TEST2] the message",
"irc_fail,nick_server,log3");
RECV(":server FAIL COMMAND TEST");
CHECK_SRV("=!=", "Failure: COMMAND [] TEST", "irc_fail,nick_server,log3");
RECV(":server FAIL COMMAND TEST :the message");
CHECK_SRV("=!=", "Failure: COMMAND [TEST] the message",
"irc_fail,nick_server,log3");
RECV(":server FAIL COMMAND TEST TEST2");
CHECK_SRV("=!=", "Failure: COMMAND [TEST] TEST2", "irc_fail,nick_server,log3");
RECV(":server FAIL COMMAND TEST TEST2 :the message");
CHECK_SRV("=!=", "Failure: COMMAND [TEST TEST2] the message",
"irc_fail,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_invite
*/
TEST(IrcProtocolWithServer, invite)
{
SRV_INIT;
/* not enough parameters */
RECV(":bob!user@host INVITE");
CHECK_ERROR_PARAMS("invite", 0, 2);
RECV(":bob!user@host INVITE alice");
CHECK_ERROR_PARAMS("invite", 1, 2);
/* missing nick */
RECV("INVITE alice #channel");
CHECK_ERROR_NICK("invite");
RECV(":bob!user@host INVITE alice #channel ");
CHECK_SRV("--", "You have been invited to #channel by bob",
"irc_invite,notify_highlight,nick_bob,host_user@host,log3");
RECV(":bob!user@host INVITE xxx #channel");
CHECK_SRV("--", "bob has invited xxx to #channel",
"irc_invite,nick_bob,host_user@host,log3");
}
/*
* Tests functions:
* irc_protocol_cb_join
*/
TEST(IrcProtocolWithServer, join)
{
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
SRV_INIT;
POINTERS_EQUAL(NULL, ptr_server->channels);
/* not enough parameters */
RECV(":alice!user@host JOIN");
CHECK_ERROR_PARAMS("join", 0, 1);
/* missing nick */
RECV("JOIN #test");
CHECK_ERROR_NICK("join");
POINTERS_EQUAL(NULL, ptr_server->channels);
/* join of a user while the channel does not yet exist in local */
RECV(":bob!user@host JOIN #test");
CHECK_NO_MSG;
RECV(":alice!user@host JOIN #test ");
CHECK_CHAN("-->", "alice (user@host) has joined #test",
"irc_join,nick_alice,host_user@host,log4");
ptr_channel = ptr_server->channels;
CHECK(ptr_channel);
CHECK(ptr_channel == ptr_server->last_channel);
LONGS_EQUAL(IRC_CHANNEL_TYPE_CHANNEL, ptr_channel->type);
STRCMP_EQUAL("#test", ptr_channel->name);
STRCMP_EQUAL(NULL, ptr_channel->topic);
STRCMP_EQUAL(NULL, ptr_channel->modes);
LONGS_EQUAL(0, ptr_channel->limit);
STRCMP_EQUAL(NULL, ptr_channel->key);
LONGS_EQUAL(0, ptr_channel->checking_whox);
STRCMP_EQUAL(NULL, ptr_channel->away_message);
LONGS_EQUAL(0, ptr_channel->has_quit_server);
LONGS_EQUAL(0, ptr_channel->cycle);
LONGS_EQUAL(0, ptr_channel->part);
LONGS_EQUAL(0, ptr_channel->part);
STRCMP_EQUAL(NULL, ptr_channel->pv_remote_nick_color);
POINTERS_EQUAL(NULL, ptr_channel->hook_autorejoin);
ptr_nick = ptr_channel->nicks;
LONGS_EQUAL(1, ptr_channel->nicks_count);
CHECK(ptr_nick);
CHECK(ptr_nick == ptr_channel->last_nick);
STRCMP_EQUAL("alice", ptr_nick->name);
STRCMP_EQUAL("user@host", ptr_nick->host);
STRCMP_EQUAL(" ", ptr_nick->prefixes);
STRCMP_EQUAL(" ", ptr_nick->prefix);
LONGS_EQUAL(0, ptr_nick->away);
STRCMP_EQUAL(NULL, ptr_nick->account);
STRCMP_EQUAL(NULL, ptr_nick->realname);
CHECK(ptr_nick->color);
CHECK(ptr_channel->buffer);
RECV(":bob!user@host JOIN #test * : ");
CHECK_CHAN("-->", "bob ( ) (user@host) has joined #test",
"irc_join,irc_smart_filter,nick_bob,host_user@host,log4");
ptr_nick = ptr_channel->last_nick;
LONGS_EQUAL(2, ptr_channel->nicks_count);
CHECK(ptr_nick);
STRCMP_EQUAL("bob", ptr_nick->name);
STRCMP_EQUAL("user@host", ptr_nick->host);
STRCMP_EQUAL(" ", ptr_nick->prefixes);
STRCMP_EQUAL(" ", ptr_nick->prefix);
LONGS_EQUAL(0, ptr_nick->away);
STRCMP_EQUAL(NULL, ptr_nick->account);
STRCMP_EQUAL(" ", ptr_nick->realname);
CHECK(ptr_nick->color);
RECV(":carol!user@host JOIN #test carol_account : \002Carol Name ");
CHECK_CHAN("-->",
"carol [carol_account] ( Carol Name ) (user@host) "
"has joined #test",
"irc_join,irc_smart_filter,nick_carol,host_user@host,log4");
ptr_nick = ptr_channel->last_nick;
LONGS_EQUAL(3, ptr_channel->nicks_count);
CHECK(ptr_nick);
STRCMP_EQUAL("carol", ptr_nick->name);
STRCMP_EQUAL("user@host", ptr_nick->host);
STRCMP_EQUAL(" ", ptr_nick->prefixes);
STRCMP_EQUAL(" ", ptr_nick->prefix);
LONGS_EQUAL(0, ptr_nick->away);
STRCMP_EQUAL("carol_account", ptr_nick->account);
STRCMP_EQUAL(" \002Carol Name ", ptr_nick->realname);
CHECK(ptr_nick->color);
/* join with option irc.look.display_host_join set to off */
config_file_option_set (irc_config_look_display_host_join, "off", 1);
RECV(":dan!user@host JOIN #test");
CHECK_CHAN("-->",
"dan has joined #test",
"irc_join,irc_smart_filter,nick_dan,host_user@host,log4");
config_file_option_reset (irc_config_look_display_host_join, 1);
/* join with option irc.look.display_host_join_local set to off */
config_file_option_set (irc_config_look_display_host_join_local, "off", 1);
RECV(":alice!user@host PART #test");
RECV(":alice!user@host JOIN #test");
CHECK_CHAN("-->", "alice has joined #test",
"irc_join,nick_alice,host_user@host,log4");
config_file_option_reset (irc_config_look_display_host_join_local, 1);
}
/*
* Tests functions:
* irc_protocol_cb_kick
*/
TEST(IrcProtocolWithServer, kick)
{
struct t_irc_channel *ptr_channel;
SRV_INIT;
POINTERS_EQUAL(NULL, ptr_server->channels);
RECV(":alice!user@host JOIN #test");
CHECK_CHAN("-->", "alice (user@host) has joined #test",
"irc_join,nick_alice,host_user@host,log4");
RECV(":bob!user@host JOIN #test");
CHECK_CHAN("-->", "bob (user@host) has joined #test",
"irc_join,irc_smart_filter,nick_bob,host_user@host,log4");
ptr_channel = ptr_server->channels;
CHECK(ptr_channel);
CHECK(ptr_channel->nicks);
STRCMP_EQUAL("alice", ptr_channel->nicks->name);
CHECK(ptr_channel->nicks->next_nick);
STRCMP_EQUAL("bob", ptr_channel->nicks->next_nick->name);
/* not enough parameters */
RECV(":alice!user@host KICK");
CHECK_ERROR_PARAMS("kick", 0, 2);
RECV(":alice!user@host KICK #test");
CHECK_ERROR_PARAMS("kick", 1, 2);
/* missing nick */
RECV("KICK #test bob");
CHECK_ERROR_NICK("kick");
STRCMP_EQUAL("bob", ptr_channel->nicks->next_nick->name);
/* channel not found */
RECV(":alice!user@host KICK #xyz bob :\002the reason");
CHECK_NO_MSG;
/* kick without a reason */
RECV(":alice!user@host KICK #test bob");
CHECK_CHAN("<--", "alice has kicked bob",
"irc_kick,nick_alice,host_user@host,log3");
STRCMP_EQUAL("alice", ptr_channel->nicks->name);
POINTERS_EQUAL(NULL, ptr_channel->nicks->next_nick);
RECV(":bob!user@host JOIN #test");
CHECK_CHAN("-->", "bob (user@host) has joined #test",
"irc_join,irc_smart_filter,nick_bob,host_user@host,log4");
/* with kick a reason */
RECV(":alice!user@host KICK #test bob :\002no spam here! ");
CHECK_CHAN("<--", "alice has kicked bob (no spam here! )",
"irc_kick,nick_alice,host_user@host,log3");
STRCMP_EQUAL("alice", ptr_channel->nicks->name);
POINTERS_EQUAL(NULL, ptr_channel->nicks->next_nick);
RECV(":bob!user@host JOIN #test");
CHECK_CHAN("-->", "bob (user@host) has joined #test",
"irc_join,irc_smart_filter,nick_bob,host_user@host,log4");
/* kick of self nick */
RECV(":bob!user@host KICK #test alice :\002no spam here! ");
CHECK_CHAN("<--", "bob has kicked alice (no spam here! )",
"irc_kick,nick_bob,host_user@host,log3");
POINTERS_EQUAL(NULL, ptr_channel->nicks);
}
/*
* Tests functions:
* irc_protocol_cb_kill
*/
TEST(IrcProtocolWithServer, kill)
{
struct t_irc_channel *ptr_channel;
SRV_INIT_JOIN2;
ptr_channel = ptr_server->channels;
CHECK(ptr_channel);
CHECK(ptr_channel->nicks);
STRCMP_EQUAL("alice", ptr_channel->nicks->name);
CHECK(ptr_channel->nicks->next_nick);
STRCMP_EQUAL("bob", ptr_channel->nicks->next_nick->name);
/* not enough parameters */
RECV(":alice!user@host KILL");
CHECK_ERROR_PARAMS("kill", 0, 1);
/* missing nick */
RECV("KILL alice");
CHECK_ERROR_NICK("kill");
STRCMP_EQUAL("bob", ptr_channel->nicks->next_nick->name);
/* kill without a reason */
RECV(":bob!user@host KILL alice");
CHECK_CHAN("<--", "You were killed by bob",
"irc_kill,nick_bob,host_user@host,log3");
POINTERS_EQUAL(NULL, ptr_channel->nicks);
RECV(":alice!user@host JOIN #test");
CHECK_CHAN("-->", "alice (user@host) has joined #test",
"irc_join,nick_alice,host_user@host,log4");
RECV(":bob!user@host JOIN #test");
CHECK_CHAN("-->", "bob (user@host) has joined #test",
"irc_join,irc_smart_filter,nick_bob,host_user@host,log4");
/* kill with a reason */
RECV(":bob!user@host KILL alice :\002killed by admin ");
CHECK_CHAN("<--", "You were killed by bob (killed by admin )",
"irc_kill,nick_bob,host_user@host,log3");
POINTERS_EQUAL(NULL, ptr_channel->nicks);
}
/*
* Tests functions:
* irc_protocol_cb_mode
*/
TEST(IrcProtocolWithServer, mode)
{
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
SRV_INIT_JOIN;
ptr_channel = ptr_server->channels;
CHECK(ptr_channel);
STRCMP_EQUAL(NULL, ptr_channel->modes);
ptr_nick = ptr_channel->nicks;
CHECK(ptr_nick);
STRCMP_EQUAL("alice", ptr_nick->name);
STRCMP_EQUAL(" ", ptr_nick->prefixes);
STRCMP_EQUAL(" ", ptr_nick->prefix);
/* not enough parameters */
RECV(":admin MODE");
CHECK_ERROR_PARAMS("mode", 0, 2);
RECV(":admin MODE #test");
CHECK_ERROR_PARAMS("mode", 1, 2);
/* missing nick */
RECV("MODE #test +nt");
CHECK_ERROR_NICK("mode");
STRCMP_EQUAL(NULL, ptr_channel->modes);
/* channel mode */
RECV(":admin!user@host MODE #test +nt ");
CHECK_CHAN("--", "Mode #test [+nt] by admin",
"irc_mode,nick_admin,host_user@host,log3");
STRCMP_EQUAL("+tn", ptr_channel->modes);
/* channel mode removed */
RECV(":admin!user@host MODE #test -n");
CHECK_CHAN("--", "Mode #test [-n] by admin",
"irc_mode,nick_admin,host_user@host,log3");
STRCMP_EQUAL("+t", ptr_channel->modes);
/* channel mode removed */
RECV(":admin!user@host MODE #test -t");
CHECK_CHAN("--", "Mode #test [-t] by admin",
"irc_mode,nick_admin,host_user@host,log3");
STRCMP_EQUAL(NULL, ptr_channel->modes);
/* bans added on channel */
RECV(":admin!user@host MODE #test +bb "
"bob!user_\00304red@host_\00304red "
"carol!user_\00304red@host_\00304red");
CHECK_CHAN("--", "Mode #test [+bb bob!user_red@host_red "
"carol!user_red@host_red] by admin",
"irc_mode,nick_admin,host_user@host,log3");
/* bans removed from channel */
RECV(":admin!user@host MODE #test -bb "
"bob!user_\00304red@host_\00304red "
"carol!user_\00304red@host_\00304red");
CHECK_CHAN("--", "Mode #test [-bb bob!user_red@host_red "
"carol!user_red@host_red] by admin",
"irc_mode,nick_admin,host_user@host,log3");
/* nick mode '@' on channel #test */
RECV(":admin!user@host MODE #test +o alice ");
CHECK_CHAN("--", "Mode #test [+o alice] by admin",
"irc_mode,nick_admin,host_user@host,log3");
STRCMP_EQUAL("@ ", ptr_nick->prefixes);
STRCMP_EQUAL("@", ptr_nick->prefix);
/* another nick mode '+' on channel #test */
RECV(":admin!user@host MODE #test +v alice");
CHECK_CHAN("--", "Mode #test [+v alice] by admin",
"irc_mode,nick_admin,host_user@host,log3");
STRCMP_EQUAL("@+", ptr_nick->prefixes);
STRCMP_EQUAL("@", ptr_nick->prefix);
/* nick mode '@' removed on channel #test */
RECV(":admin!user@host MODE #test -o alice");
CHECK_CHAN("--", "Mode #test [-o alice] by admin",
"irc_mode,nick_admin,host_user@host,log3");
STRCMP_EQUAL(" +", ptr_nick->prefixes);
STRCMP_EQUAL("+", ptr_nick->prefix);
/* nick mode '+' removed on channel #test */
RECV(":admin!user@host MODE #test -v alice");
CHECK_CHAN("--", "Mode #test [-v alice] by admin",
"irc_mode,nick_admin,host_user@host,log3");
STRCMP_EQUAL(" ", ptr_nick->prefixes);
STRCMP_EQUAL(" ", ptr_nick->prefix);
/* nick mode 'i' */
STRCMP_EQUAL(NULL, ptr_server->nick_modes);
RECV(":admin!user@host MODE alice +i");
CHECK_SRV("--", "User mode [+i] by admin",
"irc_mode,nick_admin,host_user@host,log3");
STRCMP_EQUAL("i", ptr_server->nick_modes);
/* nick mode 'R' */
RECV(":admin!user@host MODE alice +R");
CHECK_SRV("--", "User mode [+R] by admin",
"irc_mode,nick_admin,host_user@host,log3");
STRCMP_EQUAL("iR", ptr_server->nick_modes);
/* remove nick mode 'i' */
RECV(":admin!user@host MODE alice -i");
CHECK_SRV("--", "User mode [-i] by admin",
"irc_mode,nick_admin,host_user@host,log3");
STRCMP_EQUAL("R", ptr_server->nick_modes);
}
/*
* Tests functions:
* irc_protocol_cb_nick
*/
TEST(IrcProtocolWithServer, nick)
{
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick1, *ptr_nick2;
SRV_INIT_JOIN2;
RECV(":bob!user@host PRIVMSG alice :hi Alice!");
CHECK_PV("bob", "bob", "hi Alice!",
"irc_privmsg,notify_private,prefix_nick_248,nick_bob,"
"host_user@host,log1");
ptr_channel = ptr_server->channels;
CHECK(ptr_channel);
ptr_nick1 = ptr_channel->nicks;
CHECK(ptr_nick1);
ptr_nick2 = ptr_nick1->next_nick;
CHECK(ptr_nick2);
STRCMP_EQUAL("alice", ptr_nick1->name);
STRCMP_EQUAL("bob", ptr_nick2->name);
/* not enough parameters */
RECV(":alice!user@host NICK");
CHECK_ERROR_PARAMS("nick", 0, 1);
STRCMP_EQUAL("alice", ptr_nick1->name);
STRCMP_EQUAL("bob", ptr_nick2->name);
/* missing nick */
RECV("NICK alice_away");
CHECK_ERROR_NICK("nick");
/* new nick for alice */
RECV(":alice!user@host NICK alice_away ");
CHECK_SRV("--", "You are now known as alice_away",
"irc_nick,irc_nick1_alice,irc_nick2_alice_away,"
"nick_alice,host_user@host,log2");
CHECK_CHAN("--", "You are now known as alice_away",
"irc_nick,irc_nick1_alice,irc_nick2_alice_away,"
"nick_alice,host_user@host,log2");
STRCMP_EQUAL("alice_away", ptr_nick1->name);
/* new nick for alice_away (with ":") */
RECV(":alice_away!user@host NICK :alice2");
CHECK_SRV("--", "You are now known as alice2",
"irc_nick,irc_nick1_alice_away,irc_nick2_alice2,"
"nick_alice_away,host_user@host,log2");
CHECK_CHAN("--", "You are now known as alice2",
"irc_nick,irc_nick1_alice_away,irc_nick2_alice2,"
"nick_alice_away,host_user@host,log2");
STRCMP_EQUAL("alice2", ptr_nick1->name);
/* new nick for bob */
RECV(":bob!user@host NICK bob_away");
CHECK_CHAN("--", "bob is now known as bob_away",
"irc_nick,irc_smart_filter,irc_nick1_bob,irc_nick2_bob_away,"
"nick_bob,host_user@host,log2");
CHECK_PV("bob_away", "--", "bob is now known as bob_away",
"irc_nick,irc_nick1_bob,irc_nick2_bob_away,nick_bob,host_user@host,"
"log2");
STRCMP_EQUAL("bob_away", ptr_nick2->name);
/* new nick for bob_away (with ":") */
RECV(":bob_away!user@host NICK :bob2");
CHECK_CHAN("--", "bob_away is now known as bob2",
"irc_nick,irc_smart_filter,irc_nick1_bob_away,"
"irc_nick2_bob2,nick_bob_away,host_user@host,log2");
CHECK_PV("bob2", "--", "bob_away is now known as bob2",
"irc_nick,irc_nick1_bob_away,irc_nick2_bob2,"
"nick_bob_away,host_user@host,log2");
STRCMP_EQUAL("bob2", ptr_nick2->name);
STRCMP_EQUAL("bob2", ptr_server->last_channel->name);
}
/*
* Tests functions:
* irc_protocol_cb_note
*/
TEST(IrcProtocolWithServer, note)
{
SRV_INIT;
/* not enough parameters */
RECV(":server NOTE");
CHECK_ERROR_PARAMS("note", 0, 2);
RECV(":server NOTE *");
CHECK_ERROR_PARAMS("note", 1, 2);
RECV(":server NOTE COMMAND");
CHECK_ERROR_PARAMS("note", 1, 2);
RECV(":server NOTE * TEST");
CHECK_SRV("--", "Note: [] TEST", "irc_note,nick_server,log3");
RECV(":server NOTE * TEST : \002the message ");
CHECK_SRV("--", "Note: [TEST] the message ", "irc_note,nick_server,log3");
RECV(":server NOTE * TEST TEST2");
CHECK_SRV("--", "Note: [TEST] TEST2", "irc_note,nick_server,log3");
RECV(":server NOTE * TEST TEST2 :the message");
CHECK_SRV("--", "Note: [TEST TEST2] the message", "irc_note,nick_server,log3");
RECV(":server NOTE COMMAND TEST");
CHECK_SRV("--", "Note: COMMAND [] TEST", "irc_note,nick_server,log3");
RECV(":server NOTE COMMAND TEST :the message");
CHECK_SRV("--", "Note: COMMAND [TEST] the message", "irc_note,nick_server,log3");
RECV(":server NOTE COMMAND TEST TEST2");
CHECK_SRV("--", "Note: COMMAND [TEST] TEST2", "irc_note,nick_server,log3");
RECV(":server NOTE COMMAND TEST TEST2 :the message");
CHECK_SRV("--", "Note: COMMAND [TEST TEST2] the message",
"irc_note,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_notice
*/
TEST(IrcProtocolWithServer, notice)
{
int echo_message;
SRV_INIT_JOIN;
/* test without and with capability "echo-message" */
for (echo_message = 0; echo_message < 2; echo_message++)
{
if (echo_message == 1)
{
/* assume "echo-message" capability is enabled in server */
hashtable_set (ptr_server->cap_list, "echo-message", NULL);
}
/* not enough parameters */
RECV("NOTICE");
CHECK_ERROR_PARAMS("notice", 0, 2);
RECV("NOTICE AUTH");
CHECK_ERROR_PARAMS("notice", 1, 2);
RECV(":bob!user@host NOTICE");
CHECK_ERROR_PARAMS("notice", 0, 2);
RECV(":bob!user@host NOTICE #test");
CHECK_ERROR_PARSE("notice", ":bob!user@host NOTICE #test");
RECV(":bob!user@host NOTICE alice");
CHECK_ERROR_PARSE("notice", ":bob!user@host NOTICE alice");
/* notice from server */
RECV("NOTICE AUTH :\002*** Looking up your hostname... ");
CHECK_SRV("--", "*** Looking up your hostname... ", "irc_notice,log1");
RECV(":server.address NOTICE AUTH :*** Looking up your hostname... ");
CHECK_SRV("--", "server.address: *** Looking up your hostname... ",
"irc_notice,notify_private,nick_server.address,log1");
RECV(":server.address NOTICE * :*** Looking up your hostname... ");
CHECK_SRV("--", "server.address: *** Looking up your hostname... ",
"irc_notice,notify_private,nick_server.address,log1");
/* notice to channel/user */
RECV(":server.address NOTICE #test :\002a notice ");
CHECK_CHAN("--", "Notice(server.address) -> #test: a notice ",
"irc_notice,notify_message,nick_server.address,log1");
RECV(":server.address NOTICE alice :a notice ");
CHECK_SRV("--", "server.address: a notice ",
"irc_notice,notify_private,nick_server.address,log1");
RECV(":bob!user@host NOTICE #test :a notice ");
CHECK_CHAN("--", "Notice(bob) -> #test: a notice ",
"irc_notice,notify_message,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE alice :a notice ");
CHECK_SRV("--", "bob (user@host): a notice ",
"irc_notice,notify_private,nick_bob,host_user@host,log1");
/* notice to channel/user with color in address */
RECV(":bob!user_\00304red@host_\00304red NOTICE #test :a notice ");
CHECK_CHAN("--", "Notice(bob) -> #test: a notice ",
"irc_notice,notify_message,nick_bob,host_user_\00304red@host_\00304red,log1");
RECV(":bob!user_\00304red@host_\00304red NOTICE alice :a notice ");
CHECK_SRV("--", "bob (user_red@host_red): a notice ",
"irc_notice,notify_private,nick_bob,host_user_\00304red@host_\00304red,log1");
/* notice to channel/user with option irc.look.display_host_notice set to off */
config_file_option_set (irc_config_look_display_host_notice, "off", 1);
RECV(":server.address NOTICE #test :\002a notice ");
CHECK_CHAN("--", "Notice(server.address) -> #test: a notice ",
"irc_notice,notify_message,nick_server.address,log1");
RECV(":server.address NOTICE alice :a notice ");
CHECK_SRV("--", "server.address: a notice ",
"irc_notice,notify_private,nick_server.address,log1");
RECV(":bob!user@host NOTICE #test :a notice ");
CHECK_CHAN("--", "Notice(bob) -> #test: a notice ",
"irc_notice,notify_message,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE alice :a notice ");
CHECK_SRV("--", "bob: a notice ",
"irc_notice,notify_private,nick_bob,host_user@host,log1");
config_file_option_reset (irc_config_look_display_host_notice, 1);
/*
* notice to channel/user from self nick
* (case of bouncer or if echo-message capability is enabled)
*/
RECV(":alice!user@host NOTICE #test :\002a notice ");
CHECK_CHAN("--", "Notice(alice) -> #test: a notice ",
"irc_notice,self_msg,notify_none,no_highlight,nick_alice,"
"host_user@host,log1");
/* notice to ops of channel */
RECV(":server.address NOTICE @#test :\002a notice ");
CHECK_CHAN("--", "Notice(server.address) -> @#test: a notice ",
"irc_notice,notify_message,nick_server.address,log1");
RECV(":bob!user@host NOTICE @#test :a notice ");
CHECK_CHAN("--", "Notice(bob) -> @#test: a notice ",
"irc_notice,notify_message,nick_bob,host_user@host,log1");
/*
* notice to ops of channel from self nick
* (case of bouncer or if echo-message capability is enabled)
*/
RECV(":alice!user@host NOTICE @#test :\002a notice ");
CHECK_CHAN("--", "Notice(alice) -> @#test: a notice ",
"irc_notice,self_msg,notify_none,no_highlight,nick_alice,"
"host_user@host,log1");
/*
* notice from self nick
* (case of bouncer or if echo-message capability is enabled)
*/
RECV(":alice!user@host NOTICE alice :\002a notice ");
CHECK_SRV("--", "Notice -> alice: a notice ",
"irc_notice,notify_private,nick_alice,host_user@host,log1");
/* notice with channel name at beginning */
RECV(":server.address NOTICE alice :[#test] \002a notice ");
CHECK_CHAN("--", "PvNotice(server.address): a notice ",
"irc_notice,nick_server.address,log1");
RECV(":server.address NOTICE alice :(#test) a notice ");
CHECK_CHAN("--", "PvNotice(server.address): a notice ",
"irc_notice,nick_server.address,log1");
RECV(":server.address NOTICE alice :{#test} a notice ");
CHECK_CHAN("--", "PvNotice(server.address): a notice ",
"irc_notice,nick_server.address,log1");
RECV(":server.address NOTICE alice :<#test> a notice ");
CHECK_CHAN("--", "PvNotice(server.address): a notice ",
"irc_notice,nick_server.address,log1");
RECV(":bob!user@host NOTICE alice :[#test] a notice ");
CHECK_CHAN("--", "PvNotice(bob): a notice ",
"irc_notice,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE alice :(#test) a notice ");
CHECK_CHAN("--", "PvNotice(bob): a notice ",
"irc_notice,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE alice :{#test} a notice ");
CHECK_CHAN("--", "PvNotice(bob): a notice ",
"irc_notice,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE alice :<#test> a notice ");
CHECK_CHAN("--", "PvNotice(bob): a notice ",
"irc_notice,nick_bob,host_user@host,log1");
/*
* notice to another nick with channel name at beginning
* (case of a notice sent if echo-message capability is enabled)
*/
RECV(":alice!user@host NOTICE bob :[#test] \002a notice ");
CHECK_SRV("--", "Notice -> bob: [#test] a notice ",
"irc_notice,notify_private,nick_alice,host_user@host,log1");
/* broken CTCP to channel */
RECV(":bob!user@host NOTICE #test :\001");
CHECK_SRV("--", "CTCP reply from bob: ",
"irc_notice,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE #test :\001TEST");
CHECK_SRV("--", "CTCP reply from bob: TEST",
"irc_notice,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE #test :\001ACTION");
CHECK_SRV("--", "CTCP reply from bob: ACTION",
"irc_notice,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE #test :\001ACTION is testing");
CHECK_SRV("--", "CTCP reply from bob: ACTION is testing",
"irc_notice,irc_ctcp,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE #test :\001VERSION");
CHECK_SRV("--", "CTCP reply from bob: VERSION",
"irc_notice,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE #test :\001DCC");
CHECK_SRV("--", "CTCP reply from bob: DCC",
"irc_notice,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE #test :\001DCC SEND");
CHECK_SRV("--", "CTCP reply from bob: DCC SEND",
"irc_notice,irc_ctcp,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE #test :\001DCC SEND file.txt");
CHECK_SRV("--", "CTCP reply from bob: DCC SEND file.txt",
"irc_notice,irc_ctcp,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE #test :\001DCC SEND file.txt 1 2 3");
CHECK_SRV("--", "CTCP reply from bob: DCC SEND file.txt 1 2 3",
"irc_notice,irc_ctcp,nick_bob,host_user@host,log1");
/* broken CTCP to user */
RECV(":bob!user@host NOTICE alice :\001");
CHECK_SRV("--", "CTCP reply from bob: ",
"irc_notice,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE alice :\001TEST");
CHECK_SRV("--", "CTCP reply from bob: TEST",
"irc_notice,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE alice :\001ACTION");
CHECK_SRV("--", "CTCP reply from bob: ACTION",
"irc_notice,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE alice :\001ACTION is testing");
CHECK_SRV("--", "CTCP reply from bob: ACTION is testing",
"irc_notice,irc_ctcp,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE alice :\001VERSION");
CHECK_SRV("--", "CTCP reply from bob: VERSION",
"irc_notice,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE alice :\001DCC");
CHECK_SRV("--", "CTCP reply from bob: DCC",
"irc_notice,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE alice :\001DCC SEND");
CHECK_SRV("--", "CTCP reply from bob: DCC SEND",
"irc_notice,irc_ctcp,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE alice :\001DCC SEND file.txt");
CHECK_SRV("--", "CTCP reply from bob: DCC SEND file.txt",
"irc_notice,irc_ctcp,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE alice :\001DCC SEND file.txt 1 2 3");
CHECK_SRV("--", "CTCP reply from bob: DCC SEND file.txt 1 2 3",
"irc_notice,irc_ctcp,nick_bob,host_user@host,log1");
/* valid CTCP to channel */
RECV(":bob!user@host NOTICE #test :\001TEST\001");
CHECK_SRV("--", "CTCP reply from bob: TEST",
"irc_notice,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE #test :\001ACTION\001");
CHECK_SRV("--", "CTCP reply from bob: ACTION",
"irc_notice,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE #test :\001ACTION is testing\001");
CHECK_SRV("--", "CTCP reply from bob: ACTION is testing",
"irc_notice,irc_ctcp,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE #test :\001VERSION\001");
CHECK_SRV("--", "CTCP reply from bob: VERSION",
"irc_notice,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE #test :\001DCC SEND file.txt 1 2 3\001");
CHECK_SRV("--", "CTCP reply from bob: DCC SEND file.txt 1 2 3",
"irc_notice,irc_ctcp,nick_bob,host_user@host,log1");
/* valid CTCP to user */
RECV(":bob!user@host NOTICE alice :\001TEST\001");
CHECK_SRV("--", "CTCP reply from bob: TEST",
"irc_notice,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE alice :\001ACTION\001");
CHECK_SRV("--", "CTCP reply from bob: ACTION",
"irc_notice,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE alice :\001ACTION is testing\001");
CHECK_SRV("--", "CTCP reply from bob: ACTION is testing",
"irc_notice,irc_ctcp,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE alice :\001VERSION\001");
CHECK_SRV("--", "CTCP reply from bob: VERSION",
"irc_notice,nick_bob,host_user@host,log1");
RECV(":bob!user@host NOTICE alice :\001DCC SEND file.txt 1 2 3\001");
CHECK_SRV("--", "CTCP reply from bob: DCC SEND file.txt 1 2 3",
"irc_notice,irc_ctcp,nick_bob,host_user@host,log1");
if (echo_message == 1)
hashtable_remove (ptr_server->cap_list, "echo-message");
}
}
/*
* Tests functions:
* irc_protocol_cb_part
*/
TEST(IrcProtocolWithServer, part)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":alice!user@host PART");
CHECK_ERROR_PARAMS("part", 0, 1);
/* missing nick */
RECV("PART #test");
CHECK_ERROR_NICK("part");
STRCMP_EQUAL("#test", ptr_server->channels->name);
CHECK(ptr_server->channels->nicks);
LONGS_EQUAL(0, ptr_server->channels->part);
/* channel not found */
RECV(":alice!user@host PART #xyz");
CHECK_NO_MSG;
STRCMP_EQUAL("#test", ptr_server->channels->name);
CHECK(ptr_server->channels->nicks);
LONGS_EQUAL(0, ptr_server->channels->part);
/* without part message */
RECV(":alice!user@host PART #test");
CHECK_CHAN("<--", "alice (user@host) has left #test",
"irc_part,nick_alice,host_user@host,log4");
STRCMP_EQUAL("#test", ptr_server->channels->name);
POINTERS_EQUAL(NULL, ptr_server->channels->nicks);
LONGS_EQUAL(1, ptr_server->channels->part);
/* without part message (but empty trailing parameter) */
RECV(":alice!user@host JOIN #test");
RECV(":alice!user@host PART #test :");
CHECK_CHAN("<--", "alice (user@host) has left #test",
"irc_part,nick_alice,host_user@host,log4");
STRCMP_EQUAL("#test", ptr_server->channels->name);
POINTERS_EQUAL(NULL, ptr_server->channels->nicks);
LONGS_EQUAL(1, ptr_server->channels->part);
/* with part message */
RECV(":alice!user@host JOIN #test");
RECV(":alice!user@host PART #test :\002part message ");
CHECK_CHAN("<--", "alice (user@host) has left #test (part message )",
"irc_part,nick_alice,host_user@host,log4");
STRCMP_EQUAL("#test", ptr_server->channels->name);
POINTERS_EQUAL(NULL, ptr_server->channels->nicks);
LONGS_EQUAL(1, ptr_server->channels->part);
RECV(":alice!user@host JOIN #test");
CHECK_CHAN("-->", "alice (user@host) has joined #test",
"irc_join,nick_alice,host_user@host,log4");
RECV(":bob!user@host JOIN #test");
CHECK_CHAN("-->", "bob (user@host) has joined #test",
"irc_join,irc_smart_filter,nick_bob,host_user@host,log4");
/* part from another user */
RECV(":bob!user@host PART #test :part message ");
CHECK_CHAN("<--", "bob (user@host) has left #test (part message )",
"irc_part,irc_smart_filter,nick_bob,host_user@host,log4");
STRCMP_EQUAL("#test", ptr_server->channels->name);
CHECK(ptr_server->channels->nicks == ptr_server->channels->last_nick);
LONGS_EQUAL(0, ptr_server->channels->part);
}
/*
* Tests functions:
* irc_protocol_cb_ping
*/
TEST(IrcProtocolWithServer, ping)
{
SRV_INIT;
/* not enough parameters, no response */
RECV("PING");
CHECK_ERROR_PARAMS("ping", 0, 1);
CHECK_SENT(NULL);
RECV("PING :\002123456789 ");
CHECK_NO_MSG;
CHECK_SENT("PONG :\002123456789 ");
}
/*
* Tests functions:
* irc_protocol_cb_pong
*/
TEST(IrcProtocolWithServer, pong)
{
SRV_INIT;
RECV(":server PONG");
CHECK_SRV("", "PONG", "irc_pong,nick_server,log3");
RECV(":server PONG server");
CHECK_SRV("", "PONG", "irc_pong,nick_server,log3");
RECV(":server PONG server : \002info ");
CHECK_SRV("", "PONG: info ", "irc_pong,nick_server,log3");
RECV(":server PONG server :extra info");
CHECK_SRV("", "PONG: extra info", "irc_pong,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_privmsg
*/
TEST(IrcProtocolWithServer, privmsg)
{
char *info, message[1024];
int echo_message;
SRV_INIT_JOIN2;
/* test without and with capability "echo-message" */
for (echo_message = 0; echo_message < 2; echo_message++)
{
if (echo_message == 1)
{
/* assume "echo-message" capability is enabled in server */
hashtable_set (ptr_server->cap_list, "echo-message", NULL);
}
/* not enough parameters */
RECV(":bob!user@host PRIVMSG");
CHECK_ERROR_PARAMS("privmsg", 0, 2);
RECV(":bob!user@host PRIVMSG #test");
CHECK_ERROR_PARAMS("privmsg", 1, 2);
RECV(":bob!user@host PRIVMSG alice");
CHECK_ERROR_PARAMS("privmsg", 1, 2);
/* missing nick */
RECV("PRIVMSG #test :this is the message");
CHECK_ERROR_NICK("privmsg");
/* message to channel/user */
RECV(":bob!user@host PRIVMSG #test :\002this is the message ");
CHECK_CHAN_DATE_NOW("bob", "this is the message ",
"irc_privmsg,notify_message,prefix_nick_248,nick_bob,"
"host_user@host,log1");
RECV(":bob!user@host PRIVMSG alice :this is the message ");
CHECK_PV_CLOSE("bob", "bob", "this is the message ",
"irc_privmsg,notify_private,prefix_nick_248,nick_bob,"
"host_user@host,log1");
/* message with tags to channel/user */
RECV("@tag1=value1;tag2=value2 :bob!user@host PRIVMSG #test "
":\002this is the message ");
CHECK_CHAN_DATE_NOW("bob", "this is the message ",
"irc_privmsg,irc_tag_tag1=value1,irc_tag_tag2=value2,"
"notify_message,prefix_nick_248,nick_bob,host_user@host,log1");
RECV("@tag1=value1;tag2=value2 :bob!user@host PRIVMSG alice "
":this is the message ");
CHECK_PV_CLOSE("bob", "bob", "this is the message ",
"irc_privmsg,irc_tag_tag1=value1,irc_tag_tag2=value2,"
"notify_private,prefix_nick_248,nick_bob,host_user@host,log1");
/* message with tags + time as timestamp to channel/user */
RECV("@tag1=value1;tag2=value2;time=1703500149 :bob!user@host PRIVMSG #test "
":\002this is the message ");
CHECK_CHAN_DATE_VALUE(
"bob",
"this is the message ",
"irc_privmsg,irc_tag_tag1=value1,irc_tag_tag2=value2,"
"irc_tag_time=1703500149,notify_message,prefix_nick_248,nick_bob,"
"host_user@host,log1",
1703500149, 0);
/* message with tags + time as timestamp with milliseconds to channel/user */
RECV("@tag1=value1;tag2=value2;time=1703500149.456 :bob!user@host PRIVMSG #test "
":\002this is the message ");
CHECK_CHAN_DATE_VALUE(
"bob",
"this is the message ",
"irc_privmsg,irc_tag_tag1=value1,irc_tag_tag2=value2,"
"irc_tag_time=1703500149.456,notify_message,prefix_nick_248,nick_bob,"
"host_user@host,log1",
1703500149, 456000);
/* message with tags + time as timestamp with microseconds to channel/user */
RECV("@tag1=value1;tag2=value2;time=1703500149.456789 :bob!user@host PRIVMSG #test "
":\002this is the message ");
CHECK_CHAN_DATE_VALUE(
"bob",
"this is the message ",
"irc_privmsg,irc_tag_tag1=value1,irc_tag_tag2=value2,"
"irc_tag_time=1703500149.456789,notify_message,prefix_nick_248,nick_bob,"
"host_user@host,log1",
1703500149, 456789);
/* message with tags + time as ISO 8601 with microseconds to channel/user */
RECV("@tag1=value1;tag2=value2;time=2023-12-25T10:29:09.456789Z "
":bob!user@host PRIVMSG #test :\002this is the message ");
CHECK_CHAN_DATE_VALUE(
"bob",
"this is the message ",
"irc_privmsg,irc_tag_tag1=value1,irc_tag_tag2=value2,"
"irc_tag_time=2023-12-25T10:29:09.456789Z,notify_message,"
"prefix_nick_248,nick_bob,"
"host_user@host,log1",
1703500149, 456789);
/*
* message to channel/user from self nick
* (case of bouncer or if echo-message capability is enabled)
*/
RECV(":alice!user@host PRIVMSG #test :\002this is the message ");
CHECK_CHAN("alice", "this is the message ",
"irc_privmsg,self_msg,notify_none,no_highlight,"
"prefix_nick_white,nick_alice,host_user@host,log1");
/* message to ops of channel */
RECV(":bob!user@host PRIVMSG @#test :\002this is the message ");
CHECK_CHAN("--", "Msg(bob) -> @#test: this is the message ",
"irc_privmsg,notify_message,nick_bob,host_user@host,log1");
/*
* message to ops of channel from self nick
* (case of bouncer or if echo-message capability is enabled)
*/
RECV(":alice!user@host PRIVMSG @#test :\002this is the message ");
CHECK_CHAN("--", "Msg(alice) -> @#test: this is the message ",
"irc_privmsg,self_msg,notify_none,no_highlight,nick_alice,"
"host_user@host,log1");
/*
* message from self nick in private
* (case of bouncer or if echo-message capability is enabled)
*/
if (echo_message == 0)
{
/* without echo-message */
RECV(":alice!user@host PRIVMSG bob :\002this is the message ");
CHECK_PV_CLOSE("bob", "alice", "this is the message ",
"irc_privmsg,self_msg,notify_none,no_highlight,"
"prefix_nick_white,nick_alice,host_user@host,log1");
}
else
{
/* with echo-message */
RECV(":alice!user@host PRIVMSG bob :\002this is the message ");
CHECK_PV_CLOSE("bob", "alice", "this is the message ",
"irc_privmsg,self_msg,notify_none,no_highlight,"
"prefix_nick_white,nick_alice,host_user@host,log1");
/* with echo-message, option irc.look.open_pv_buffer_echo_msg off */
config_file_option_set (irc_config_look_open_pv_buffer_echo_msg,
"off", 1);
RECV(":alice!user@host PRIVMSG bob :\002this is the message ");
CHECK_SRV("--", "Msg(alice) -> bob: this is the message ",
"irc_privmsg,self_msg,notify_none,no_highlight,"
"nick_alice,host_user@host,log1");
config_file_option_reset (irc_config_look_open_pv_buffer_echo_msg, 1);
}
/*
* message from self nick in private, with password hidden (nickserv)
* (case of bouncer or if echo-message capability is enabled)
*/
if (echo_message == 0)
{
/* without echo-message */
RECV(":alice!user@host PRIVMSG nickserv :identify secret");
CHECK_PV_CLOSE("nickserv", "alice", "identify ******",
"irc_privmsg,self_msg,notify_none,no_highlight,"
"prefix_nick_white,nick_alice,host_user@host,log1");
}
else
{
/* with echo-message */
RECV(":alice!user@host PRIVMSG nickserv :identify secret");
CHECK_PV_CLOSE("nickserv", "alice", "identify ******",
"irc_privmsg,self_msg,notify_none,no_highlight,"
"prefix_nick_white,nick_alice,host_user@host,log1");
/* with echo-message, option irc.look.open_pv_buffer_echo_msg off */
config_file_option_set (irc_config_look_open_pv_buffer_echo_msg,
"off", 1);
RECV(":alice!user@host PRIVMSG nickserv :identify secret");
CHECK_SRV("--", "Msg(alice) -> nickserv: identify ******",
"irc_privmsg,self_msg,notify_none,no_highlight,"
"nick_alice,host_user@host,log1");
config_file_option_reset (irc_config_look_open_pv_buffer_echo_msg, 1);
}
/* broken CTCP to channel */
RECV(":bob!user@host PRIVMSG #test :\001");
CHECK_SENT(NULL);
CHECK_CHAN("--", "Unknown CTCP requested by bob: ",
"irc_privmsg,irc_ctcp,nick_bob,host_user@host,log1");
RECV(":bob!user@host PRIVMSG #test :\001TEST");
CHECK_SENT(NULL);
CHECK_CHAN("--", "Unknown CTCP requested by bob: TEST",
"irc_privmsg,irc_ctcp,nick_bob,host_user@host,log1");
RECV(":bob!user@host PRIVMSG #test :\001ACTION");
CHECK_SENT(NULL);
CHECK_CHAN(" *", "bob",
"irc_privmsg,irc_action,notify_message,nick_bob,"
"host_user@host,log1");
RECV(":bob!user@host PRIVMSG #test :\001ACTION \002is testing");
CHECK_SENT(NULL);
CHECK_CHAN(" *", "bob is testing",
"irc_privmsg,irc_action,notify_message,nick_bob,"
"host_user@host,log1");
info = irc_ctcp_eval_reply (ptr_server,
irc_ctcp_get_reply (ptr_server, "VERSION"));
RECV(":bob!user@host PRIVMSG #test :\001VERSION");
snprintf (message, sizeof (message),
"NOTICE bob :\001VERSION %s\001", info);
CHECK_SENT(message);
CHECK_CHAN("--", "CTCP requested by bob: VERSION",
"irc_privmsg,irc_ctcp,nick_bob,host_user@host,log1");
snprintf (message, sizeof (message),
"CTCP reply to bob: VERSION %s", info);
if (echo_message == 0)
{
/* reply is displayed only if echo-message is NOT enabled */
CHECK_SRV("--", message,
"irc_privmsg,irc_ctcp,irc_ctcp_reply,self_msg,notify_none,"
"no_highlight,nick_alice,log1");
}
snprintf (message, sizeof (message),
"NOTICE bob :\001VERSION %s\001", info);
CHECK_SENT(message);
free (info);
RECV(":bob!user@host PRIVMSG #test :\001DCC");
CHECK_SENT(NULL);
CHECK_NO_MSG;
RECV(":bob!user@host PRIVMSG #test :\001DCC SEND");
CHECK_SENT(NULL);
CHECK_NO_MSG;
RECV(":bob!user@host PRIVMSG #test :\001DCC SEND file.txt");
CHECK_SENT(NULL);
CHECK_SRV("=!=", "irc: cannot parse \"privmsg\" command", "");
RECV(":bob!user@host PRIVMSG #test :\001DCC SEND file.txt 1 2 3");
CHECK_SENT(NULL);
CHECK_CORE("",
"xfer: incoming file from bob (0.0.0.1, irc." IRC_FAKE_SERVER
"), name: file.txt, 3 bytes (protocol: dcc)");
/* broken CTCP to user */
RECV(":bob!user@host PRIVMSG alice :\001");
CHECK_SENT(NULL);
CHECK_SRV("--", "Unknown CTCP requested by bob: ",
"irc_privmsg,irc_ctcp,nick_bob,host_user@host,log1");
RECV(":bob!user@host PRIVMSG alice :\001TEST");
CHECK_SENT(NULL);
CHECK_SRV("--", "Unknown CTCP requested by bob: TEST",
"irc_privmsg,irc_ctcp,nick_bob,host_user@host,log1");
RECV(":bob!user@host PRIVMSG alice :\001ACTION");
CHECK_SENT(NULL);
CHECK_PV_CLOSE("bob", " *", "bob",
"irc_privmsg,irc_action,notify_private,nick_bob,"
"host_user@host,log1");
RECV(":bob!user@host PRIVMSG alice :\001ACTION \002is testing");
CHECK_SENT(NULL);
CHECK_PV_CLOSE("bob", " *", "bob is testing",
"irc_privmsg,irc_action,notify_private,nick_bob,"
"host_user@host,log1");
info = irc_ctcp_eval_reply (ptr_server,
irc_ctcp_get_reply (ptr_server, "VERSION"));
RECV(":bob!user@host PRIVMSG alice :\001VERSION");
snprintf (message, sizeof (message),
"NOTICE bob :\001VERSION %s\001", info);
CHECK_SENT(message);
snprintf (message, sizeof (message),
"CTCP reply to bob: VERSION %s", info);
if (echo_message == 0)
{
/* reply is displayed only if echo-message is NOT enabled */
CHECK_SRV("--", message,
"irc_privmsg,irc_ctcp,irc_ctcp_reply,self_msg,notify_none,"
"no_highlight,nick_alice,log1");
}
free (info);
RECV(":bob!user@host PRIVMSG alice :\001DCC");
CHECK_SENT(NULL);
CHECK_NO_MSG;
RECV(":bob!user@host PRIVMSG alice :\001DCC SEND");
CHECK_SENT(NULL);
CHECK_NO_MSG;
RECV(":bob!user@host PRIVMSG alice :\001DCC SEND file.txt");
CHECK_SENT(NULL);
CHECK_SRV("=!=", "irc: cannot parse \"privmsg\" command", "");
RECV(":bob!user@host PRIVMSG alice :\001DCC SEND file.txt 1 2 3");
CHECK_SENT(NULL);
CHECK_CORE("",
"xfer: incoming file from bob (0.0.0.1, irc." IRC_FAKE_SERVER
"), name: file.txt, 3 bytes (protocol: dcc)");
/* valid CTCP to channel */
RECV("@time=2023-12-25T10:29:09.456789Z "
":bob!user@host PRIVMSG #test :\001TEST\001");
CHECK_SENT(NULL);
RECV("@time=2023-12-25T10:29:09.456789Z "
":bob!user@host PRIVMSG #test :\001ACTION\001");
CHECK_SENT(NULL);
CHECK_CHAN(" *", "bob",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_action,notify_message,nick_bob,host_user@host,log1");
RECV("@time=2023-12-25T10:29:09.456789Z "
":bob!user@host PRIVMSG #test :\001ACTION is testing with \002bold\002\001");
CHECK_SENT(NULL);
CHECK_CHAN(" *", "bob is testing with bold",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_action,notify_message,nick_bob,host_user@host,log1");
RECV("@time=2023-12-25T10:29:09.456789Z "
":bob!user@host PRIVMSG #test :\001PING 1703496549 905284\001");
CHECK_SENT("NOTICE bob :\001PING 1703496549 905284\001");
CHECK_CHAN("--", "CTCP requested by bob: PING 1703496549 905284",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,nick_bob,host_user@host,log1");
if (echo_message == 0)
{
/* reply is displayed only if echo-message is NOT enabled */
CHECK_SRV("--", "CTCP reply to bob: PING 1703496549 905284",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,irc_ctcp_reply,self_msg,notify_none,"
"no_highlight,nick_alice,log1");
}
RECV("@time=2023-12-25T10:29:09.456789Z "
":bob!user@host PRIVMSG #test :\001UNKNOWN\001");
CHECK_SENT(NULL);
CHECK_CHAN("--", "Unknown CTCP requested by bob: UNKNOWN",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,nick_bob,host_user@host,log1");
/* valid CTCP to ops of channel */
RECV("@time=2023-12-25T10:29:09.456789Z "
":bob!user@host PRIVMSG @#test :\001ACTION\001");
CHECK_SENT(NULL);
CHECK_CHAN("--", "Action -> @#test: bob",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_action,notify_message,nick_bob,host_user@host,log1");
RECV("@time=2023-12-25T10:29:09.456789Z "
":bob!user@host PRIVMSG @#test :\001ACTION \002is testing\001");
CHECK_SENT(NULL);
CHECK_CHAN("--", "Action -> @#test: bob is testing",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_action,notify_message,nick_bob,host_user@host,log1");
RECV("@time=2023-12-25T10:29:09.456789Z "
":bob!user@host PRIVMSG @#test :\001PING 1703496549 905284\001");
CHECK_SENT("NOTICE bob :\001PING 1703496549 905284\001");
CHECK_CHAN("--", "CTCP requested by bob: PING 1703496549 905284",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,nick_bob,host_user@host,log1");
if (echo_message == 0)
{
/* reply is displayed only if echo-message is NOT enabled */
CHECK_SRV("--", "CTCP reply to bob: PING 1703496549 905284",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,irc_ctcp_reply,self_msg,notify_none,"
"no_highlight,nick_alice,log1");
}
RECV("@time=2023-12-25T10:29:09.456789Z "
":bob!user@host PRIVMSG @#test :\001UNKNOWN\001");
CHECK_SENT(NULL);
CHECK_CHAN("--", "Unknown CTCP requested by bob: UNKNOWN",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,nick_bob,host_user@host,log1");
/*
* valid CTCP to channel from self nick
* (case of bouncer or if echo-message capability is enabled)
*/
RECV("@time=2023-12-25T10:29:09.456789Z "
":alice!user@host PRIVMSG #test :\001VERSION\001");
CHECK_SENT(NULL);
CHECK_CHAN("--", "CTCP query to #test: VERSION",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,self_msg,notify_none,no_highlight,nick_alice,"
"host_user@host,log1");
RECV("@time=2023-12-25T10:29:09.456789Z "
":alice!user@host PRIVMSG #test :\001ACTION\001");
CHECK_SENT(NULL);
CHECK_CHAN(" *", "alice",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_action,self_msg,notify_none,no_highlight,nick_alice,"
"host_user@host,log1");
RECV("@time=2023-12-25T10:29:09.456789Z "
":alice!user@host PRIVMSG #test :\001ACTION is testing with \002bold\002\001");
CHECK_SENT(NULL);
CHECK_CHAN(" *", "alice is testing with bold",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_action,self_msg,notify_none,no_highlight,nick_alice,"
"host_user@host,log1");
RECV("@time=2023-12-25T10:29:09.456789Z "
":alice!user@host PRIVMSG #test :\001PING 1703496549 905284\001");
CHECK_SENT(NULL);
CHECK_CHAN("--", "CTCP query to #test: PING 1703496549 905284",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,self_msg,notify_none,no_highlight,"
"nick_alice,host_user@host,log1");
RECV("@time=2023-12-25T10:29:09.456789Z "
":alice!user@host PRIVMSG #test :\001UNKNOWN\001");
CHECK_SENT(NULL);
CHECK_CHAN("--", "CTCP query to #test: UNKNOWN",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,self_msg,notify_none,no_highlight,"
"nick_alice,host_user@host,log1");
/*
* valid CTCP to ops of channel from self nick
* (case of bouncer or if echo-message capability is enabled)
*/
RECV("@time=2023-12-25T10:29:09.456789Z "
":alice!user@host PRIVMSG @#test :\001ACTION\001");
CHECK_SENT(NULL);
CHECK_CHAN("--", "Action -> @#test: alice",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_action,self_msg,notify_none,no_highlight,nick_alice,"
"host_user@host,log1");
RECV("@time=2023-12-25T10:29:09.456789Z "
":alice!user@host PRIVMSG @#test :\001ACTION \002is testing\001");
CHECK_SENT(NULL);
CHECK_CHAN("--", "Action -> @#test: alice is testing",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_action,self_msg,notify_none,no_highlight,nick_alice,"
"host_user@host,log1");
RECV("@time=2023-12-25T10:29:09.456789Z "
":alice!user@host PRIVMSG @#test :\001PING 1703496549 905284\001");
CHECK_SENT(NULL);
CHECK_CHAN("--", "CTCP query to @#test: PING 1703496549 905284",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,self_msg,notify_none,no_highlight,"
"nick_alice,host_user@host,log1");
RECV("@time=2023-12-25T10:29:09.456789Z "
":alice!user@host PRIVMSG @#test :\001UNKNOWN\001");
CHECK_SENT(NULL);
CHECK_CHAN("--", "CTCP query to @#test: UNKNOWN",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,self_msg,notify_none,no_highlight,"
"nick_alice,host_user@host,log1");
/* valid CTCP to user */
RECV("@time=2023-12-25T10:29:09.456789Z "
":bob!user@host PRIVMSG alice :\001TEST\001");
CHECK_SENT(NULL);
RECV("@time=2023-12-25T10:29:09.456789Z "
":bob!user@host PRIVMSG alice :\001ACTION\001");
CHECK_SENT(NULL);
RECV("@time=2023-12-25T10:29:09.456789Z "
":bob!user@host PRIVMSG alice :\001ACTION \002is testing\001");
CHECK_SENT(NULL);
RECV("@time=2023-12-25T10:29:09.456789Z "
":bob!user@host PRIVMSG alice :\001PING 1703496549 905284\001");
CHECK_SENT("NOTICE bob :\001PING 1703496549 905284\001");
CHECK_SRV("--", "CTCP requested by bob: PING 1703496549 905284",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,nick_bob,host_user@host,log1");
if (echo_message == 0)
{
/* reply is displayed only if echo-message is NOT enabled */
CHECK_SRV("--", "CTCP reply to bob: PING 1703496549 905284",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,irc_ctcp_reply,self_msg,notify_none,"
"no_highlight,nick_alice,log1");
}
RECV("@time=2023-12-25T10:29:09.456789Z "
":bob!user@host PRIVMSG alice :\001UNKNOWN\001");
CHECK_SENT(NULL);
CHECK_SRV("--", "Unknown CTCP requested by bob: UNKNOWN",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,nick_bob,host_user@host,log1");
info = irc_ctcp_eval_reply (ptr_server,
irc_ctcp_get_reply (ptr_server, "VERSION"));
RECV("@time=2023-12-25T10:29:09.456789Z "
":bob!user@host PRIVMSG alice :\001VERSION\001");
snprintf (message, sizeof (message),
"NOTICE bob :\001VERSION %s\001", info);
CHECK_SENT(message);
CHECK_SRV("--", "CTCP requested by bob: VERSION",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,nick_bob,host_user@host,log1");
snprintf (message, sizeof (message),
"CTCP reply to bob: VERSION %s", info);
if (echo_message == 0)
{
/* reply is displayed only if echo-message is NOT enabled */
CHECK_SRV("--", message,
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,irc_ctcp_reply,self_msg,notify_none,no_highlight,"
"nick_alice,log1");
}
snprintf (message, sizeof (message),
"NOTICE bob :\001VERSION %s\001", info);
CHECK_SENT(message);
free (info);
info = hook_info_get (NULL, "weechat_site_download", "");
RECV("@time=2023-12-25T10:29:09.456789Z "
":bob!user@host PRIVMSG alice :\001SOURCE\001");
snprintf (message, sizeof (message),
"NOTICE bob :\001SOURCE %s\001", info);
CHECK_SENT(message);
free (info);
RECV("@time=2023-12-25T10:29:09.456789Z "
":bob!user@host PRIVMSG alice :\001DCC SEND file.txt 1 2 3\001");
CHECK_SENT(NULL);
CHECK_CORE("",
"xfer: incoming file from bob (0.0.0.1, irc." IRC_FAKE_SERVER
"), name: file.txt, 3 bytes (protocol: dcc)");
CHECK_SENT(NULL);
/*
* valid CTCP to user from self nick
* (case of bouncer or if echo-message capability is enabled)
*/
RECV("@time=2023-12-25T10:29:09.456789Z "
":alice!user@host PRIVMSG alice :\001CLIENTINFO\001");
if (echo_message == 0)
{
CHECK_SENT("NOTICE alice :\001CLIENTINFO ACTION CLIENTINFO DCC "
"PING SOURCE TIME VERSION\001");
CHECK_SRV("--", "CTCP requested by alice: CLIENTINFO",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,nick_alice,host_user@host,log1");
CHECK_SRV("--", "CTCP reply to alice: CLIENTINFO ACTION CLIENTINFO "
"DCC PING SOURCE TIME VERSION",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,irc_ctcp_reply,self_msg,notify_none,"
"no_highlight,nick_alice,host_user@host,log1");
}
else
{
CHECK_SENT(NULL);
CHECK_SRV("--", "CTCP query to alice: CLIENTINFO",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,self_msg,notify_none,no_highlight,nick_alice,"
"host_user@host,log1");
RECV("@time=2023-12-25T10:29:09.456789Z "
":alice!user@host PRIVMSG alice :\001CLIENTINFO\001");
CHECK_SENT("NOTICE alice :\001CLIENTINFO ACTION CLIENTINFO DCC "
"PING SOURCE TIME VERSION\001");
CHECK_SRV("--", "CTCP requested by alice: CLIENTINFO",
"irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,nick_alice,host_user@host,log1");
RECV("@time=2023-12-25T10:29:09.456789Z "
":alice!user@host NOTICE alice :\001CLIENTINFO DCC PING "
"SOURCE TIME VERSION\001");
CHECK_SENT(NULL);
CHECK_SRV("--", "CTCP reply to alice: CLIENTINFO DCC PING "
"SOURCE TIME VERSION",
"irc_notice,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,irc_ctcp_reply,self_msg,notify_none,"
"no_highlight,nick_alice,host_user@host,log1");
RECV("@time=2023-12-25T10:29:09.456789Z "
":alice!user@host NOTICE alice :\001CLIENTINFO DCC PING "
"SOURCE TIME VERSION\001");
CHECK_SENT(NULL);
CHECK_SRV("--", "CTCP reply from alice: CLIENTINFO DCC PING "
"SOURCE TIME VERSION",
"irc_notice,irc_tag_time=2023-12-25T10:29:09.456789Z,"
"irc_ctcp,nick_alice,host_user@host,log1");
}
/* close xfer buffer */
if (xfer_buffer)
gui_buffer_close (xfer_buffer);
if (echo_message == 1)
hashtable_remove (ptr_server->cap_list, "echo-message");
}
}
/*
* Tests functions:
* irc_protocol_cb_quit
*/
TEST(IrcProtocolWithServer, quit)
{
struct t_irc_channel *ptr_channel;
SRV_INIT_JOIN;
/* missing nick */
RECV("QUIT");
CHECK_ERROR_NICK("quit");
RECV(":bob!user@host PRIVMSG alice :hi Alice!");
CHECK_PV("bob", "bob", "hi Alice!",
"irc_privmsg,notify_private,prefix_nick_248,nick_bob,"
"host_user@host,log1");
ptr_channel = ptr_server->channels;
/* without quit message */
RECV(":bob!user@host JOIN #test");
RECV(":bob!user@host QUIT");
CHECK_CHAN("<--", "bob (user@host) has quit",
"irc_quit,irc_smart_filter,nick_bob,host_user@host,log4");
LONGS_EQUAL(1, ptr_channel->nicks_count);
STRCMP_EQUAL("alice", ptr_channel->nicks->name);
POINTERS_EQUAL(NULL, ptr_channel->nicks->next_nick);
/* without quit message (but empty trailing parameter) */
RECV(":bob!user@host JOIN #test");
RECV(":bob!user@host QUIT :");
CHECK_CHAN("<--", "bob (user@host) has quit",
"irc_quit,irc_smart_filter,nick_bob,host_user@host,log4");
LONGS_EQUAL(1, ptr_channel->nicks_count);
STRCMP_EQUAL("alice", ptr_channel->nicks->name);
POINTERS_EQUAL(NULL, ptr_channel->nicks->next_nick);
/* with quit message */
RECV(":bob!user@host JOIN #test");
RECV(":bob!user@host QUIT :\002quit message ");
CHECK_CHAN("<--", "bob (user@host) has quit (quit message )",
"irc_quit,irc_smart_filter,nick_bob,host_user@host,log4");
LONGS_EQUAL(1, ptr_channel->nicks_count);
STRCMP_EQUAL("alice", ptr_channel->nicks->name);
POINTERS_EQUAL(NULL, ptr_channel->nicks->next_nick);
/* with quit message */
RECV(":bob!user_\00304red@host_\00304red JOIN #test");
RECV(":bob!user_\00304red@host_\00304red QUIT :\002quit message ");
CHECK_CHAN("<--", "bob (user_red@host_red) has quit (quit message )",
"irc_quit,irc_smart_filter,nick_bob,host_user_\00304red@host_\00304red,log4");
LONGS_EQUAL(1, ptr_channel->nicks_count);
STRCMP_EQUAL("alice", ptr_channel->nicks->name);
POINTERS_EQUAL(NULL, ptr_channel->nicks->next_nick);
RECV(":bob!user_\00304red@host_\00304red JOIN #test");
CHECK_PV("bob", "-->", "bob (user_red@host_red) is back on server",
"irc_nick_back,nick_bob,host_user_\00304red@host_\00304red,log4");
RECV(":bob!user_\00304red@host_\00304red QUIT :\002quit message ");
/* quit with option irc.look.display_host_quit set to off */
config_file_option_set (irc_config_look_display_host_quit, "off", 1);
RECV(":bob!user@host JOIN #test");
RECV(":bob!user@host QUIT :\002quit message ");
CHECK_CHAN("<--", "bob has quit (quit message )",
"irc_quit,irc_smart_filter,nick_bob,host_user@host,log4");
config_file_option_reset (irc_config_look_display_host_quit, 1);
}
/*
* Tests functions:
* irc_protocol_cb_setname (without setname capability)
*/
TEST(IrcProtocolWithServer, setname_without_setname_cap)
{
struct t_irc_nick *ptr_nick;
SRV_INIT_JOIN2;
ptr_nick = ptr_server->channels->nicks;
STRCMP_EQUAL(NULL, ptr_nick->realname);
/* not enough parameters */
RECV(":alice!user@host SETNAME");
CHECK_ERROR_PARAMS("setname", 0, 1);
/* missing nick */
RECV("SETNAME :new bob realname");
CHECK_ERROR_NICK("setname");
STRCMP_EQUAL(NULL, ptr_nick->realname);
/* real name of "bob" has changed */
RECV(":bob!user@host SETNAME :\002new bob realname ");
CHECK_CHAN("--", "bob has changed real name to \"new bob realname \"",
"irc_setname,irc_smart_filter,nick_bob,host_user@host,log3");
STRCMP_EQUAL(NULL, ptr_nick->realname);
/* self real name has changed */
RECV(":alice!user@host SETNAME :\002new alice realname ");
CHECK_SRV("--", "Your real name has been set to \"new alice realname \"",
"irc_setname,nick_alice,host_user@host,log3");
STRCMP_EQUAL(NULL, ptr_nick->realname);
}
/*
* Tests functions:
* irc_protocol_cb_setname (with setname capability)
*/
TEST(IrcProtocolWithServer, setname_with_setname_cap)
{
struct t_irc_nick *ptr_nick, *ptr_nick2;
/* assume "setname" capability is enabled in server */
hashtable_set (ptr_server->cap_list, "setname", NULL);
SRV_INIT_JOIN2;
ptr_nick = ptr_server->channels->nicks;
ptr_nick2 = ptr_server->channels->last_nick;
STRCMP_EQUAL(NULL, ptr_nick->realname);
/* real name of "bob" has changed */
RECV(":bob!user@host SETNAME :\002new bob realname ");
CHECK_CHAN("--", "bob has changed real name to \"new bob realname \"",
"irc_setname,irc_smart_filter,nick_bob,host_user@host,log3");
STRCMP_EQUAL("\002new bob realname ", ptr_nick2->realname);
/* self real name has changed */
RECV(":alice!user@host SETNAME :new realname");
CHECK_SRV("--", "Your real name has been set to \"new realname\"",
"irc_setname,nick_alice,host_user@host,log3");
STRCMP_EQUAL("new realname", ptr_nick->realname);
/* self real name has changed */
RECV(":alice!user@host SETNAME :new realname2");
CHECK_SRV("--", "Your real name has been set to \"new realname2\"",
"irc_setname,nick_alice,host_user@host,log3");
STRCMP_EQUAL("new realname2", ptr_nick->realname);
hashtable_remove (ptr_server->cap_list, "setname");
}
/*
* Tests functions:
* irc_protocol_cb_tagmsg
*/
TEST(IrcProtocolWithServer, tagmsg)
{
struct t_gui_buffer *ptr_buffer;
struct t_typing_status *ptr_typing_status;
SRV_INIT_JOIN2;
/* not enough parameters */
RECV(":bob!user@host TAGMSG");
CHECK_ERROR_PARAMS("tagmsg", 0, 1);
/* no tags */
RECV(":bob!user@host TAGMSG #test");
CHECK_NO_MSG;
RECV(":bob!user@host TAGMSG :#test");
CHECK_NO_MSG;
/* with tags */
RECV("@tag1=123;tag2=456 :bob!user@host TAGMSG #test ");
CHECK_NO_MSG;
RECV("@tag1=123;tag2=456 :bob!user@host TAGMSG :#test ");
CHECK_NO_MSG;
/* check typing status */
ptr_buffer = ptr_server->channels->buffer;
config_file_option_set (irc_config_look_typing_status_nicks, "on", 1);
config_file_option_set (typing_config_look_enabled_nicks, "on", 1);
POINTERS_EQUAL(NULL, typing_status_nick_search (ptr_buffer, "bob"));
RECV("@+typing=active :bob!user@host TAGMSG #test ");
ptr_typing_status = typing_status_nick_search (ptr_buffer, "bob");
CHECK(ptr_typing_status);
LONGS_EQUAL(TYPING_STATUS_STATE_TYPING, ptr_typing_status->state);
RECV("@+typing=paused :bob!user@host TAGMSG : #test ");
ptr_typing_status = typing_status_nick_search (ptr_buffer, "bob");
CHECK(ptr_typing_status);
LONGS_EQUAL(TYPING_STATUS_STATE_PAUSED, ptr_typing_status->state);
RECV("@+typing=done :bob!user@host TAGMSG #test ");
POINTERS_EQUAL(NULL, typing_status_nick_search (ptr_buffer, "bob"));
config_file_option_reset (typing_config_look_enabled_nicks, 1);
config_file_option_reset (irc_config_look_typing_status_nicks, 1);
}
/*
* Tests functions:
* irc_protocol_cb_topic
*/
TEST(IrcProtocolWithServer, topic)
{
struct t_irc_channel *ptr_channel;
SRV_INIT_JOIN;
ptr_channel = ptr_server->channels;
STRCMP_EQUAL(NULL, ptr_channel->topic);
/* not enough parameters */
RECV(":alice!user@host TOPIC");
CHECK_ERROR_PARAMS("topic", 0, 1);
/* missing nick */
RECV("TOPIC #test :new topic");
CHECK_ERROR_NICK("topic");
STRCMP_EQUAL(NULL, ptr_channel->topic);
/* not a channel */
RECV(":alice!user@host TOPIC bob");
CHECK_SRV("=!=", "irc: \"topic\" command received without channel", "");
/* empty topic */
RECV(":alice!user@host TOPIC #test");
CHECK_CHAN("--", "alice has unset topic for #test",
"irc_topic,nick_alice,host_user@host,log3");
STRCMP_EQUAL(NULL, ptr_channel->topic);
/* empty topic (with empty trailing parameter) */
RECV(":alice!user@host TOPIC #test :");
CHECK_CHAN("--", "alice has unset topic for #test",
"irc_topic,nick_alice,host_user@host,log3");
STRCMP_EQUAL(NULL, ptr_channel->topic);
/* new topic */
RECV(":alice!user@host TOPIC #test :\002new topic ");
CHECK_CHAN("--", "alice has changed topic for #test to \"new topic \"",
"irc_topic,nick_alice,host_user@host,log3");
STRCMP_EQUAL("\002new topic ", ptr_channel->topic);
/* another new topic */
RECV(":alice!user_\00304red@host_\00304red TOPIC #test :\00304another new topic ");
CHECK_CHAN("--",
"alice has changed topic for #test from "
"\"new topic \" to \"another new topic \"",
"irc_topic,nick_alice,host_user_\00304red@host_\00304red,log3");
STRCMP_EQUAL("\00304another new topic ", ptr_channel->topic);
/* empty topic */
RECV(":alice!user@host TOPIC #test");
CHECK_CHAN("--",
"alice has unset topic for #test (old topic: "
"\"another new topic \")",
"irc_topic,nick_alice,host_user@host,log3");
STRCMP_EQUAL(NULL, ptr_channel->topic);
}
/*
* Tests functions:
* irc_protocol_cb_wallops
*/
TEST(IrcProtocolWithServer, wallops)
{
SRV_INIT;
/* not enough parameters */
RECV(":alice!user@host WALLOPS");
CHECK_ERROR_PARAMS("wallops", 0, 1);
RECV(":alice!user@host WALLOPS message ");
CHECK_SRV("--", "Wallops from alice (user@host): message",
"irc_wallops,notify_private,nick_alice,host_user@host,log3");
RECV(":alice!user@host WALLOPS :\002message from admin ");
CHECK_SRV("--", "Wallops from alice (user@host): message from admin ",
"irc_wallops,notify_private,nick_alice,host_user@host,log3");
/* wallops with option irc.look.display_host_wallops set to off */
config_file_option_set (irc_config_look_display_host_wallops, "off", 1);
RECV(":alice!user@host WALLOPS :message from admin ");
CHECK_SRV("--", "Wallops from alice: message from admin ",
"irc_wallops,notify_private,nick_alice,host_user@host,log3");
config_file_option_reset (irc_config_look_display_host_wallops, 1);
}
/*
* Tests functions:
* irc_protocol_cb_warn
*/
TEST(IrcProtocolWithServer, warn)
{
SRV_INIT;
/* not enough parameters */
RECV(":server WARN");
CHECK_ERROR_PARAMS("warn", 0, 2);
RECV(":server WARN *");
CHECK_ERROR_PARAMS("warn", 1, 2);
RECV(":server WARN COMMAND");
CHECK_ERROR_PARAMS("warn", 1, 2);
RECV(":server WARN * TEST");
CHECK_SRV("=!=", "Warning: [] TEST", "irc_warn,nick_server,log3");
RECV(":server WARN * TEST : \002the message ");
CHECK_SRV("=!=", "Warning: [TEST] the message ", "irc_warn,nick_server,log3");
RECV(":server WARN * TEST TEST2");
CHECK_SRV("=!=", "Warning: [TEST] TEST2", "irc_warn,nick_server,log3");
RECV(":server WARN * TEST TEST2 :the message");
CHECK_SRV("=!=", "Warning: [TEST TEST2] the message", "irc_warn,nick_server,log3");
RECV(":server WARN COMMAND TEST");
CHECK_SRV("=!=", "Warning: COMMAND [] TEST", "irc_warn,nick_server,log3");
RECV(":server WARN COMMAND TEST :the message");
CHECK_SRV("=!=", "Warning: COMMAND [TEST] the message", "irc_warn,nick_server,log3");
RECV(":server WARN COMMAND TEST TEST2");
CHECK_SRV("=!=", "Warning: COMMAND [TEST] TEST2", "irc_warn,nick_server,log3");
RECV(":server WARN COMMAND TEST TEST2 :the message");
CHECK_SRV("=!=", "Warning: COMMAND [TEST TEST2] the message",
"irc_warn,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_001 (connected to IRC server, empty)
*/
TEST(IrcProtocolWithServer, 001_empty)
{
LONGS_EQUAL(0, ptr_server->is_connected);
STRCMP_EQUAL("nick1", ptr_server->nick);
/* not enough parameters */
RECV(":server 001");
CHECK_ERROR_PARAMS("001", 0, 1);
RECV(":server 001 alice");
CHECK_SRV("--", "", "irc_001,irc_numeric,nick_server,log3");
LONGS_EQUAL(1, ptr_server->is_connected);
STRCMP_EQUAL("alice", ptr_server->nick);
}
/*
* Tests functions:
* irc_protocol_cb_001 (connected to IRC server, welcome message)
*/
TEST(IrcProtocolWithServer, 001_welcome)
{
run_cmd_quiet ("/mute /set irc.server." IRC_FAKE_SERVER ".autojoin \"#autojoin1\"");
run_cmd_quiet ("/mute /set irc.server." IRC_FAKE_SERVER ".command "
"\"/join #test1;/join #test2;/query remote_nick\"");
LONGS_EQUAL(0, ptr_server->is_connected);
STRCMP_EQUAL("nick1", ptr_server->nick);
RECV(":server 001 alice : Welcome on this server, alice! ");
CHECK_SRV("--", " Welcome on this server, alice! ",
"irc_001,irc_numeric,nick_server,log3");
LONGS_EQUAL(1, ptr_server->is_connected);
STRCMP_EQUAL("alice", ptr_server->nick);
CHECK(ptr_server->channels);
STRCMP_EQUAL("remote_nick", ptr_server->channels->name);
}
/*
* Tests functions:
* irc_protocol_cb_005 (infos from server, empty)
*/
TEST(IrcProtocolWithServer, 005_empty)
{
SRV_INIT;
STRCMP_EQUAL(NULL, ptr_server->prefix_modes);
STRCMP_EQUAL(NULL, ptr_server->prefix_chars);
RECV(":server 005 alice TEST=A");
CHECK_SRV("--", "TEST=A", "irc_005,irc_numeric,nick_server,log3");
STRCMP_EQUAL(NULL, ptr_server->prefix_modes);
STRCMP_EQUAL(NULL, ptr_server->prefix_chars);
}
/*
* Tests functions:
* irc_protocol_cb_005 (infos from server, full)
*/
TEST(IrcProtocolWithServer, 005_full)
{
SRV_INIT;
STRCMP_EQUAL(NULL, ptr_server->prefix_modes);
STRCMP_EQUAL(NULL, ptr_server->prefix_chars);
LONGS_EQUAL(0, ptr_server->msg_max_length);
LONGS_EQUAL(0, ptr_server->nick_max_length);
LONGS_EQUAL(0, ptr_server->user_max_length);
LONGS_EQUAL(0, ptr_server->host_max_length);
LONGS_EQUAL(0, ptr_server->casemapping);
STRCMP_EQUAL(NULL, ptr_server->chantypes);
STRCMP_EQUAL(NULL, ptr_server->chanmodes);
LONGS_EQUAL(0, ptr_server->monitor);
LONGS_EQUAL(IRC_SERVER_UTF8MAPPING_NONE, ptr_server->utf8mapping);
LONGS_EQUAL(0, ptr_server->utf8only);
STRCMP_EQUAL(NULL, ptr_server->isupport);
RECV(":server 005 alice " IRC_MSG_005 " : are supported ");
CHECK_SRV("--", IRC_MSG_005 " are supported ",
"irc_005,irc_numeric,nick_server,log3");
STRCMP_EQUAL("ohv", ptr_server->prefix_modes);
STRCMP_EQUAL("@%+", ptr_server->prefix_chars);
LONGS_EQUAL(4096, ptr_server->msg_max_length);
LONGS_EQUAL(30, ptr_server->nick_max_length);
LONGS_EQUAL(16, ptr_server->user_max_length);
LONGS_EQUAL(32, ptr_server->host_max_length);
LONGS_EQUAL(1, ptr_server->casemapping);
STRCMP_EQUAL("#", ptr_server->chantypes);
STRCMP_EQUAL("eIbq,k,flj,CFLMPQScgimnprstuz", ptr_server->chanmodes);
LONGS_EQUAL(100, ptr_server->monitor);
LONGS_EQUAL(IRC_SERVER_UTF8MAPPING_RFC8265, ptr_server->utf8mapping);
LONGS_EQUAL(1, ptr_server->utf8only);
STRCMP_EQUAL(IRC_MSG_005, ptr_server->isupport);
/* check that realloc of info is OK if we receive the message again */
RECV(":server 005 alice " IRC_MSG_005 " :are supported");
CHECK_SRV("--", IRC_MSG_005 " are supported",
"irc_005,irc_numeric,nick_server,log3");
STRCMP_EQUAL("ohv", ptr_server->prefix_modes);
STRCMP_EQUAL("@%+", ptr_server->prefix_chars);
LONGS_EQUAL(4096, ptr_server->msg_max_length);
LONGS_EQUAL(30, ptr_server->nick_max_length);
LONGS_EQUAL(16, ptr_server->user_max_length);
LONGS_EQUAL(32, ptr_server->host_max_length);
LONGS_EQUAL(1, ptr_server->casemapping);
STRCMP_EQUAL("#", ptr_server->chantypes);
STRCMP_EQUAL("eIbq,k,flj,CFLMPQScgimnprstuz", ptr_server->chanmodes);
LONGS_EQUAL(100, ptr_server->monitor);
LONGS_EQUAL(IRC_SERVER_UTF8MAPPING_RFC8265, ptr_server->utf8mapping);
LONGS_EQUAL(1, ptr_server->utf8only);
STRCMP_EQUAL(IRC_MSG_005 " " IRC_MSG_005, ptr_server->isupport);
}
/*
* Tests functions:
* irc_protocol_cb_005 (infos from server, multiple messages)
*/
TEST(IrcProtocolWithServer, 005_multiple_messages)
{
SRV_INIT;
STRCMP_EQUAL(NULL, ptr_server->prefix_modes);
STRCMP_EQUAL(NULL, ptr_server->prefix_chars);
LONGS_EQUAL(0, ptr_server->host_max_length);
STRCMP_EQUAL(NULL, ptr_server->isupport);
RECV(":server 005 alice PREFIX=(ohv)@%+ :are supported");
CHECK_SRV("--", "PREFIX=(ohv)@%+ are supported",
"irc_005,irc_numeric,nick_server,log3");
STRCMP_EQUAL("ohv", ptr_server->prefix_modes);
STRCMP_EQUAL("@%+", ptr_server->prefix_chars);
STRCMP_EQUAL("PREFIX=(ohv)@%+", ptr_server->isupport);
RECV(":server 005 alice HOSTLEN=24 :are supported");
CHECK_SRV("--", "HOSTLEN=24 are supported",
"irc_005,irc_numeric,nick_server,log3");
LONGS_EQUAL(24, ptr_server->host_max_length);
STRCMP_EQUAL("PREFIX=(ohv)@%+ HOSTLEN=24", ptr_server->isupport);
}
/*
* Tests functions:
* irc_protocol_cb_008 (server notice mask)
*/
TEST(IrcProtocolWithServer, 008)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 008");
CHECK_ERROR_PARAMS("008", 0, 2);
RECV(":server 008 alice");
CHECK_ERROR_PARAMS("008", 1, 2);
RECV(":server 008 alice +Zbfkrsuy : \002Server notice mask ");
CHECK_SRV("--",
"Server notice mask for alice: +Zbfkrsuy Server notice mask ",
"irc_008,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_221 (user mode string)
*/
TEST(IrcProtocolWithServer, 221)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 221");
CHECK_ERROR_PARAMS("221", 0, 2);
RECV(":server 221 alice");
CHECK_ERROR_PARAMS("221", 1, 2);
STRCMP_EQUAL(NULL, ptr_server->nick_modes);
RECV(":server 221 alice : +abc ");
CHECK_SRV("--", "User mode for alice is [ +abc ]",
"irc_221,irc_numeric,nick_server,log3");
STRCMP_EQUAL("abc", ptr_server->nick_modes);
RECV(":server 221 alice :-abc");
CHECK_SRV("--", "User mode for alice is [-abc]",
"irc_221,irc_numeric,nick_server,log3");
STRCMP_EQUAL(NULL, ptr_server->nick_modes);
}
/*
* Tests functions:
* irc_protocol_cb_whois_nick_msg
*
* Messages:
* 223: whois (charset is)
* 264: whois (is using encrypted connection)
* 275: whois (secure connection)
* 276: whois (has client certificate fingerprint)
* 307: whois (registered nick)
* 310: whois (help mode)
* 313: whois (operator)
* 318: whois (end)
* 319: whois (channels)
* 320: whois (identified user)
* 326: whois (has oper privs)
* 335: whois (is a bot on)
* 337: whois ((is hiding idle time)
* 378: whois (connecting from)
* 379: whois (using modes)
* 671: whois (secure connection)
*/
TEST(IrcProtocolWithServer, whois_nick_msg)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 223");
CHECK_ERROR_PARAMS("223", 0, 2);
RECV(":server 223 alice");
CHECK_ERROR_PARAMS("223", 1, 2);
RECV(":server 264");
CHECK_ERROR_PARAMS("264", 0, 2);
RECV(":server 264 alice");
CHECK_ERROR_PARAMS("264", 1, 2);
RECV(":server 275");
CHECK_ERROR_PARAMS("275", 0, 2);
RECV(":server 275 alice");
CHECK_ERROR_PARAMS("275", 1, 2);
RECV(":server 276");
CHECK_ERROR_PARAMS("276", 0, 2);
RECV(":server 276 alice");
CHECK_ERROR_PARAMS("276", 1, 2);
RECV(":server 307");
CHECK_ERROR_PARAMS("307", 0, 2);
RECV(":server 307 alice");
CHECK_ERROR_PARAMS("307", 1, 2);
RECV(":server 310");
CHECK_ERROR_PARAMS("310", 0, 2);
RECV(":server 310 alice");
CHECK_ERROR_PARAMS("310", 1, 2);
RECV(":server 313");
CHECK_ERROR_PARAMS("313", 0, 2);
RECV(":server 313 alice");
CHECK_ERROR_PARAMS("313", 1, 2);
RECV(":server 318");
CHECK_ERROR_PARAMS("318", 0, 2);
RECV(":server 318 alice");
CHECK_ERROR_PARAMS("318", 1, 2);
RECV(":server 319");
CHECK_ERROR_PARAMS("319", 0, 2);
RECV(":server 319 alice");
CHECK_ERROR_PARAMS("319", 1, 2);
RECV(":server 320");
CHECK_ERROR_PARAMS("320", 0, 2);
RECV(":server 320 alice");
CHECK_ERROR_PARAMS("320", 1, 2);
RECV(":server 326");
CHECK_ERROR_PARAMS("326", 0, 2);
RECV(":server 326 alice");
CHECK_ERROR_PARAMS("326", 1, 2);
RECV(":server 335");
CHECK_ERROR_PARAMS("335", 0, 2);
RECV(":server 335 alice");
CHECK_ERROR_PARAMS("335", 1, 2);
RECV(":server 337");
CHECK_ERROR_PARAMS("337", 0, 2);
RECV(":server 337 alice");
CHECK_ERROR_PARAMS("337", 1, 2);
RECV(":server 378");
CHECK_ERROR_PARAMS("378", 0, 2);
RECV(":server 378 alice");
CHECK_ERROR_PARAMS("378", 1, 2);
RECV(":server 379");
CHECK_ERROR_PARAMS("379", 0, 2);
RECV(":server 379 alice");
CHECK_ERROR_PARAMS("379", 1, 2);
RECV(":server 671");
CHECK_ERROR_PARAMS("671", 0, 2);
RECV(":server 671 alice");
CHECK_ERROR_PARAMS("671", 1, 2);
RECV(":server 223 alice bob UTF-8");
CHECK_SRV("--", "[bob] UTF-8", "irc_223,irc_numeric,nick_server,log3");
RECV(":server 223 alice bob :UTF-8");
CHECK_SRV("--", "[bob] UTF-8", "irc_223,irc_numeric,nick_server,log3");
RECV(":server 223 alice bob : UTF-8 ");
CHECK_SRV("--", "[bob] UTF-8 ", "irc_223,irc_numeric,nick_server,log3");
RECV(":server 223 alice bob");
CHECK_SRV("--", "bob", "irc_223,irc_numeric,nick_server,log3");
RECV(":server 264 alice bob : \002is using encrypted connection ");
CHECK_SRV("--", "[bob] is using encrypted connection ",
"irc_264,irc_numeric,nick_server,log3");
RECV(":server 264 alice bob");
CHECK_SRV("--", "bob", "irc_264,irc_numeric,nick_server,log3");
RECV(":server 275 alice bob : is using secure connection ");
CHECK_SRV("--", "[bob] is using secure connection ",
"irc_275,irc_numeric,nick_server,log3");
RECV(":server 275 alice bob");
CHECK_SRV("--", "bob", "irc_275,irc_numeric,nick_server,log3");
RECV(":server 276 alice bob : has client certificate fingerprint ");
CHECK_SRV("--", "[bob] has client certificate fingerprint ",
"irc_276,irc_numeric,nick_server,log3");
RECV(":server 276 alice bob");
CHECK_SRV("--", "bob", "irc_276,irc_numeric,nick_server,log3");
RECV(":server 307 alice bob : registered nick ");
CHECK_SRV("--", "[bob] registered nick ", "irc_307,irc_numeric,nick_server,log3");
RECV(":server 307 alice bob");
CHECK_SRV("--", "bob", "irc_307,irc_numeric,nick_server,log3");
RECV(":server 310 alice bob : help mode ");
CHECK_SRV("--", "[bob] help mode ", "irc_310,irc_numeric,nick_server,log3");
RECV(":server 310 alice bob");
CHECK_SRV("--", "bob", "irc_310,irc_numeric,nick_server,log3");
RECV(":server 313 alice bob : operator ");
CHECK_SRV("--", "[bob] operator ", "irc_313,irc_numeric,nick_server,log3");
RECV(":server 313 alice bob");
CHECK_SRV("--", "bob", "irc_313,irc_numeric,nick_server,log3");
RECV(":server 318 alice bob : end ");
CHECK_SRV("--", "[bob] end ", "irc_318,irc_numeric,nick_server,log3");
RECV(":server 318 alice bob");
CHECK_SRV("--", "bob", "irc_318,irc_numeric,nick_server,log3");
RECV(":server 319 alice bob : channels ");
CHECK_SRV("--", "[bob] channels ", "irc_319,irc_numeric,nick_server,log3");
RECV(":server 319 alice bob");
CHECK_SRV("--", "bob", "irc_319,irc_numeric,nick_server,log3");
RECV(":server 320 alice bob : identified user ");
CHECK_SRV("--", "[bob] identified user ", "irc_320,irc_numeric,nick_server,log3");
RECV(":server 320 alice bob");
CHECK_SRV("--", "bob", "irc_320,irc_numeric,nick_server,log3");
RECV(":server 326 alice bob : has oper privs ");
CHECK_SRV("--", "[bob] has oper privs ", "irc_326,irc_numeric,nick_server,log3");
RECV(":server 326 alice bob");
CHECK_SRV("--", "bob", "irc_326,irc_numeric,nick_server,log3");
RECV(":server 335 alice bob : is a bot ");
CHECK_SRV("--", "[bob] is a bot ", "irc_335,irc_numeric,nick_server,log3");
RECV(":server 335 alice bob");
CHECK_SRV("--", "bob", "irc_335,irc_numeric,nick_server,log3");
RECV(":server 337 alice bob : is hiding their idle time ");
CHECK_SRV("--", "[bob] is hiding their idle time ", "irc_337,irc_numeric,nick_server,log3");
RECV(":server 337 alice bob");
CHECK_SRV("--", "bob", "irc_337,irc_numeric,nick_server,log3");
RECV(":server 378 alice bob");
CHECK_SRV("--", "bob", "irc_378,irc_numeric,nick_server,log3");
RECV(":server 378 alice bob : connecting from ");
CHECK_SRV("--", "[bob] connecting from ", "irc_378,irc_numeric,nick_server,log3");
RECV(":server 378 alice bob");
CHECK_SRV("--", "bob", "irc_378,irc_numeric,nick_server,log3");
RECV(":server 379 alice bob : using modes ");
CHECK_SRV("--", "[bob] using modes ", "irc_379,irc_numeric,nick_server,log3");
RECV(":server 379 alice bob");
CHECK_SRV("--", "bob", "irc_379,irc_numeric,nick_server,log3");
RECV(":server 671 alice bob : secure connection ");
CHECK_SRV("--", "[bob] secure connection ", "irc_671,irc_numeric,nick_server,log3");
RECV(":server 671 alice bob");
CHECK_SRV("--", "bob", "irc_671,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_whowas_nick_msg
*
* Messages:
* 369: whowas (end)
*/
TEST(IrcProtocolWithServer, whowas_nick_msg)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 369");
CHECK_ERROR_PARAMS("369", 0, 2);
RECV(":server 369 alice");
CHECK_ERROR_PARAMS("369", 1, 2);
RECV(":server 369 alice bob end");
CHECK_SRV("--", "[bob] end", "irc_369,irc_numeric,nick_server,log3");
RECV(":server 369 alice bob : \002end ");
CHECK_SRV("--", "[bob] end ", "irc_369,irc_numeric,nick_server,log3");
RECV(":server 369 alice bob");
CHECK_SRV("--", "bob", "irc_369,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_301 (away message)
*/
TEST(IrcProtocolWithServer, 301)
{
SRV_INIT;
RECV(":bob!user@host PRIVMSG alice :hi Alice!");
CHECK_PV("bob", "bob", "hi Alice!",
"irc_privmsg,notify_private,prefix_nick_248,nick_bob,"
"host_user@host,log1");
/* not enough parameters */
RECV(":server 301");
CHECK_ERROR_PARAMS("301", 0, 1);
STRCMP_EQUAL(NULL, ptr_server->channels->away_message);
RECV(":server 301 alice bob");
CHECK_NO_MSG;
STRCMP_EQUAL(NULL, ptr_server->channels->away_message);
RECV(":server 301 alice bob : \002I am away ");
CHECK_PV("bob", "--", "[bob] is away: I am away ",
"irc_301,irc_numeric,nick_server,log3");
STRCMP_EQUAL(" \002I am away ", ptr_server->channels->away_message);
}
/*
* Tests functions:
* irc_protocol_cb_303 (ison)
*/
TEST(IrcProtocolWithServer, 303)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 303");
CHECK_ERROR_PARAMS("303", 0, 2);
RECV(":server 303 alice");
CHECK_ERROR_PARAMS("303", 1, 2);
RECV(":server 303 alice : nick1 nick2 ");
CHECK_SRV("--", "Users online: nick1 nick2 ",
"irc_303,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_305 (unaway)
* irc_protocol_cb_306 (away)
*/
TEST(IrcProtocolWithServer, 305_306)
{
SRV_INIT;
RECV(":bob!user@host PRIVMSG alice :hi Alice!");
CHECK_PV("bob", "bob", "hi Alice!",
"irc_privmsg,notify_private,prefix_nick_248,nick_bob,"
"host_user@host,log1");
/* not enough parameters */
RECV(":server 305");
CHECK_ERROR_PARAMS("305", 0, 1);
RECV(":server 306");
CHECK_ERROR_PARAMS("306", 0, 1);
STRCMP_EQUAL(NULL, ptr_server->channels->away_message);
RECV(":server 306 alice"); /* now away */
CHECK_NO_MSG;
LONGS_EQUAL(1, ptr_server->is_away);
RECV(":server 305 alice");
CHECK_NO_MSG;
LONGS_EQUAL(0, ptr_server->is_away);
RECV(":server 306 alice : \002We'll miss you "); /* now away */
CHECK_SRV("--", " We'll miss you ", "irc_306,irc_numeric,nick_server,log3");
LONGS_EQUAL(1, ptr_server->is_away);
RECV(":server 305 alice : \002Does this mean you're really back? ");
CHECK_SRV("--", " Does this mean you're really back? ",
"irc_305,irc_numeric,nick_server,log3");
LONGS_EQUAL(0, ptr_server->is_away);
}
/*
* Tests functions:
* irc_protocol_cb_311 (whois, user)
*/
TEST(IrcProtocolWithServer, 311)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 311");
CHECK_ERROR_PARAMS("311", 0, 3);
RECV(":server 311 alice");
CHECK_ERROR_PARAMS("311", 1, 3);
RECV(":server 311 alice bob");
CHECK_ERROR_PARAMS("311", 2, 3);
RECV(":server 311 alice bob user");
/* non-standard parameters (using default whois callback) */
RECV(":server 311 alice bob user");
CHECK_SRV("--", "[bob] user", "irc_311,irc_numeric,nick_server,log3");
/* standard parameters */
RECV(":server 311 alice bob user_\00304red host_\00302blue * : \002real name ");
CHECK_SRV("--", "[bob] (user_red@host_blue): real name ",
"irc_311,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_312 (whois, server)
*/
TEST(IrcProtocolWithServer, 312)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 312");
CHECK_ERROR_PARAMS("312", 0, 3);
RECV(":server 312 alice");
CHECK_ERROR_PARAMS("312", 1, 3);
RECV(":server 312 alice bob");
CHECK_ERROR_PARAMS("312", 2, 3);
/* non-standard parameters (using default whois callback) */
RECV(":server 312 alice bob server");
CHECK_SRV("--", "[bob] server", "irc_312,irc_numeric,nick_server,log3");
/* standard parameters */
RECV(":server 312 alice bob server : \002https://example.com/ ");
CHECK_SRV("--", "[bob] server ( https://example.com/ )",
"irc_312,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_314 (whowas)
*/
TEST(IrcProtocolWithServer, 314)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 314");
CHECK_ERROR_PARAMS("314", 0, 3);
RECV(":server 314 alice");
CHECK_ERROR_PARAMS("314", 1, 3);
RECV(":server 314 alice bob");
CHECK_ERROR_PARAMS("314", 2, 3);
/* non-standard parameters (using default whowas callback) */
RECV(":server 314 alice bob user");
CHECK_SRV("--", "[bob] user", "irc_314,irc_numeric,nick_server,log3");
/* standard parameters */
RECV(":server 314 alice bob user host * : \002real name ");
CHECK_SRV("--", "[bob] (user@host) was real name ",
"irc_314,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_315 (end of /who)
*/
TEST(IrcProtocolWithServer, 315)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 315");
CHECK_ERROR_PARAMS("315", 0, 3);
RECV(":server 315 alice");
CHECK_ERROR_PARAMS("315", 1, 3);
RECV(":server 315 alice #test");
CHECK_ERROR_PARAMS("315", 2, 3);
RECV(":server 315 alice #test end");
CHECK_SRV("--", "[#test] end",
"irc_315,irc_numeric,nick_server,log3");
RECV(":server 315 alice #test : \002End of /WHO list. ");
CHECK_SRV("--", "[#test] End of /WHO list. ",
"irc_315,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_317 (whois, idle)
*/
TEST(IrcProtocolWithServer, 317)
{
time_t time;
char message[1024];
SRV_INIT;
/* not enough parameters */
RECV(":server 317");
CHECK_ERROR_PARAMS("317", 0, 4);
RECV(":server 317 alice");
CHECK_ERROR_PARAMS("317", 1, 4);
RECV(":server 317 alice bob");
CHECK_ERROR_PARAMS("317", 2, 4);
RECV(":server 317 alice bob 122877");
CHECK_ERROR_PARAMS("317", 3, 4);
/* signon at 03/12/2008 @ 1:18pm (UTC) */
RECV(":server 317 alice bob 122877 1205327880");
CHECK_SRV("--",
"[bob] idle: 1 day, 10 hours 07 minutes 57 seconds, "
"signon at: Wed, 12 Mar 2008 13:18:00",
"irc_317,irc_numeric,nick_server,log3");
RECV(":server 317 alice bob 122877 1205327880 :\002seconds idle, signon time ");
CHECK_SRV("--",
"[bob] idle: 1 day, 10 hours 07 minutes 57 seconds, "
"signon at: Wed, 12 Mar 2008 13:18:00",
"irc_317,irc_numeric,nick_server,log3");
/* signon 2 minutes ago */
time = time_t (NULL);
time -= 120;
snprintf (message, sizeof (message),
":server 317 alice bob 30 %lld :seconds idle, signon time",
(long long)time);
RECV(message);
}
/*
* Tests functions:
* irc_protocol_cb_321 (/list start)
*/
TEST(IrcProtocolWithServer, 321)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 321");
CHECK_ERROR_PARAMS("321", 0, 2);
RECV(":server 321 alice");
CHECK_ERROR_PARAMS("321", 1, 2);
RECV(":server 321 alice #test");
CHECK_SRV("--", "#test", "irc_321,irc_numeric,nick_server,log3");
RECV(":server 321 alice #test Users");
CHECK_SRV("--", "#test Users", "irc_321,irc_numeric,nick_server,log3");
RECV(":server 321 alice #test : \002Users Name ");
CHECK_SRV("--", "#test Users Name ", "irc_321,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_322 (channel for /list)
*/
TEST(IrcProtocolWithServer, 322)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 322");
CHECK_ERROR_PARAMS("322", 0, 3);
RECV(":server 322 alice");
CHECK_ERROR_PARAMS("322", 1, 3);
RECV(":server 322 alice #test");
CHECK_ERROR_PARAMS("322", 2, 3);
RECV(":server 322 alice #test 3");
CHECK_SRV("--", "#test(3)", "irc_322,irc_numeric,nick_server,log3");
RECV(":server 322 alice #test 3 :\002topic of channel ");
CHECK_SRV("--", "#test(3): topic of channel ",
"irc_322,irc_numeric,nick_server,log3");
run_cmd_quiet ("/list -server " IRC_FAKE_SERVER " -raw #test.*");
CHECK_SRV("--", "#test(3): topic of channel ",
"irc_322,irc_numeric,nick_server,log3");
RECV(":server 322 alice #test 3");
CHECK_SRV("--", "#test(3)",
"irc_322,irc_numeric,nick_server,log3");
RECV(":server 322 alice #test 3 :topic of channel ");
CHECK_SRV("--", "#test(3): topic of channel ",
"irc_322,irc_numeric,nick_server,log3");
RECV(":server 322 alice #xyz 3");
CHECK_NO_MSG;
RECV(":server 322 alice #xyz 3 :topic of channel ");
CHECK_NO_MSG;
}
/*
* Tests functions:
* irc_protocol_cb_323 (end of /list)
*/
TEST(IrcProtocolWithServer, 323)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 323");
CHECK_ERROR_PARAMS("323", 0, 1);
RECV(":server 323 alice");
CHECK_SRV("--", "", "irc_323,irc_numeric,nick_server,log3");
RECV(":server 323 alice end");
CHECK_SRV("--", "end", "irc_323,irc_numeric,nick_server,log3");
RECV(":server 323 alice : \002End of /LIST ");
CHECK_SRV("--", " End of /LIST ", "irc_323,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_324 (channel mode)
*/
TEST(IrcProtocolWithServer, 324)
{
SRV_INIT_JOIN;
STRCMP_EQUAL(NULL, ptr_server->channels->modes);
/* not enough parameters */
RECV(":server 324");
CHECK_ERROR_PARAMS("324", 0, 2);
RECV(":server 324 alice");
CHECK_ERROR_PARAMS("324", 1, 2);
RECV(":server 324 alice #test +nt");
CHECK_NO_MSG;
STRCMP_EQUAL("+nt", ptr_server->channels->modes);
RECV(":server 324 alice #test +nst ");
CHECK_CHAN("--", "Mode #test [+nst]", "irc_324,irc_numeric,nick_server,log3");
STRCMP_EQUAL("+nst", ptr_server->channels->modes);
RECV(":server 324 alice #test");
CHECK_CHAN("--", "Mode #test []", "irc_324,irc_numeric,nick_server,log3");
STRCMP_EQUAL(NULL, ptr_server->channels->modes);
}
/*
* Tests functions:
* irc_protocol_cb_327 (whois, host)
*/
TEST(IrcProtocolWithServer, 327)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 327");
CHECK_ERROR_PARAMS("327", 0, 3);
RECV(":server 327 alice");
CHECK_ERROR_PARAMS("327", 1, 3);
RECV(":server 327 alice bob");
CHECK_ERROR_PARAMS("327", 2, 3);
/* non-standard parameters (using default whois callback) */
RECV(":server 327 alice bob host");
CHECK_SRV("--", "[bob] host", "irc_327,irc_numeric,nick_server,log3");
/* standard parameters */
RECV(":server 327 alice bob host 1.2.3.4");
CHECK_SRV("--", "[bob] host 1.2.3.4", "irc_327,irc_numeric,nick_server,log3");
RECV(":server 327 alice bob host_\00304red 1.2.3.4 : \002real name ");
CHECK_SRV("--", "[bob] host_red 1.2.3.4 ( real name )",
"irc_327,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_328 (channel URL)
*/
TEST(IrcProtocolWithServer, 328)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 328");
CHECK_ERROR_PARAMS("328", 0, 3);
RECV(":server 328 alice");
CHECK_ERROR_PARAMS("328", 1, 3);
RECV(":server 328 alice #test");
CHECK_ERROR_PARAMS("328", 2, 3);
RECV(":server 328 alice #test :https://example.com/");
CHECK_CHAN("--", "URL for #test: https://example.com/",
"irc_328,irc_numeric,nick_server,log3");
RECV(":server 328 alice #test : \002URL is https://example.com/ ");
CHECK_CHAN("--", "URL for #test: URL is https://example.com/ ",
"irc_328,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_329 (channel creation date)
*/
TEST(IrcProtocolWithServer, 329)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 329");
CHECK_ERROR_PARAMS("329", 0, 3);
RECV(":server 329 alice");
CHECK_ERROR_PARAMS("329", 1, 3);
RECV(":server 329 alice #test");
CHECK_ERROR_PARAMS("329", 2, 3);
RECV(":server 329 alice #test 1205327894");
CHECK_CHAN("--", "Channel created on Wed, 12 Mar 2008 13:18:14",
"irc_329,irc_numeric,nick_server,log3");
RECV(":server 329 alice #test :1205327894");
CHECK_CHAN("--", "Channel created on Wed, 12 Mar 2008 13:18:14",
"irc_329,irc_numeric,nick_server,log3");
/* channel not found */
RECV(":server 329 alice #xyz 1205327894");
CHECK_SRV("--", "Channel #xyz created on Wed, 12 Mar 2008 13:18:14",
"irc_329,irc_numeric,nick_server,log3");
RECV(":server 329 alice #xyz :1205327894 ");
CHECK_SRV("--", "Channel #xyz created on Wed, 12 Mar 2008 13:18:14",
"irc_329,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_330 (whois, is logged in as)
* irc_protocol_cb_343 (whois, is opered as)
*/
TEST(IrcProtocolWithServer, 330_343)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 330");
CHECK_ERROR_PARAMS("330", 0, 3);
RECV(":server 330 alice");
CHECK_ERROR_PARAMS("330", 1, 3);
RECV(":server 330 alice bob");
CHECK_ERROR_PARAMS("330", 2, 3);
/* not enough parameters */
RECV(":server 343");
CHECK_ERROR_PARAMS("343", 0, 3);
RECV(":server 343 alice");
CHECK_ERROR_PARAMS("343", 1, 3);
RECV(":server 343 alice bob");
CHECK_ERROR_PARAMS("343", 2, 3);
RECV(":server 330 alice bob bob2");
CHECK_SRV("--", "[bob] bob2", "irc_330,irc_numeric,nick_server,log3");
RECV(":server 330 alice bob bob2 : \002is logged in as ");
CHECK_SRV("--", "[bob] is logged in as bob2",
"irc_330,irc_numeric,nick_server,log3");
RECV(":server 343 alice bob bob2");
CHECK_SRV("--", "[bob] bob2", "irc_343,irc_numeric,nick_server,log3");
RECV(":server 343 alice bob bob2 :\002is opered as ");
CHECK_SRV("--", "[bob] is opered as bob2",
"irc_343,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_331 (no topic for channel)
*/
TEST(IrcProtocolWithServer, 331)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 331");
CHECK_ERROR_PARAMS("331", 0, 2);
RECV(":server 331 alice");
CHECK_ERROR_PARAMS("331", 1, 2);
RECV(":server 331 alice #test");
CHECK_CHAN("--", "No topic set for channel #test",
"irc_331,irc_numeric,nick_server,log3");
/* channel not found */
RECV(":server 331 alice #xyz ");
CHECK_SRV("--", "No topic set for channel #xyz",
"irc_331,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_332 (topic of channel)
*/
TEST(IrcProtocolWithServer, 332)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 332");
CHECK_ERROR_PARAMS("332", 0, 2);
RECV(":server 332 alice");
CHECK_ERROR_PARAMS("332", 1, 2);
STRCMP_EQUAL(NULL, ptr_server->channels->topic);
RECV(":server 332 alice #test");
CHECK_CHAN("--", "Topic for #test is \"\"",
"irc_332,irc_numeric,nick_server,log3");
RECV(":server 332 alice #test :\002the new topic ");
CHECK_CHAN("--", "Topic for #test is \"the new topic \"",
"irc_332,irc_numeric,nick_server,log3");
STRCMP_EQUAL("\002the new topic ",
ptr_server->channels->topic);
}
/*
* Tests functions:
* irc_protocol_cb_333 (infos about topic (nick / date))
*/
TEST(IrcProtocolWithServer, 333)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 333");
CHECK_ERROR_PARAMS("333", 0, 3);
RECV(":server 333 alice");
CHECK_ERROR_PARAMS("333", 1, 3);
RECV(":server 333 alice #test");
CHECK_ERROR_PARAMS("333", 2, 3);
RECV(":server 333 alice #test nick!user_\00304red@host_\00304red");
CHECK_NO_MSG;
RECV(":server 333 alice #test nick!user_\00304red@host_\00304red 1205428096");
CHECK_CHAN("--",
"Topic set by nick (user_red@host_red) on Thu, 13 Mar 2008 17:08:16",
"irc_333,irc_numeric,nick_server,log3");
RECV(":server 333 alice #test 1205428096 ");
CHECK_CHAN("--", "Topic set on Thu, 13 Mar 2008 17:08:16",
"irc_333,irc_numeric,nick_server,log3");
/* channel not found */
RECV(":server 333 alice #xyz nick!user_\00304red@host_\00304red");
CHECK_NO_MSG;
RECV(":server 333 alice #xyz nick!user_\00304red@host_\00304red 1205428096");
CHECK_SRV("--",
"Topic for #xyz set by nick (user_red@host_red) on "
"Thu, 13 Mar 2008 17:08:16",
"irc_333,irc_numeric,nick_server,log3");
RECV(":server 333 alice #xyz 1205428096");
CHECK_SRV("--", "Topic for #xyz set on Thu, 13 Mar 2008 17:08:16",
"irc_333,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_338 (whois, host)
*/
TEST(IrcProtocolWithServer, 338)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 338");
CHECK_ERROR_PARAMS("338", 0, 3);
RECV(":server 338 alice");
CHECK_ERROR_PARAMS("338", 1, 3);
RECV(":server 338 alice bob");
CHECK_ERROR_PARAMS("338", 2, 3);
RECV(":server 338 alice bob host_\00304red : \002actually using host ");
CHECK_SRV("--", "[bob] actually using host host_red",
"irc_338,irc_numeric,nick_server,log3");
/* on Rizon server */
RECV(":server 338 alice bob :\002is actually bob_\00304red@example_\00304red.com [1.2.3.4]");
CHECK_SRV("--", "[bob] is actually bob_red@example_red.com [1.2.3.4]",
"irc_338,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_341 (inviting)
*/
TEST(IrcProtocolWithServer, 341)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 341");
CHECK_ERROR_PARAMS("341", 0, 3);
RECV(":server 341 alice");
CHECK_ERROR_PARAMS("341", 1, 3);
RECV(":server 341 alice bob");
CHECK_ERROR_PARAMS("341", 2, 3);
RECV(":server 341 alice bob #test");
CHECK_SRV("--", "alice has invited bob to #test",
"irc_341,irc_numeric,nick_alice,log3");
RECV(":server 341 alice bob : #test ");
CHECK_SRV("--", "alice has invited bob to #test ",
"irc_341,irc_numeric,nick_alice,log3");
}
/*
* Tests functions:
* irc_protocol_cb_344 (channel reop / whois (geo info))
*/
TEST(IrcProtocolWithServer, 344)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 344");
CHECK_ERROR_PARAMS("344", 0, 3);
RECV(":server 344 alice");
CHECK_ERROR_PARAMS("344", 1, 3);
RECV(":server 344 alice #test");
CHECK_ERROR_PARAMS("344", 2, 3);
/* channel reop (IRCnet) */
RECV(":server 344 alice #test nick!user@host");
CHECK_SRV("--", "Channel reop #test: nick!user@host",
"irc_344,irc_numeric,nick_server,log3");
RECV(":server 344 alice #test : nick!user@host ");
CHECK_SRV("--", "Channel reop #test: nick!user@host ",
"irc_344,irc_numeric,nick_server,log3");
/* channel reop (IRCnet), channel not found */
RECV(":server 344 alice #xyz nick!user@host");
CHECK_SRV("--", "Channel reop #xyz: nick!user@host",
"irc_344,irc_numeric,nick_server,log3");
RECV(":server 344 alice #xyz : nick!user@host ");
CHECK_SRV("--", "Channel reop #xyz: nick!user@host ",
"irc_344,irc_numeric,nick_server,log3");
/* whois, geo info (UnrealIRCd) */
RECV(":server 344 alice bob FR : \002is connecting from France ");
CHECK_SRV("--", "[bob] is connecting from France (FR)",
"irc_344,irc_numeric,nick_server,log3");
/* whois, geo info (UnrealIRCd), no country code */
RECV(":server 344 alice bob : \002is connecting from France ");
CHECK_SRV("--", "[bob] is connecting from France ",
"irc_344,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_345 (end of channel reop)
*/
TEST(IrcProtocolWithServer, 345)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 345");
CHECK_ERROR_PARAMS("345", 0, 3);
RECV(":server 345 alice");
CHECK_ERROR_PARAMS("345", 1, 3);
RECV(":server 345 alice #test");
CHECK_ERROR_PARAMS("345", 2, 3);
RECV(":server 345 alice #test end");
CHECK_SRV("--", "#test: end", "irc_345,irc_numeric,nick_server,log3");
RECV(":server 345 alice #test : \002End of Channel Reop List ");
CHECK_SRV("--", "#test: End of Channel Reop List ",
"irc_345,irc_numeric,nick_server,log3");
/* channel not found */
RECV(":server 345 alice #xyz end");
CHECK_SRV("--", "#xyz: end", "irc_345,irc_numeric,nick_server,log3");
RECV(":server 345 alice #xyz :\002End of Channel Reop List");
CHECK_SRV("--", "#xyz: End of Channel Reop List",
"irc_345,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_346 (channel invite list)
*/
TEST(IrcProtocolWithServer, 346)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 346");
CHECK_ERROR_PARAMS("346", 0, 3);
RECV(":server 346 alice");
CHECK_ERROR_PARAMS("346", 1, 3);
RECV(":server 346 alice #test");
CHECK_ERROR_PARAMS("346", 2, 3);
RECV(":server 346 alice #test invitemask");
CHECK_CHAN("--", "[#test] [1] invitemask invited",
"irc_346,irc_numeric,nick_server,log3");
RECV(":server 346 alice #test invitemask nick!user_\00304red@host_\00304red");
CHECK_CHAN("--", "[#test] [2] invitemask invited by nick (user_red@host_red)",
"irc_346,irc_numeric,nick_server,log3");
RECV(":server 346 alice #test invitemask nick!user_\00304red@host_\00304red 1205590879 ");
CHECK_CHAN("--",
"[#test] [3] invitemask invited by nick (user_red@host_red) "
"on Sat, 15 Mar 2008 14:21:19",
"irc_346,irc_numeric,nick_server,log3");
/* channel not found */
RECV(":server 346 alice #xyz invitemask");
CHECK_SRV("--", "[#xyz] invitemask invited",
"irc_346,irc_numeric,nick_server,log3");
RECV(":server 346 alice #xyz invitemask nick!user_\00304red@host_\00304red");
CHECK_SRV("--", "[#xyz] invitemask invited by nick (user_red@host_red)",
"irc_346,irc_numeric,nick_server,log3");
RECV(":server 346 alice #xyz invitemask nick!user_\00304red@host_\00304red 1205590879");
CHECK_SRV("--",
"[#xyz] invitemask invited by nick (user_red@host_red) "
"on Sat, 15 Mar 2008 14:21:19",
"irc_346,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_347 (end of channel invite list)
*/
TEST(IrcProtocolWithServer, 347)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 347");
CHECK_ERROR_PARAMS("347", 0, 2);
RECV(":server 347 alice");
CHECK_ERROR_PARAMS("347", 1, 2);
RECV(":server 347 alice #test");
CHECK_CHAN("--", "[#test]", "irc_347,irc_numeric,nick_server,log3");
RECV(":server 347 alice #test end");
CHECK_CHAN("--", "[#test] end", "irc_347,irc_numeric,nick_server,log3");
RECV(":server 347 alice #test : \002End of Channel Invite List ");
CHECK_CHAN("--", "[#test] End of Channel Invite List ",
"irc_347,irc_numeric,nick_server,log3");
/* channel not found */
RECV(":server 347 alice #xyz");
CHECK_SRV("--", "[#xyz]", "irc_347,irc_numeric,nick_server,log3");
RECV(":server 347 alice #xyz end");
CHECK_SRV("--", "[#xyz] end", "irc_347,irc_numeric,nick_server,log3");
RECV(":server 347 alice #xyz :\002End of Channel Invite List");
CHECK_SRV("--", "[#xyz] End of Channel Invite List",
"irc_347,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_348 (channel exception list)
*/
TEST(IrcProtocolWithServer, 348)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 348");
CHECK_ERROR_PARAMS("348", 0, 3);
RECV(":server 348 alice");
CHECK_ERROR_PARAMS("348", 1, 3);
RECV(":server 348 alice #test");
CHECK_ERROR_PARAMS("348", 2, 3);
RECV(":server 348 alice #test nick1!user1@host1");
CHECK_CHAN("--", "[#test] [1] exception nick1!user1@host1",
"irc_348,irc_numeric,nick_server,log3");
RECV(":server 348 alice #test nick1!user_\00304red@host_\00304red "
"nick2!user_\00302blue@host_\00302blue");
CHECK_CHAN("--",
"[#test] [2] exception nick1!user_red@host_red "
"by nick2 (user_blue@host_blue)",
"irc_348,irc_numeric,nick_server,log3");
RECV(":server 348 alice #test nick1!user_\00304red@host_\00304red "
"nick2!user_\00302blue@host_\00302blue 1205585109 ");
CHECK_CHAN("--",
"[#test] [3] exception nick1!user_red@host_red "
"by nick2 (user_blue@host_blue) on Sat, 15 Mar 2008 12:45:09",
"irc_348,irc_numeric,nick_server,log3");
/* channel not found */
RECV(":server 348 alice #xyz nick1!user_\00304red@host_\00304red");
CHECK_SRV("--", "[#xyz] exception nick1!user_red@host_red",
"irc_348,irc_numeric,nick_server,log3");
RECV(":server 348 alice #xyz nick1!user_\00304red@host_\00304red "
"nick2!user_\00302blue@host_\00302blue");
CHECK_SRV("--",
"[#xyz] exception nick1!user_red@host_red "
"by nick2 (user_blue@host_blue)",
"irc_348,irc_numeric,nick_server,log3");
RECV(":server 348 alice #xyz nick1!user_\00304red@host_\00304red "
"nick2!user_\00302blue@host_\00302blue 1205585109");
CHECK_SRV("--",
"[#xyz] exception nick1!user_red@host_red "
"by nick2 (user_blue@host_blue) on Sat, 15 Mar 2008 12:45:09",
"irc_348,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_349 (end of channel exception list)
*/
TEST(IrcProtocolWithServer, 349)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 349");
CHECK_ERROR_PARAMS("349", 0, 2);
RECV(":server 349 alice");
CHECK_ERROR_PARAMS("349", 1, 2);
RECV(":server 349 alice #test");
CHECK_CHAN("--", "[#test]", "irc_349,irc_numeric,nick_server,log3");
RECV(":server 349 alice #test end");
CHECK_CHAN("--", "[#test] end", "irc_349,irc_numeric,nick_server,log3");
RECV(":server 349 alice #test :\002End of Channel Exception List ");
CHECK_CHAN("--", "[#test] End of Channel Exception List ",
"irc_349,irc_numeric,nick_server,log3");
/* channel not found */
RECV(":server 349 alice #xyz");
CHECK_SRV("--", "[#xyz]", "irc_349,irc_numeric,nick_server,log3");
RECV(":server 349 alice #xyz end");
CHECK_SRV("--", "[#xyz] end", "irc_349,irc_numeric,nick_server,log3");
RECV(":server 349 alice #xyz :\002End of Channel Exception List");
CHECK_SRV("--", "[#xyz] End of Channel Exception List",
"irc_349,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_350 (whois, gateway)
*/
TEST(IrcProtocolWithServer, 350)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 350");
CHECK_ERROR_PARAMS("350", 0, 2);
RECV(":server 350 alice");
CHECK_ERROR_PARAMS("350", 1, 2);
/* non-standard parameters (using whois_nick_msg callback) */
RECV(":server 350 alice bob : \002something here ");
CHECK_SRV("--", "[bob] something here ",
"irc_350,irc_numeric,nick_server,log3");
RECV(":server 350 alice bob * : something here ");
CHECK_SRV("--", "[bob] something here ",
"irc_350,irc_numeric,nick_server,log3");
/* non-standard parameters (using default whois callback) */
RECV(":server 350 alice bob");
CHECK_SRV("--", "bob", "irc_350,irc_numeric,nick_server,log3");
/* standard parameters */
RECV(":server 350 alice bob * * : \002is connected via the WebIRC gateway ");
CHECK_SRV("--", "[bob] is connected via the WebIRC gateway ",
"irc_350,irc_numeric,nick_server,log3");
RECV(":server 350 alice bob example.com * :is connected via the WebIRC gateway");
CHECK_SRV("--", "[bob] (example.com) is connected via the WebIRC gateway",
"irc_350,irc_numeric,nick_server,log3");
RECV(":server 350 alice bob * 1.2.3.4 :is connected via the WebIRC gateway");
CHECK_SRV("--", "[bob] (1.2.3.4) is connected via the WebIRC gateway",
"irc_350,irc_numeric,nick_server,log3");
RECV(":server 350 alice bob example.com 1.2.3.4 :is connected via the WebIRC gateway");
CHECK_SRV("--",
"[bob] (example.com, 1.2.3.4) is connected via the WebIRC gateway",
"irc_350,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_351 (server version)
*/
TEST(IrcProtocolWithServer, 351)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 351");
CHECK_ERROR_PARAMS("351", 0, 3);
RECV(":server 351 alice");
CHECK_ERROR_PARAMS("351", 1, 3);
RECV(":server 351 alice dancer-ircd-1.0");
CHECK_ERROR_PARAMS("351", 2, 3);
RECV(":server 351 alice dancer-ircd-1.0 server");
CHECK_SRV("--", "dancer-ircd-1.0 server",
"irc_351,irc_numeric,nick_server,log3");
RECV(":server 351 alice dancer-ircd-1.0 server : iMZ \002dncrTS/v4 ");
CHECK_SRV("--", "dancer-ircd-1.0 server ( iMZ dncrTS/v4 )",
"irc_351,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_352 (who)
*/
TEST(IrcProtocolWithServer, 352)
{
struct t_irc_nick *ptr_nick, *ptr_nick2;
SRV_INIT_JOIN2;
/* not enough parameters */
RECV(":server 352");
CHECK_ERROR_PARAMS("352", 0, 3);
RECV(":server 352 alice");
CHECK_ERROR_PARAMS("352", 1, 3);
RECV(":server 352 alice #test");
CHECK_ERROR_PARAMS("352", 2, 3);
/* not enough parameters, but silently ignored */
RECV(":server 352 alice #test user");
CHECK_NO_MSG;
RECV(":server 352 alice #test user host");
CHECK_NO_MSG;
RECV(":server 352 alice #test user host server");
CHECK_NO_MSG;
ptr_nick = ptr_server->channels->nicks;
ptr_nick2 = ptr_server->channels->last_nick;
STRCMP_EQUAL("user_a@host_a", ptr_nick->host);
STRCMP_EQUAL("user_b@host_b", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick->away);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL(NULL, ptr_nick->realname);
STRCMP_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 352 alice #test user_\00304red host_\00304red server bob");
CHECK_SRV("--", "[#test] bob (user_red@host_red) ()",
"irc_352,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user_\00304red@host_\00304red", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 352 alice #test user3 host3 server bob *");
CHECK_SRV("--", "[#test] bob (user3@host3) * ()",
"irc_352,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user3@host3", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 352 alice #test user4 host4 server bob * :0 \002real name 1 ");
CHECK_SRV("--", "[#test] bob (user4@host4) * 0 (real name 1 )",
"irc_352,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user4@host4", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL("\002real name 1 ", ptr_nick2->realname);
RECV(":server 352 alice #test user5 host5 server bob H@ :0 real name 2");
CHECK_SRV("--", "[#test] bob (user5@host5) H@ 0 (real name 2)",
"irc_352,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user5@host5", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL("real name 2", ptr_nick2->realname);
RECV(":server 352 alice #test user6 host6 server bob G@ :0 real name 3");
CHECK_SRV("--", "[#test] bob (user6@host6) G@ 0 (real name 3)",
"irc_352,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user6@host6", ptr_nick2->host);
LONGS_EQUAL(1, ptr_nick2->away);
STRCMP_EQUAL("real name 3", ptr_nick2->realname);
RECV(":server 352 alice #test user7 host7 server bob * :0 real name 4");
CHECK_SRV("--", "[#test] bob (user7@host7) * 0 (real name 4)",
"irc_352,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user7@host7", ptr_nick2->host);
LONGS_EQUAL(1, ptr_nick2->away);
STRCMP_EQUAL("real name 4", ptr_nick2->realname);
RECV(":server 352 alice #test user_\00304red host_\00304red server bob H@ :0 real name \00302blue");
CHECK_SRV("--", "[#test] bob (user_red@host_red) H@ 0 (real name blue)",
"irc_352,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user_\00304red@host_\00304red", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL("real name \00302blue", ptr_nick2->realname);
RECV(":server 352 alice #test user8 host8 server bob H@ :0");
CHECK_SRV("--", "[#test] bob (user8@host8) H@ 0 ()",
"irc_352,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user8@host8", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL("real name \00302blue", ptr_nick2->realname);
/* nothing should have changed in the first nick */
STRCMP_EQUAL("user_a@host_a", ptr_nick->host);
LONGS_EQUAL(0, ptr_nick->away);
STRCMP_EQUAL(NULL, ptr_nick->realname);
/* channel not found */
RECV(":server 352 alice #xyz user");
CHECK_NO_MSG;
RECV(":server 352 alice #xyz user host");
CHECK_NO_MSG;
RECV(":server 352 alice #xyz user host server");
CHECK_NO_MSG;
RECV(":server 352 alice #xyz user host server bob");
CHECK_SRV("--", "[#xyz] bob (user@host) ()",
"irc_352,irc_numeric,nick_server,log3");
RECV(":server 352 alice #xyz user host server bob *");
CHECK_SRV("--", "[#xyz] bob (user@host) * ()",
"irc_352,irc_numeric,nick_server,log3");
RECV(":server 352 alice #xyz user host server bob * :0 nick");
CHECK_SRV("--", "[#xyz] bob (user@host) * 0 (nick)",
"irc_352,irc_numeric,nick_server,log3");
RECV(":server 352 alice #xyz user host server bob H@ :0 nick");
CHECK_SRV("--", "[#xyz] bob (user@host) H@ 0 (nick)",
"irc_352,irc_numeric,nick_server,log3");
RECV(":server 352 alice #xyz user host server bob G@ :0 nick");
CHECK_SRV("--", "[#xyz] bob (user@host) G@ 0 (nick)",
"irc_352,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_353 (list of users on a channel)
*/
TEST(IrcProtocolWithServer, 353)
{
struct t_irc_channel *ptr_channel;
SRV_INIT_JOIN2;
ptr_channel = ptr_server->channels;
STRCMP_EQUAL("alice", ptr_channel->nicks->name);
STRCMP_EQUAL("bob", ptr_channel->nicks->next_nick->name);
POINTERS_EQUAL(NULL, ptr_channel->nicks->next_nick->next_nick);
/* not enough parameters */
RECV(":server 353");
CHECK_ERROR_PARAMS("353", 0, 3);
RECV(":server 353 alice");
CHECK_ERROR_PARAMS("353", 1, 3);
RECV(":server 353 alice #test");
CHECK_ERROR_PARAMS("353", 2, 3);
RECV(":server 353 alice =");
CHECK_ERROR_PARAMS("353", 2, 3);
RECV(":server 353 alice = #test");
CHECK_ERROR_PARSE("353", ":server 353 alice = #test");
RECV(":server 353 alice #test :alice");
CHECK_NO_MSG;
STRCMP_EQUAL("alice", ptr_channel->nicks->name);
STRCMP_EQUAL("bob", ptr_channel->nicks->next_nick->name);
POINTERS_EQUAL(NULL, ptr_channel->nicks->next_nick->next_nick);
RECV(":server 353 alice #test :alice bob @carol +dan!user_\00304red@host_\00304red ");
CHECK_NO_MSG;
STRCMP_EQUAL("alice", ptr_channel->nicks->name);
STRCMP_EQUAL("bob", ptr_channel->nicks->next_nick->name);
STRCMP_EQUAL("carol", ptr_channel->nicks->next_nick->next_nick->name);
STRCMP_EQUAL("@", ptr_channel->nicks->next_nick->next_nick->prefix);
STRCMP_EQUAL("dan",
ptr_channel->nicks->next_nick->next_nick->next_nick->name);
STRCMP_EQUAL("+",
ptr_channel->nicks->next_nick->next_nick->next_nick->prefix);
STRCMP_EQUAL("user_\00304red@host_\00304red",
ptr_channel->nicks->next_nick->next_nick->next_nick->host);
POINTERS_EQUAL(NULL,
ptr_channel->nicks->next_nick->next_nick->next_nick->next_nick);
RECV(":server 353 alice = #test :alice");
CHECK_NO_MSG;
STRCMP_EQUAL("alice", ptr_channel->nicks->name);
STRCMP_EQUAL("bob", ptr_channel->nicks->next_nick->name);
STRCMP_EQUAL("carol", ptr_channel->nicks->next_nick->next_nick->name);
STRCMP_EQUAL("@", ptr_channel->nicks->next_nick->next_nick->prefix);
STRCMP_EQUAL("dan",
ptr_channel->nicks->next_nick->next_nick->next_nick->name);
STRCMP_EQUAL("+",
ptr_channel->nicks->next_nick->next_nick->next_nick->prefix);
STRCMP_EQUAL("user_\00304red@host_\00304red",
ptr_channel->nicks->next_nick->next_nick->next_nick->host);
POINTERS_EQUAL(NULL,
ptr_channel->nicks->next_nick->next_nick->next_nick->next_nick);
RECV(":server 353 alice = #test :alice bob @carol +dan!user_\00304red@host_\00304red");
CHECK_NO_MSG;
STRCMP_EQUAL("alice", ptr_channel->nicks->name);
STRCMP_EQUAL("bob", ptr_channel->nicks->next_nick->name);
STRCMP_EQUAL("carol", ptr_channel->nicks->next_nick->next_nick->name);
STRCMP_EQUAL("@", ptr_channel->nicks->next_nick->next_nick->prefix);
STRCMP_EQUAL("dan",
ptr_channel->nicks->next_nick->next_nick->next_nick->name);
STRCMP_EQUAL("+",
ptr_channel->nicks->next_nick->next_nick->next_nick->prefix);
STRCMP_EQUAL("user_\00304red@host_\00304red",
ptr_channel->nicks->next_nick->next_nick->next_nick->host);
POINTERS_EQUAL(NULL,
ptr_channel->nicks->next_nick->next_nick->next_nick->next_nick);
/* with option irc.look.color_nicks_in_names enabled */
config_file_option_set (irc_config_look_color_nicks_in_names, "on", 1);
RECV(":server 353 alice = #test :alice bob @carol +dan!user@host");
config_file_option_unset (irc_config_look_color_nicks_in_names);
/* channel not found */
RECV(":server 353 alice #xyz :alice");
CHECK_SRV("--", "Nicks #xyz: [alice]",
"irc_353,irc_numeric,nick_server,log3");
RECV(":server 353 alice #xyz :alice bob @carol +dan!user@host");
CHECK_SRV("--", "Nicks #xyz: [alice bob @carol +dan]",
"irc_353,irc_numeric,nick_server,log3");
/* channel not found */
RECV(":server 353 alice = #xyz :alice");
CHECK_SRV("--", "Nicks #xyz: [alice]",
"irc_353,irc_numeric,nick_server,log3");
RECV(":server 353 alice = #xyz :alice bob @carol +dan!user@host");
CHECK_SRV("--", "Nicks #xyz: [alice bob @carol +dan]",
"irc_353,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_354 (WHOX output)
*/
TEST(IrcProtocolWithServer, 354)
{
struct t_irc_nick *ptr_nick, *ptr_nick2;
/* assume "account-notify" capability is enabled in server */
hashtable_set (ptr_server->cap_list, "account-notify", NULL);
SRV_INIT_JOIN2;
/* not enough parameters */
RECV(":server 354");
CHECK_ERROR_PARAMS("354", 0, 2);
RECV(":server 354 alice");
CHECK_ERROR_PARAMS("354", 1, 2);
ptr_nick = ptr_server->channels->nicks;
ptr_nick2 = ptr_server->channels->last_nick;
STRCMP_EQUAL("user_a@host_a", ptr_nick->host);
STRCMP_EQUAL("user_b@host_b", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick->away);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL(NULL, ptr_nick->account);
STRCMP_EQUAL(NULL, ptr_nick2->account);
STRCMP_EQUAL(NULL, ptr_nick->realname);
STRCMP_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 354 alice #test");
CHECK_SRV("--", "[#test]", "irc_354,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user_b@host_b", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL(NULL, ptr_nick2->account);
STRCMP_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 354 alice #test user2");
CHECK_SRV("--", "[#test] user2", "irc_354,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user_b@host_b", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL(NULL, ptr_nick2->account);
STRCMP_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 354 alice #test user2 :trailing parameter");
CHECK_SRV("--", "[#test] user2 trailing parameter",
"irc_354,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user_b@host_b", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL(NULL, ptr_nick2->account);
STRCMP_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 354 alice #test user2 host2");
CHECK_SRV("--", "[#test] user2 host2", "irc_354,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user_b@host_b", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL(NULL, ptr_nick2->account);
STRCMP_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 354 alice #test user2 host2 server");
CHECK_SRV("--", "[#test] user2 host2 server",
"irc_354,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user_b@host_b", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL(NULL, ptr_nick2->account);
STRCMP_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 354 alice #test user2 host2 server bob");
CHECK_SRV("--", "[#test] user2 host2 server bob",
"irc_354,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user_b@host_b", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL(NULL, ptr_nick2->account);
STRCMP_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 354 alice #test user2 host2 server bob *");
CHECK_SRV("--", "[#test] user2 host2 server bob *",
"irc_354,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user_b@host_b", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL(NULL, ptr_nick2->account);
STRCMP_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 354 alice #test user2 host2 server bob H@ 0");
CHECK_SRV("--", "[#test] user2 host2 server bob H@ 0",
"irc_354,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user_b@host_b", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL(NULL, ptr_nick2->account);
STRCMP_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 354 alice #test user2 host2 server bob * 0 \002account2");
CHECK_SRV("--", "[#test] bob [account2] (user2@host2) * 0 ()",
"irc_354,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user2@host2", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL("\002account2", ptr_nick2->account);
STRCMP_EQUAL(NULL, ptr_nick2->realname);
RECV(":server 354 alice #test user3 host3 server bob * 0 \002account3 "
": \002real name 2 ");
CHECK_SRV("--", "[#test] bob [account3] (user3@host3) * 0 ( real name 2 )",
"irc_354,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user3@host3", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL("\002account3", ptr_nick2->account);
STRCMP_EQUAL(" \002real name 2 ", ptr_nick2->realname);
RECV(":server 354 alice #test user4 host4 server bob H@ 0 account4 "
":real name 3");
CHECK_SRV("--",
"[#test] bob [account4] (user4@host4) H@ 0 (real name 3)",
"irc_354,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user4@host4", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL("account4", ptr_nick2->account);
STRCMP_EQUAL("real name 3", ptr_nick2->realname);
RECV(":server 354 alice #test user5 host5 server bob G@ 0 account5 "
":real name 4");
CHECK_SRV("--",
"[#test] bob [account5] (user5@host5) G@ 0 (real name 4)",
"irc_354,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user5@host5", ptr_nick2->host);
LONGS_EQUAL(1, ptr_nick2->away);
STRCMP_EQUAL("account5", ptr_nick2->account);
STRCMP_EQUAL("real name 4", ptr_nick2->realname);
RECV(":server 354 alice #test user6 host6 server bob * 0 account6 "
":real name 5");
CHECK_SRV("--",
"[#test] bob [account6] (user6@host6) * 0 (real name 5)",
"irc_354,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user6@host6", ptr_nick2->host);
LONGS_EQUAL(1, ptr_nick2->away);
STRCMP_EQUAL("account6", ptr_nick2->account);
STRCMP_EQUAL("real name 5", ptr_nick2->realname);
RECV(":server 354 alice #test user_\00304red host_\00304red server bob "
"H@ 0 account_\00304red :real name \00302blue");
CHECK_SRV("--",
"[#test] bob [account_red] (user_red@host_red) H@ 0 "
"(real name blue)",
"irc_354,irc_numeric,nick_server,log3");
STRCMP_EQUAL("user_\00304red@host_\00304red", ptr_nick2->host);
LONGS_EQUAL(0, ptr_nick2->away);
STRCMP_EQUAL("account_\00304red", ptr_nick2->account);
STRCMP_EQUAL("real name \00302blue", ptr_nick2->realname);
/* nothing should have changed in the first nick */
STRCMP_EQUAL("user_a@host_a", ptr_nick->host);
LONGS_EQUAL(0, ptr_nick->away);
STRCMP_EQUAL(NULL, ptr_nick->account);
STRCMP_EQUAL(NULL, ptr_nick->realname);
/* channel not found */
RECV(":server 354 alice #xyz");
CHECK_SRV("--", "[#xyz]", "irc_354,irc_numeric,nick_server,log3");
RECV(":server 354 alice #xyz user2");
CHECK_SRV("--", "[#xyz] user2", "irc_354,irc_numeric,nick_server,log3");
RECV(":server 354 alice #xyz user2 host2");
CHECK_SRV("--", "[#xyz] user2 host2", "irc_354,irc_numeric,nick_server,log3");
RECV(":server 354 alice #xyz user2 host2 server");
CHECK_SRV("--", "[#xyz] user2 host2 server",
"irc_354,irc_numeric,nick_server,log3");
RECV(":server 354 alice #xyz user2 host2 server bob");
CHECK_SRV("--", "[#xyz] user2 host2 server bob",
"irc_354,irc_numeric,nick_server,log3");
RECV(":server 354 alice #xyz user2 host2 server bob *");
CHECK_SRV("--", "[#xyz] user2 host2 server bob *",
"irc_354,irc_numeric,nick_server,log3");
RECV(":server 354 alice #xyz user2 host2 server bob G@ 0");
CHECK_SRV("--", "[#xyz] user2 host2 server bob G@ 0",
"irc_354,irc_numeric,nick_server,log3");
RECV(":server 354 alice #xyz user2 host2 server bob H@ 0 account");
CHECK_SRV("--", "[#xyz] bob [account] (user2@host2) H@ 0 ()",
"irc_354,irc_numeric,nick_server,log3");
RECV(":server 354 alice #xyz user2 host2 server bob G@ 0 account "
":real name");
CHECK_SRV("--", "[#xyz] bob [account] (user2@host2) G@ 0 (real name)",
"irc_354,irc_numeric,nick_server,log3");
hashtable_remove (ptr_server->cap_list, "account-notify");
}
/*
* Tests functions:
* irc_protocol_get_string_channel_nicks
* irc_protocol_get_string_channel_nicks_count
* irc_protocol_cb_366 (end of /names list)
*/
TEST(IrcProtocolWithServer, 366)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 366");
CHECK_ERROR_PARAMS("366", 0, 3);
RECV(":server 366 alice");
CHECK_ERROR_PARAMS("366", 1, 3);
RECV(":server 366 alice #test");
CHECK_ERROR_PARAMS("366", 2, 3);
RECV(":server 366 alice #test end");
CHECK_CHAN("--", "Channel #test: 1 nick (0 ops, 0 voiced, 1 regular)",
"irc_366,irc_numeric,nick_server,log3");
RECV(":server 366 alice #test : \002End of /NAMES list ");
CHECK_CHAN("--", "Channel #test: 1 nick (0 ops, 0 voiced, 1 regular)",
"irc_366,irc_numeric,nick_server,log3");
RECV(":server 353 alice = #test :bob");
RECV(":server 366 alice #test :End of /NAMES list");
CHECK_CHAN("--", "Channel #test: 2 nicks (0 ops, 0 voiced, 2 regular)",
"irc_366,irc_numeric,nick_server,log3");
RECV(":server 353 alice = #test :@carol");
RECV(":server 366 alice #test :End of /NAMES list");
CHECK_CHAN("--", "Channel #test: 3 nicks (1 op, 0 voiced, 2 regular)",
"irc_366,irc_numeric,nick_server,log3");
RECV(":server 353 alice = #test :+dan!user@host");
RECV(":server 366 alice #test :End of /NAMES list");
CHECK_CHAN("--", "Channel #test: 4 nicks (1 op, 1 voiced, 2 regular)",
"irc_366,irc_numeric,nick_server,log3");
RECV(":server 353 alice = #test :@evans");
RECV(":server 366 alice #test :End of /NAMES list");
CHECK_CHAN("--", "Channel #test: 5 nicks (2 ops, 1 voiced, 2 regular)",
"irc_366,irc_numeric,nick_server,log3");
RECV(":server 353 alice = #test :+fred");
RECV(":server 366 alice #test :End of /NAMES list");
CHECK_CHAN("--", "Channel #test: 6 nicks (2 ops, 2 voiced, 2 regular)",
"irc_366,irc_numeric,nick_server,log3");
RECV(":server 353 alice = #test :greg");
RECV(":server 366 alice #test :End of /NAMES list");
CHECK_CHAN("--", "Channel #test: 7 nicks (2 ops, 2 voiced, 3 regular)",
"irc_366,irc_numeric,nick_server,log3");
RECV(":server 005 alice " IRC_MSG_005 " :are supported");
RECV(":server 353 alice = #test :%harry");
RECV(":server 366 alice #test :End of /NAMES list");
CHECK_CHAN("--",
"Channel #test: 8 nicks (2 ops, 1 halfop, 2 voiced, 3 regular)",
"irc_366,irc_numeric,nick_server,log3");
RECV(":server 353 alice = #test :%ian");
RECV(":server 366 alice #test :End of /NAMES list");
CHECK_CHAN("--",
"Channel #test: 9 nicks (2 ops, 2 halfops, 2 voiced, 3 regular)",
"irc_366,irc_numeric,nick_server,log3");
RECV(":server 005 alice PREFIX=(qaohv)~&@%+ :are supported");
RECV(":server 353 alice = #test :~jessica");
RECV(":server 366 alice #test :End of /NAMES list");
CHECK_CHAN(
"--",
"Channel #test: 10 nicks (1 owner, 0 admins, 2 ops, 2 halfops, 2 voiced, 3 regular)",
"irc_366,irc_numeric,nick_server,log3");
RECV(":server 353 alice = #test :&karl");
RECV(":server 366 alice #test :End of /NAMES list");
CHECK_CHAN(
"--",
"Channel #test: 11 nicks (1 owner, 1 admin, 2 ops, 2 halfops, 2 voiced, 3 regular)",
"irc_366,irc_numeric,nick_server,log3");
RECV(":server 353 alice = #test :&mike");
RECV(":server 366 alice #test :End of /NAMES list");
CHECK_CHAN(
"--",
"Channel #test: 12 nicks (1 owner, 2 admins, 2 ops, 2 halfops, 2 voiced, 3 regular)",
"irc_366,irc_numeric,nick_server,log3");
RECV(":server 353 alice = #test :~olivia");
RECV(":server 366 alice #test :End of /NAMES list");
CHECK_CHAN(
"--",
"Channel #test: 13 nicks (2 owners, 2 admins, 2 ops, 2 halfops, 2 voiced, 3 regular)",
"irc_366,irc_numeric,nick_server,log3");
RECV(":server 005 alice PREFIX=(zqaohv)?~&@%+ :are supported");
RECV(":server 353 alice = #test :?peggy");
RECV(":server 366 alice #test :End of /NAMES list");
CHECK_CHAN(
"--",
"Channel #test: 14 nicks (1 +z, 2 owners, 2 admins, 2 ops, 2 halfops, 2 voiced, 3 regular)",
"irc_366,irc_numeric,nick_server,log3");
RECV(":server 353 alice = #test :?robert");
RECV(":server 366 alice #test :End of /NAMES list");
CHECK_CHAN(
"--",
"Channel #test: 15 nicks (2 +z, 2 owners, 2 admins, 2 ops, 2 halfops, 2 voiced, 3 regular)",
"irc_366,irc_numeric,nick_server,log3");
/* channel not found */
RECV(":server 366 alice #xyz end");
CHECK_SRV("--", "#xyz: end", "irc_366,irc_numeric,nick_server,log3");
RECV(":server 366 alice #xyz : End of /NAMES list ");
CHECK_SRV("--", "#xyz: End of /NAMES list ",
"irc_366,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_367 (banlist)
*/
TEST(IrcProtocolWithServer, 367)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 367");
CHECK_ERROR_PARAMS("367", 0, 3);
RECV(":server 367 alice");
CHECK_ERROR_PARAMS("367", 1, 3);
RECV(":server 367 alice #test");
CHECK_ERROR_PARAMS("367", 2, 3);
RECV(":server 367 alice #test nick1!user1@host1_\00304red");
CHECK_CHAN("--", "[#test] [1] nick1!user1@host1_red banned",
"irc_367,irc_numeric,nick_server,log3");
RECV(":server 367 alice #test nick1!user1_\00304red@host1_\00304red "
"nick2!user2_\00304red@host2_\00304red ");
CHECK_CHAN("--",
"[#test] [2] nick1!user1_red@host1_red banned by nick2 (user2_red@host2_red)",
"irc_367,irc_numeric,nick_server,log3");
RECV(":server 367 alice #test nick1!user1_\00304red@host1_\00304red "
"nick2!user2_\00304red@host2_\00304red 1205585109 ");
CHECK_CHAN("--",
"[#test] [3] nick1!user1_red@host1_red banned "
"by nick2 (user2_red@host2_red) on Sat, 15 Mar 2008 12:45:09",
"irc_367,irc_numeric,nick_server,log3");
/* channel not found */
RECV(":server 367 alice #xyz nick1!user1_\00304red@host1_\00304red");
CHECK_SRV("--", "[#xyz] nick1!user1_red@host1_red banned",
"irc_367,irc_numeric,nick_server,log3");
RECV(":server 367 alice #xyz nick1!user1_\00304red@host1_\00304red "
"nick2!user2_\00304red@host2_\00304red");
CHECK_SRV("--", "[#xyz] nick1!user1_red@host1_red banned by nick2 (user2_red@host2_red)",
"irc_367,irc_numeric,nick_server,log3");
RECV(":server 367 alice #xyz nick1!user1_\00304red@host1_\00304red "
"nick2!user2_\00304red@host2_\00304red 1205585109");
CHECK_SRV("--", "[#xyz] nick1!user1_red@host1_red banned by nick2 (user2_red@host2_red) "
"on Sat, 15 Mar 2008 12:45:09",
"irc_367,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_368 (end of banlist)
*/
TEST(IrcProtocolWithServer, 368)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 368");
CHECK_ERROR_PARAMS("368", 0, 2);
RECV(":server 368 alice");
CHECK_ERROR_PARAMS("368", 1, 2);
RECV(":server 368 alice #test");
CHECK_CHAN("--", "[#test]", "irc_368,irc_numeric,nick_server,log3");
RECV(":server 368 alice #test end");
CHECK_CHAN("--", "[#test] end", "irc_368,irc_numeric,nick_server,log3");
RECV(":server 368 alice #test : \002End of Channel Ban List ");
CHECK_CHAN("--", "[#test] End of Channel Ban List ",
"irc_368,irc_numeric,nick_server,log3");
/* channel not found */
RECV(":server 368 alice #xyz");
CHECK_SRV("--", "[#xyz]", "irc_368,irc_numeric,nick_server,log3");
RECV(":server 368 alice #xyz end");
CHECK_SRV("--", "[#xyz] end", "irc_368,irc_numeric,nick_server,log3");
RECV(":server 368 alice #xyz :\002End of Channel Ban List");
CHECK_SRV("--", "[#xyz] End of Channel Ban List",
"irc_368,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_401 (no such nick/channel)
*/
TEST(IrcProtocolWithServer, 401)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 401");
CHECK_ERROR_PARAMS("401", 0, 2);
RECV(":server 401 alice");
CHECK_ERROR_PARAMS("401", 1, 2);
RECV(":server 401 alice bob");
CHECK_SRV("--", "bob", "irc_401,irc_numeric,nick_server,log3");
RECV(":server 401 alice bob : \002No such nick/channel ");
CHECK_SRV("--", "bob: No such nick/channel ",
"irc_401,irc_numeric,nick_server,log3");
RECV(":server 401 alice #unknown :\002No such nick/channel");
CHECK_SRV("--", "#unknown: No such nick/channel",
"irc_401,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_402 (no such server)
*/
TEST(IrcProtocolWithServer, 402)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 402");
CHECK_ERROR_PARAMS("402", 0, 2);
RECV(":server 402 alice");
CHECK_ERROR_PARAMS("402", 1, 2);
RECV(":server 402 alice server");
CHECK_SRV("--", "server", "irc_402,irc_numeric,nick_server,log3");
RECV(":server 402 alice server : \002No such server ");
CHECK_SRV("--", "server: No such server ",
"irc_402,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_403 (no such channel)
*/
TEST(IrcProtocolWithServer, 403)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 403");
CHECK_ERROR_PARAMS("403", 0, 2);
RECV(":server 403 alice");
CHECK_ERROR_PARAMS("403", 1, 2);
RECV(":server 403 alice #test2");
CHECK_SRV("--", "#test2", "irc_403,irc_numeric,nick_server,log3");
RECV(":server 403 alice #test2 : \002No such channel ");
CHECK_SRV("--", "#test2: No such channel ",
"irc_403,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_404 (cannot send to channel)
*/
TEST(IrcProtocolWithServer, 404)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 404");
CHECK_ERROR_PARAMS("404", 0, 2);
RECV(":server 404 alice");
CHECK_ERROR_PARAMS("404", 1, 2);
RECV(":server 404 alice #test");
CHECK_SRV("--", "#test", "irc_404,irc_numeric,nick_server,log3");
RECV(":server 404 alice #test : \002Cannot send to channel ");
CHECK_CHAN("--", "#test: Cannot send to channel ",
"irc_404,irc_numeric,nick_server,log3");
RECV(":server 404 alice #test2 :\002Cannot send to channel");
CHECK_SRV("--", "#test2: Cannot send to channel",
"irc_404,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_405 (too many channels)
*/
TEST(IrcProtocolWithServer, 405)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 405");
CHECK_ERROR_PARAMS("405", 0, 2);
RECV(":server 405 alice");
CHECK_ERROR_PARAMS("405", 1, 2);
RECV(":server 405 alice #test2");
CHECK_SRV("--", "#test2", "irc_405,irc_numeric,nick_server,log3");
RECV(":server 405 alice #test2 : \002You have joined too many channels ");
CHECK_SRV("--", "#test2: You have joined too many channels ",
"irc_405,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_406 (was no such nick)
*/
TEST(IrcProtocolWithServer, 406)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 406");
CHECK_ERROR_PARAMS("406", 0, 2);
RECV(":server 406 alice");
CHECK_ERROR_PARAMS("406", 1, 2);
RECV(":server 406 alice bob");
CHECK_SRV("--", "bob", "irc_406,irc_numeric,nick_server,log3");
RECV(":server 406 alice bob : \002There was no such nick ");
CHECK_SRV("--", "bob: There was no such nick ",
"irc_406,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_407 (too many targets)
*/
TEST(IrcProtocolWithServer, 407)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 407");
CHECK_ERROR_PARAMS("407", 0, 2);
RECV(":server 407 alice");
CHECK_ERROR_PARAMS("407", 1, 2);
RECV(":server 407 alice bob@host");
CHECK_SRV("--", "bob@host", "irc_407,irc_numeric,nick_server,log3");
RECV(":server 407 alice bob@host : \002Duplicate recipients. No message delivered ");
CHECK_SRV("--", "bob@host: Duplicate recipients. No message delivered ",
"irc_407,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_409 (no origin)
*/
TEST(IrcProtocolWithServer, 409)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 409");
CHECK_ERROR_PARAMS("409", 0, 2);
RECV(":server 409 alice");
CHECK_ERROR_PARAMS("409", 1, 2);
RECV(":server 409 alice : \002No origin specified ");
CHECK_SRV("--", " No origin specified ",
"irc_409,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_411 (no recipient)
*/
TEST(IrcProtocolWithServer, 411)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 411");
CHECK_ERROR_PARAMS("411", 0, 2);
RECV(":server 411 alice");
CHECK_ERROR_PARAMS("411", 1, 2);
RECV(":server 411 alice : \002No recipient given (PRIVMSG) ");
CHECK_SRV("--", " No recipient given (PRIVMSG) ",
"irc_411,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_412 (no text to send)
*/
TEST(IrcProtocolWithServer, 412)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 412");
CHECK_ERROR_PARAMS("412", 0, 2);
RECV(":server 412 alice");
CHECK_ERROR_PARAMS("412", 1, 2);
RECV(":server 412 alice : \002No text to send ");
CHECK_SRV("--", " No text to send ",
"irc_412,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_413 (no toplevel)
*/
TEST(IrcProtocolWithServer, 413)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 413");
CHECK_ERROR_PARAMS("413", 0, 2);
RECV(":server 413 alice");
CHECK_ERROR_PARAMS("413", 1, 2);
RECV(":server 413 alice mask");
CHECK_SRV("--", "mask", "irc_413,irc_numeric,nick_server,log3");
RECV(":server 413 alice mask : \002No toplevel domain specified ");
CHECK_SRV("--", "mask: No toplevel domain specified ",
"irc_413,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_414 (wildcard in toplevel domain)
*/
TEST(IrcProtocolWithServer, 414)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 414");
CHECK_ERROR_PARAMS("414", 0, 2);
RECV(":server 414 alice");
CHECK_ERROR_PARAMS("414", 1, 2);
RECV(":server 414 alice mask");
CHECK_SRV("--", "mask", "irc_414,irc_numeric,nick_server,log3");
RECV(":server 414 alice mask : \002Wildcard in toplevel domain ");
CHECK_SRV("--", "mask: Wildcard in toplevel domain ",
"irc_414,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_415 (cannot send to channel)
*/
TEST(IrcProtocolWithServer, 415)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 415");
CHECK_ERROR_PARAMS("415", 0, 2);
RECV(":server 415 alice");
CHECK_ERROR_PARAMS("415", 1, 2);
RECV(":server 415 alice #test");
CHECK_SRV("--", "#test", "irc_415,irc_numeric,nick_server,log3");
RECV(":server 415 alice #test : \002Cannot send message to channel (+R) ");
CHECK_CHAN("--", "#test: Cannot send message to channel (+R) ",
"irc_415,irc_numeric,nick_server,log3");
RECV(":server 415 alice #test2 :\002Cannot send message to channel (+R)");
CHECK_SRV("--", "#test2: Cannot send message to channel (+R)",
"irc_415,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_421 (unknown command)
*/
TEST(IrcProtocolWithServer, 421)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 421");
CHECK_ERROR_PARAMS("421", 0, 2);
RECV(":server 421 alice");
CHECK_ERROR_PARAMS("421", 1, 2);
RECV(":server 421 alice UNKNOWN");
CHECK_SRV("--", "UNKNOWN", "irc_421,irc_numeric,nick_server,log3");
RECV(":server 421 alice UNKNOWN : \002Unknown command ");
CHECK_SRV("--", "UNKNOWN: Unknown command ",
"irc_421,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_422 (MOTD is missing)
*/
TEST(IrcProtocolWithServer, 422)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 422");
CHECK_ERROR_PARAMS("422", 0, 2);
RECV(":server 422 alice");
CHECK_ERROR_PARAMS("422", 1, 2);
RECV(":server 422 alice : \002MOTD file is missing ");
CHECK_SRV("--", " MOTD file is missing ",
"irc_422,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_423 (no administrative info)
*/
TEST(IrcProtocolWithServer, 423)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 423");
CHECK_ERROR_PARAMS("423", 0, 2);
RECV(":server 423 alice");
CHECK_ERROR_PARAMS("423", 1, 2);
RECV(":server 423 alice server");
CHECK_SRV("--", "server", "irc_423,irc_numeric,nick_server,log3");
RECV(":server 423 alice server : \002No administrative info available ");
CHECK_SRV("--", "server: No administrative info available ",
"irc_423,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_424 (file error)
*/
TEST(IrcProtocolWithServer, 424)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 424");
CHECK_ERROR_PARAMS("424", 0, 2);
RECV(":server 424 alice");
CHECK_ERROR_PARAMS("424", 1, 2);
RECV(":server 424 alice : \002File error doing read on /path/to/file ");
CHECK_SRV("--", " File error doing read on /path/to/file ",
"irc_424,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_431 (no nickname given)
*/
TEST(IrcProtocolWithServer, 431)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 431");
CHECK_ERROR_PARAMS("431", 0, 2);
RECV(":server 431 alice");
CHECK_ERROR_PARAMS("431", 1, 2);
RECV(":server 431 alice : \002No nickname given ");
CHECK_SRV("--", " No nickname given ",
"irc_431,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_432 (erroneous nickname, not connected)
*/
TEST(IrcProtocolWithServer, 432_not_connected)
{
RECV(":server 432 * alice error");
CHECK_SRV("--", "* alice error", "");
CHECK_SRV("=!=",
"irc: nickname \"nick1\" is invalid, trying nickname \"nick2\"",
"");
RECV(":server 432 * :alice error");
CHECK_SRV("--", "* alice error", "");
CHECK_SRV("=!=",
"irc: nickname \"nick2\" is invalid, trying nickname \"nick3\"",
"");
RECV(":server 432 * alice : \002Erroneous Nickname ");
CHECK_SRV("--", "* alice Erroneous Nickname ", "");
CHECK_SRV("=!=",
"irc: nickname \"nick3\" is invalid, trying nickname \"nick1_\"",
"");
RECV(":server 432 * alice1 :\002Erroneous Nickname");
CHECK_SRV("--", "* alice1 Erroneous Nickname", "");
CHECK_SRV("=!=",
"irc: nickname \"nick1_\" is invalid, "
"trying nickname \"nick1__\"",
"");
}
/*
* Tests functions:
* irc_protocol_cb_432 (erroneous nickname, connected)
*/
TEST(IrcProtocolWithServer, 432_connected)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 432");
CHECK_ERROR_PARAMS("432", 0, 2);
RECV(":server 432 alice");
CHECK_ERROR_PARAMS("432", 1, 2);
RECV(":server 432 alice test%+");
CHECK_SRV("--", "test%+", "irc_432,irc_numeric,nick_server,log3");
RECV(":server 432 alice test%+ error");
CHECK_SRV("--", "test%+: error", "irc_432,irc_numeric,nick_server,log3");
RECV(":server 432 alice test%+ : \002Erroneous Nickname ");
CHECK_SRV("--", "test%+: Erroneous Nickname ",
"irc_432,irc_numeric,nick_server,log3");
/*
* special case: erroneous nick is a channel: check that the message is
* still displayed on the server buffer
*/
RECV(":server 432 alice #test : \002Erroneous Nickname ");
CHECK_SRV("--", "#test: Erroneous Nickname ",
"irc_432,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_433 (nickname already in use, not connected)
*/
TEST(IrcProtocolWithServer, 433_not_connected)
{
RECV(":server 433 * alice error");
CHECK_SRV("--",
"irc: nickname \"nick1\" is already in use, "
"trying nickname \"nick2\"",
"");
RECV(":server 433 * alice : Nickname is already in use. ");
CHECK_SRV("--",
"irc: nickname \"nick2\" is already in use, "
"trying nickname \"nick3\"",
"");
RECV(":server 433 * alice1 :Nickname is already in use.");
CHECK_SRV("--",
"irc: nickname \"nick3\" is already in use, "
"trying nickname \"nick1_\"",
"");
}
/*
* Tests functions:
* irc_protocol_cb_433 (nickname already in use, connected)
*/
TEST(IrcProtocolWithServer, 433_connected)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 433");
CHECK_ERROR_PARAMS("433", 0, 2);
RECV(":server 433 alice");
CHECK_ERROR_PARAMS("433", 1, 2);
RECV(":server 433 alice test");
CHECK_SRV("--", "test", "irc_433,irc_numeric,nick_server,log3");
RECV(":server 433 alice test error");
CHECK_SRV("--", "test: error", "irc_433,irc_numeric,nick_server,log3");
RECV(":server 433 alice test : \002Nickname is already in use. ");
CHECK_SRV("--", "test: Nickname is already in use. ",
"irc_433,irc_numeric,nick_server,log3");
/*
* special case: nickname already used looks like a channel (it should
* never happen in practice): check that the message is still displayed
* on the server buffer
*/
RECV(":server 433 alice #test : \002Nickname is already in use. ");
CHECK_SRV("--", "#test: Nickname is already in use. ",
"irc_433,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_436 (nickname collision)
*/
TEST(IrcProtocolWithServer, 436)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 436");
CHECK_ERROR_PARAMS("436", 0, 2);
RECV(":server 436 alice");
CHECK_ERROR_PARAMS("436", 1, 2);
RECV(":server 436 alice bob");
CHECK_SRV("--", "bob", "irc_436,irc_numeric,nick_server,log3");
RECV(":server 436 alice bob error");
CHECK_SRV("--", "bob: error", "irc_436,irc_numeric,nick_server,log3");
RECV(":server 436 alice bob : \002Nickname collision KILL ");
CHECK_SRV("--", "bob: Nickname collision KILL ",
"irc_436,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_437 (nick/channel temporarily unavailable, not connected)
*/
TEST(IrcProtocolWithServer, 437_not_connected)
{
RECV(":server 437 * alice error");
CHECK_SRV("--", "* alice error", "irc_437,irc_numeric,nick_server,log3");
RECV(":server 437 * alice : \002Nick/channel is temporarily unavailable ");
CHECK_SRV("--", "* alice Nick/channel is temporarily unavailable ",
"irc_437,irc_numeric,nick_server,log3");
RECV(":server 437 * alice1 :\002Nick/channel is temporarily unavailable");
CHECK_SRV("--", "* alice1 Nick/channel is temporarily unavailable",
"irc_437,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_437 (nick/channel temporarily unavailable, connected)
*/
TEST(IrcProtocolWithServer, 437_connected)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 437");
CHECK_ERROR_PARAMS("437", 0, 2);
RECV(":server 437 alice");
CHECK_ERROR_PARAMS("437", 1, 2);
RECV(":server 437 * alice");
CHECK_SRV("--", "* alice", "irc_437,irc_numeric,nick_server,log3");
RECV(":server 437 * alice error");
CHECK_SRV("--", "* alice error", "irc_437,irc_numeric,nick_server,log3");
RECV(":server 437 * alice : \002Nick/channel is temporarily unavailable ");
CHECK_SRV("--", "* alice Nick/channel is temporarily unavailable ",
"irc_437,irc_numeric,nick_server,log3");
RECV(":server 437 alice #test :\002Cannot change nickname while banned on channel");
CHECK_SRV("--", "#test: Cannot change nickname while banned on channel",
"irc_437,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_438 (not authorized to change nickname)
*/
TEST(IrcProtocolWithServer, 438)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 438");
CHECK_ERROR_PARAMS("438", 0, 2);
RECV(":server 438 alice");
CHECK_ERROR_PARAMS("438", 1, 2);
RECV(":server 438 alice alice2");
CHECK_SRV("--", "alice alice2", "irc_438,irc_numeric,nick_server,log3");
RECV(":server 438 alice alice2 error");
CHECK_SRV("--", "error (alice => alice2)",
"irc_438,irc_numeric,nick_server,log3");
RECV(":server 438 alice alice2 : \002Nick change too fast. "
"Please wait 30 seconds. ");
CHECK_SRV("--",
" Nick change too fast. Please wait 30 seconds. (alice => alice2)",
"irc_438,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_441 (user not in channel)
*/
TEST(IrcProtocolWithServer, 441)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 441");
CHECK_ERROR_PARAMS("441", 0, 2);
RECV(":server 441 alice");
CHECK_ERROR_PARAMS("441", 1, 2);
RECV(":server 441 alice bob");
CHECK_SRV("--", "bob", "irc_441,irc_numeric,nick_server,log3");
RECV(":server 441 alice bob #test2");
CHECK_SRV("--", "bob: #test2", "irc_441,irc_numeric,nick_server,log3");
RECV(":server 441 alice bob #test2 : \002They aren't on that channel ");
CHECK_SRV("--", "bob: #test2 They aren't on that channel ",
"irc_441,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_442 (not on channel)
*/
TEST(IrcProtocolWithServer, 442)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 442");
CHECK_ERROR_PARAMS("442", 0, 2);
RECV(":server 442 alice");
CHECK_ERROR_PARAMS("442", 1, 2);
RECV(":server 442 alice #test2");
CHECK_SRV("--", "#test2", "irc_442,irc_numeric,nick_server,log3");
RECV(":server 442 alice #test2 : \002You're not on that channel ");
CHECK_SRV("--", "#test2: You're not on that channel ",
"irc_442,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_443 (user already on channel)
*/
TEST(IrcProtocolWithServer, 443)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 443");
CHECK_ERROR_PARAMS("443", 0, 2);
RECV(":server 443 alice");
CHECK_ERROR_PARAMS("443", 1, 2);
RECV(":server 443 alice bob");
CHECK_SRV("--", "bob", "irc_443,irc_numeric,nick_server,log3");
RECV(":server 443 alice bob #test2");
CHECK_SRV("--", "bob: #test2", "irc_443,irc_numeric,nick_server,log3");
RECV(":server 443 alice bob #test2 : \002is already on channel ");
CHECK_SRV("--", "bob: #test2 is already on channel ",
"irc_443,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_444 (user not logged in)
*/
TEST(IrcProtocolWithServer, 444)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 444");
CHECK_ERROR_PARAMS("444", 0, 2);
RECV(":server 444 alice");
CHECK_ERROR_PARAMS("444", 1, 2);
RECV(":server 444 alice bob");
CHECK_SRV("--", "bob", "irc_444,irc_numeric,nick_server,log3");
RECV(":server 444 alice bob error");
CHECK_SRV("--", "bob: error", "irc_444,irc_numeric,nick_server,log3");
RECV(":server 444 alice bob : \002User not logged in ");
CHECK_SRV("--", "bob: User not logged in ",
"irc_444,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_445 (SUMMON has been disabled)
*/
TEST(IrcProtocolWithServer, 445)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 445");
CHECK_ERROR_PARAMS("445", 0, 2);
RECV(":server 445 alice");
CHECK_ERROR_PARAMS("445", 1, 2);
RECV(":server 445 alice : \002SUMMON has been disabled ");
CHECK_SRV("--", " SUMMON has been disabled ",
"irc_445,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_446 (USERS has been disabled)
*/
TEST(IrcProtocolWithServer, 446)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 446");
CHECK_ERROR_PARAMS("446", 0, 2);
RECV(":server 446 alice");
CHECK_ERROR_PARAMS("446", 1, 2);
RECV(":server 446 alice : \002USERS has been disabled ");
CHECK_SRV("--", " USERS has been disabled ",
"irc_446,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_451 (you are not registered)
*/
TEST(IrcProtocolWithServer, 451)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 451");
CHECK_ERROR_PARAMS("451", 0, 2);
RECV(":server 451 alice");
CHECK_ERROR_PARAMS("451", 1, 2);
RECV(":server 451 alice : \002You have not registered ");
CHECK_SRV("--", " You have not registered ",
"irc_451,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_461 (not enough parameters)
*/
TEST(IrcProtocolWithServer, 461)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 461");
CHECK_ERROR_PARAMS("461", 0, 2);
RECV(":server 461 alice");
CHECK_ERROR_PARAMS("461", 1, 2);
RECV(":server 461 alice PRIVMSG");
CHECK_SRV("--", "PRIVMSG", "irc_461,irc_numeric,nick_server,log3");
RECV(":server 461 alice PRIVMSG : \002Not enough parameters ");
CHECK_SRV("--", "PRIVMSG: Not enough parameters ",
"irc_461,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_462 (you may not register)
*/
TEST(IrcProtocolWithServer, 462)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 462");
CHECK_ERROR_PARAMS("462", 0, 2);
RECV(":server 462 alice");
CHECK_ERROR_PARAMS("462", 1, 2);
RECV(":server 462 alice : \002You may not reregister ");
CHECK_SRV("--", " You may not reregister ",
"irc_462,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_463 (host not privileged)
*/
TEST(IrcProtocolWithServer, 463)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 463");
CHECK_ERROR_PARAMS("463", 0, 2);
RECV(":server 463 alice");
CHECK_ERROR_PARAMS("463", 1, 2);
RECV(":server 463 alice : \002Your host isn't among the privileged ");
CHECK_SRV("--", " Your host isn't among the privileged ",
"irc_463,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_464 (password incorrect)
*/
TEST(IrcProtocolWithServer, 464)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 464");
CHECK_ERROR_PARAMS("464", 0, 2);
RECV(":server 464 alice");
CHECK_ERROR_PARAMS("464", 1, 2);
RECV(":server 464 alice : \002Password incorrect ");
CHECK_SRV("--", " Password incorrect ",
"irc_464,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_465 (banned from this server)
*/
TEST(IrcProtocolWithServer, 465)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 465");
CHECK_ERROR_PARAMS("465", 0, 2);
RECV(":server 465 alice");
CHECK_ERROR_PARAMS("465", 1, 2);
RECV(":server 465 alice : \002You are banned from this server ");
CHECK_SRV("--", " You are banned from this server ",
"irc_465,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_467 (channel key already set)
*/
TEST(IrcProtocolWithServer, 467)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 467");
CHECK_ERROR_PARAMS("467", 0, 2);
RECV(":server 467 alice");
CHECK_ERROR_PARAMS("467", 1, 2);
RECV(":server 467 alice #test2");
CHECK_SRV("--", "#test2", "irc_467,irc_numeric,nick_server,log3");
RECV(":server 467 alice #test2 : \002Channel key already set ");
CHECK_SRV("--", "#test2: Channel key already set ",
"irc_467,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_470 (forwarding to another channel)
*/
TEST(IrcProtocolWithServer, 470)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 470");
CHECK_ERROR_PARAMS("470", 0, 2);
RECV(":server 470 alice");
CHECK_ERROR_PARAMS("470", 1, 2);
RECV(":server 470 alice #test");
CHECK_SRV("--", "#test", "irc_470,irc_numeric,nick_server,log3");
RECV(":server 470 alice #test #test2");
CHECK_SRV("--", "#test: #test2", "irc_470,irc_numeric,nick_server,log3");
RECV(":server 470 alice #test #test2 forwarding");
CHECK_SRV("--", "#test: #test2 forwarding",
"irc_470,irc_numeric,nick_server,log3");
RECV(":server 470 alice #test #test2 : \002Forwarding to another channel ");
CHECK_SRV("--", "#test: #test2 Forwarding to another channel ",
"irc_470,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_471 (channel is already full)
*/
TEST(IrcProtocolWithServer, 471)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 471");
CHECK_ERROR_PARAMS("471", 0, 2);
RECV(":server 471 alice");
CHECK_ERROR_PARAMS("471", 1, 2);
RECV(":server 471 alice #test2");
CHECK_SRV("--", "#test2", "irc_471,irc_numeric,nick_server,log3");
RECV(":server 471 alice #test2 : \002Cannot join channel (+l) ");
CHECK_SRV("--", "#test2: Cannot join channel (+l) ",
"irc_471,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_472 (unknown mode char to me)
*/
TEST(IrcProtocolWithServer, 472)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 472");
CHECK_ERROR_PARAMS("472", 0, 2);
RECV(":server 472 alice");
CHECK_ERROR_PARAMS("472", 1, 2);
RECV(":server 472 alice x");
CHECK_SRV("--", "x", "irc_472,irc_numeric,nick_server,log3");
RECV(":server 472 alice x : \002is unknown mode char to me ");
CHECK_SRV("--", "x: is unknown mode char to me ",
"irc_472,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_473 (cannot join (invite only))
*/
TEST(IrcProtocolWithServer, 473)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 473");
CHECK_ERROR_PARAMS("473", 0, 2);
RECV(":server 473 alice");
CHECK_ERROR_PARAMS("473", 1, 2);
RECV(":server 473 alice #test2");
CHECK_SRV("--", "#test2", "irc_473,irc_numeric,nick_server,log3");
RECV(":server 473 alice #test2 : \002Cannot join channel (+i) ");
CHECK_SRV("--", "#test2: Cannot join channel (+i) ",
"irc_473,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_474 (cannot join (banned))
*/
TEST(IrcProtocolWithServer, 474)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 474");
CHECK_ERROR_PARAMS("474", 0, 2);
RECV(":server 474 alice");
CHECK_ERROR_PARAMS("474", 1, 2);
RECV(":server 474 alice #test2");
CHECK_SRV("--", "#test2", "irc_474,irc_numeric,nick_server,log3");
RECV(":server 474 alice #test2 : \002Cannot join channel (+b) ");
CHECK_SRV("--", "#test2: Cannot join channel (+b) ",
"irc_474,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_475 (cannot join (bad key))
*/
TEST(IrcProtocolWithServer, 475)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 475");
CHECK_ERROR_PARAMS("475", 0, 2);
RECV(":server 475 alice");
CHECK_ERROR_PARAMS("475", 1, 2);
RECV(":server 475 alice #test2");
CHECK_SRV("--", "#test2", "irc_475,irc_numeric,nick_server,log3");
RECV(":server 475 alice #test2 : \002Cannot join channel (+k) ");
CHECK_SRV("--", "#test2: Cannot join channel (+k) ",
"irc_475,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_476 (bad channel mask)
*/
TEST(IrcProtocolWithServer, 476)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 476");
CHECK_ERROR_PARAMS("476", 0, 2);
RECV(":server 476 alice");
CHECK_ERROR_PARAMS("476", 1, 2);
RECV(":server 476 alice #test2");
CHECK_SRV("--", "#test2", "irc_476,irc_numeric,nick_server,log3");
RECV(":server 476 alice #test2 : \002Bad Channel Mask ");
CHECK_SRV("--", "#test2: Bad Channel Mask ",
"irc_476,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_477 (channel doesn't support modes)
*/
TEST(IrcProtocolWithServer, 477)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 477");
CHECK_ERROR_PARAMS("477", 0, 2);
RECV(":server 477 alice");
CHECK_ERROR_PARAMS("477", 1, 2);
RECV(":server 477 alice #test2");
CHECK_SRV("--", "#test2", "irc_477,irc_numeric,nick_server,log3");
RECV(":server 477 alice #test2 : \002Channel doesn't support modes ");
CHECK_SRV("--", "#test2: Channel doesn't support modes ",
"irc_477,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_481 (you're not an IRC operator)
*/
TEST(IrcProtocolWithServer, 481)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 481");
CHECK_ERROR_PARAMS("481", 0, 2);
RECV(":server 481 alice");
CHECK_ERROR_PARAMS("481", 1, 2);
RECV(":server 481 alice : \002Permission Denied- You're not an IRC operator ");
CHECK_SRV("--", " Permission Denied- You're not an IRC operator ",
"irc_481,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_482 (you're not channel operator)
*/
TEST(IrcProtocolWithServer, 482)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 482");
CHECK_ERROR_PARAMS("482", 0, 2);
RECV(":server 482 alice");
CHECK_ERROR_PARAMS("482", 1, 2);
RECV(":server 482 alice #test2");
CHECK_SRV("--", "#test2", "irc_482,irc_numeric,nick_server,log3");
RECV(":server 482 alice #test2 : \002You're not channel operator ");
CHECK_SRV("--", "#test2: You're not channel operator ",
"irc_482,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_483 (you can't kill a server!)
*/
TEST(IrcProtocolWithServer, 483)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 483");
CHECK_ERROR_PARAMS("483", 0, 2);
RECV(":server 483 alice");
CHECK_ERROR_PARAMS("483", 1, 2);
RECV(":server 483 alice : \002You cant kill a server! ");
CHECK_SRV("--", " You cant kill a server! ",
"irc_483,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_484 (your connection is restricted!)
*/
TEST(IrcProtocolWithServer, 484)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 484");
CHECK_ERROR_PARAMS("484", 0, 2);
RECV(":server 484 alice");
CHECK_ERROR_PARAMS("484", 1, 2);
RECV(":server 484 alice : \002Your connection is restricted! ");
CHECK_SRV("--", " Your connection is restricted! ",
"irc_484,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_485 (not the original channel operator)
*/
TEST(IrcProtocolWithServer, 485)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 485");
CHECK_ERROR_PARAMS("485", 0, 2);
RECV(":server 485 alice");
CHECK_ERROR_PARAMS("485", 1, 2);
RECV(":server 485 alice : \002You're not the original channel operator ");
CHECK_SRV("--", " You're not the original channel operator ",
"irc_485,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_491 (no O-lines for your host)
*/
TEST(IrcProtocolWithServer, 491)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 491");
CHECK_ERROR_PARAMS("491", 0, 2);
RECV(":server 491 alice");
CHECK_ERROR_PARAMS("491", 1, 2);
RECV(":server 491 alice : \002No O-lines for your host ");
CHECK_SRV("--", " No O-lines for your host ",
"irc_491,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_501 (unknown mode flag)
*/
TEST(IrcProtocolWithServer, 501)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 501");
CHECK_ERROR_PARAMS("501", 0, 2);
RECV(":server 501 alice");
CHECK_ERROR_PARAMS("501", 1, 2);
RECV(":server 501 alice : \002Unknown MODE flag ");
CHECK_SRV("--", " Unknown MODE flag ",
"irc_501,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_502 (can't change mode for other users)
*/
TEST(IrcProtocolWithServer, 502)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 502");
CHECK_ERROR_PARAMS("502", 0, 2);
RECV(":server 502 alice");
CHECK_ERROR_PARAMS("502", 1, 2);
RECV(":server 502 alice : \002Cant change mode for other users ");
CHECK_SRV("--", " Cant change mode for other users ",
"irc_502,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_524 (help not found)
*/
TEST(IrcProtocolWithServer, 524)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 524");
CHECK_ERROR_PARAMS("524", 0, 2);
RECV(":server 524 alice");
CHECK_ERROR_PARAMS("524", 1, 2);
RECV(":server 524 alice UNKNOWN");
CHECK_SRV("--", "UNKNOWN", "irc_524,irc_numeric,nick_server,log3");
RECV(":server 524 alice UNKNOWN : \002Help not found ");
CHECK_SRV("--", "UNKNOWN: Help not found ",
"irc_524,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_569 (whois, connecting from)
*/
TEST(IrcProtocolWithServer, 569)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 569");
CHECK_ERROR_PARAMS("569", 0, 2);
RECV(":server 569 alice");
CHECK_ERROR_PARAMS("569", 1, 2);
/* whois, connecting from (UnrealIRCd) */
RECV(":server 569 alice bob 12345 : \002is connecting from AS12345 [Hoster] ");
CHECK_SRV("--", "[bob] is connecting from AS12345 [Hoster] (12345)",
"irc_569,irc_numeric,nick_server,log3");
/* whois, connecting from (UnrealIRCd), no ASN */
RECV(":server 569 alice bob :\002is connecting from AS12345 [Hoster]");
CHECK_SRV("--", "[bob] is connecting from AS12345 [Hoster]",
"irc_569,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_704 (start of HELP/HELPOP)
*/
TEST(IrcProtocolWithServer, 704)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 704");
CHECK_ERROR_PARAMS("704", 0, 2);
RECV(":server 704 alice");
CHECK_ERROR_PARAMS("704", 1, 2);
RECV(":server 704 alice MODE");
CHECK_SRV("--", "MODE", "irc_704,irc_numeric,nick_server,log3");
RECV(":server 704 alice MODE "
": MODE <target> [<modestring> [<mode arguments>...]] ");
CHECK_SRV("--", "MODE: MODE <target> [<modestring> [<mode arguments>...]] ",
"irc_704,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_705 (body of HELP/HELPOP)
*/
TEST(IrcProtocolWithServer, 705)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 705");
CHECK_ERROR_PARAMS("705", 0, 2);
RECV(":server 705 alice");
CHECK_ERROR_PARAMS("705", 1, 2);
RECV(":server 705 alice MODE");
CHECK_SRV("--", "MODE", "irc_705,irc_numeric,nick_server,log3");
RECV(":server 705 alice MODE : \002Sets and removes modes from the given target. ");
CHECK_SRV("--", "MODE: Sets and removes modes from the given target. ",
"irc_705,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_706 (end of HELP/HELPOP)
*/
TEST(IrcProtocolWithServer, 706)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 706");
CHECK_ERROR_PARAMS("706", 0, 2);
RECV(":server 706 alice");
CHECK_ERROR_PARAMS("706", 1, 2);
RECV(":server 706 alice MODE");
CHECK_SRV("--", "MODE", "irc_706,irc_numeric,nick_server,log3");
RECV(":server 706 alice MODE : \002End of /HELPOP ");
CHECK_SRV("--", "MODE: End of /HELPOP ",
"irc_706,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_710 (knock: has asked for an invite)
*/
TEST(IrcProtocolWithServer, 710)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 710");
CHECK_ERROR_PARAMS("710", 0, 3);
RECV(":server 710 #test");
CHECK_ERROR_PARAMS("710", 1, 3);
RECV(":server 710 #test #test");
CHECK_ERROR_PARAMS("710", 2, 3);
RECV(":server 710 #test #test nick1!user1@host1");
CHECK_CHAN("--", "nick1 (user1@host1) has asked for an invite",
"irc_710,irc_numeric,notify_message,nick_nick1,host_user1@host1,log3");
RECV(":server 710 #test #test nick1!user1@host1 : \002has asked for an invite. ");
CHECK_CHAN("--", "nick1 (user1@host1) has asked for an invite. ",
"irc_710,irc_numeric,notify_message,nick_nick1,host_user1@host1,log3");
/* channel not found */
RECV(":server 710 #xyz #xyz nick1!user1@host1");
CHECK_ERROR_PARSE("710", ":server 710 #xyz #xyz nick1!user1@host1");
RECV(":server 710 #xyz #xyz nick1!user1@host1 : \002has asked for an invite. ");
CHECK_ERROR_PARSE("710", ":server 710 #xyz #xyz nick1!user1@host1 : \002has asked for an invite. ");
}
/*
* Tests functions:
* irc_protocol_cb_711 (knock: has been delivered)
*/
TEST(IrcProtocolWithServer, 711)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 711");
CHECK_ERROR_PARAMS("711", 0, 3);
RECV(":server 711 alice");
CHECK_ERROR_PARAMS("711", 1, 3);
RECV(":server 711 alice #test");
CHECK_ERROR_PARAMS("711", 2, 3);
RECV(":server 711 alice #test : \002Your KNOCK has been delivered. ");
CHECK_SRV("--", "#test: Your KNOCK has been delivered. ",
"irc_711,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_712 (knock: too many knocks)
*/
TEST(IrcProtocolWithServer, 712)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 712");
CHECK_ERROR_PARAMS("712", 0, 3);
RECV(":server 712 alice");
CHECK_ERROR_PARAMS("712", 1, 3);
RECV(":server 712 alice #test");
CHECK_ERROR_PARAMS("712", 2, 3);
RECV(":server 712 alice #test : \002Too many KNOCKs (channel). ");
CHECK_SRV("--", "#test: Too many KNOCKs (channel). ",
"irc_712,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_713 (knock: channel is open)
*/
TEST(IrcProtocolWithServer, 713)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 713");
CHECK_ERROR_PARAMS("713", 0, 3);
RECV(":server 713 alice");
CHECK_ERROR_PARAMS("713", 1, 3);
RECV(":server 713 alice #test");
CHECK_ERROR_PARAMS("713", 2, 3);
RECV(":server 713 alice #test : \002Channel is open. ");
CHECK_SRV("--", "#test: Channel is open. ",
"irc_713,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_714 (knock: already on that channel)
*/
TEST(IrcProtocolWithServer, 714)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 714");
CHECK_ERROR_PARAMS("714", 0, 3);
RECV(":server 714 alice");
CHECK_ERROR_PARAMS("714", 1, 3);
RECV(":server 714 alice #test");
CHECK_ERROR_PARAMS("714", 2, 3);
RECV(":server 714 alice #test : \002You are already on that channel. ");
CHECK_SRV("--", "#test: You are already on that channel. ",
"irc_714,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_716 (nick is in +g mode)
*/
TEST(IrcProtocolWithServer, 716)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 716");
CHECK_ERROR_PARAMS("716", 0, 2);
RECV(":server 716 alice");
CHECK_ERROR_PARAMS("716", 1, 2);
RECV(":server 716 alice bob : \002is in +g mode and must manually allow you to "
"message them. Your message was discarded. ");
CHECK_SRV("--",
"bob: is in +g mode and must manually allow you to message them. "
"Your message was discarded. ",
"irc_716,irc_numeric,nick_server,log3");
/* open private buffer */
RECV(":bob!user@host PRIVMSG alice :hi Alice!");
RECV(":server 716 alice bob : \002is in +g mode and must manually allow you to "
"message them. Your message was discarded. ");
CHECK_PV("bob", "--",
"bob: is in +g mode and must manually allow you to message them. "
"Your message was discarded. ",
"irc_716,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_717 (nick has been informed that you messaged them)
*/
TEST(IrcProtocolWithServer, 717)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 717");
CHECK_ERROR_PARAMS("717", 0, 2);
RECV(":server 717 alice");
CHECK_ERROR_PARAMS("717", 1, 2);
RECV(":server 717 alice bob : \002has been informed that you messaged them. ");
CHECK_SRV("--", "bob: has been informed that you messaged them. ",
"irc_717,irc_numeric,nick_server,log3");
/* open private buffer */
RECV(":bob!user@host PRIVMSG alice :hi Alice!");
RECV(":server 717 alice bob : \002has been informed that you messaged them. ");
CHECK_PV("bob", "--",
"bob: has been informed that you messaged them. ",
"irc_717,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_728 (quietlist)
*/
TEST(IrcProtocolWithServer, 728)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 728");
CHECK_ERROR_PARAMS("728", 0, 4);
RECV(":server 728 alice");
CHECK_ERROR_PARAMS("728", 1, 4);
RECV(":server 728 alice #test");
CHECK_ERROR_PARAMS("728", 2, 4);
RECV(":server 728 alice #test q");
CHECK_ERROR_PARAMS("728", 3, 4);
RECV(":server 728 alice #test q nick1!user1_\00304red@host1_\00304red");
CHECK_CHAN("--", "[#test] nick1!user1_red@host1_red quieted",
"irc_728,irc_numeric,nick_server,log3");
RECV(":server 728 alice #test q nick1!user1_\00304red@host1_\00304red "
"alice!user_\00304red@host_\00304red");
CHECK_CHAN("--", "[#test] nick1!user1_red@host1_red quieted by alice (user_red@host_red)",
"irc_728,irc_numeric,nick_server,log3");
RECV(":server 728 alice #test q nick1!user1_\00304red@host1_\00304red "
"alice!user_\00304red@host_\00304red 1351350090 ");
CHECK_CHAN("--",
"[#test] nick1!user1_red@host1_red quieted by alice (user_red@host_red) "
"on Sat, 27 Oct 2012 15:01:30",
"irc_728,irc_numeric,nick_server,log3");
/* channel not found */
RECV(":server 728 alice #xyz q nick1!user1_\00304red@host1_\00304red");
CHECK_SRV("--", "[#xyz] nick1!user1_red@host1_red quieted",
"irc_728,irc_numeric,nick_server,log3");
RECV(":server 728 alice #xyz q nick1!user1_\00304red@host1_\00304red alice!user_\00304red@host_\00304red");
CHECK_SRV("--", "[#xyz] nick1!user1_red@host1_red quieted by alice (user_red@host_red)",
"irc_728,irc_numeric,nick_server,log3");
RECV(":server 728 alice #xyz q nick1!user1_\00304red@host1_\00304red alice!user_\00304red@host_\00304red "
"1351350090 ");
CHECK_SRV("--", "[#xyz] nick1!user1_red@host1_red quieted by alice (user_red@host_red) "
"on Sat, 27 Oct 2012 15:01:30",
"irc_728,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_729 (end of quietlist)
*/
TEST(IrcProtocolWithServer, 729)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 729");
CHECK_ERROR_PARAMS("729", 0, 3);
RECV(":server 729 alice");
CHECK_ERROR_PARAMS("729", 1, 3);
RECV(":server 729 alice #test");
CHECK_ERROR_PARAMS("729", 2, 3);
RECV(":server 729 alice #test q");
CHECK_CHAN("--", "[#test]", "irc_729,irc_numeric,nick_server,log3");
RECV(":server 729 alice #test q end");
CHECK_CHAN("--", "[#test] end", "irc_729,irc_numeric,nick_server,log3");
RECV(":server 729 alice #test q : \002End of Channel Quiet List ");
CHECK_CHAN("--", "[#test] End of Channel Quiet List ",
"irc_729,irc_numeric,nick_server,log3");
/* channel not found */
RECV(":server 729 alice #xyz q");
CHECK_SRV("--", "[#xyz]", "irc_729,irc_numeric,nick_server,log3");
RECV(":server 729 alice #xyz q end");
CHECK_SRV("--", "[#xyz] end", "irc_729,irc_numeric,nick_server,log3");
RECV(":server 729 alice #xyz q : \002End of Channel Quiet List ");
CHECK_SRV("--", "[#xyz] End of Channel Quiet List ",
"irc_729,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_730 (monitored nicks are online (RPL_MONONLINE))
* irc_protocol_cb_731 (monitored nicks are offline (RPL_MONOFFLINE))
*/
TEST(IrcProtocolWithServer, 730)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 730");
CHECK_ERROR_PARAMS("730", 0, 2);
RECV(":server 730 alice");
CHECK_ERROR_PARAMS("730", 1, 2);
RECV(":server 731");
CHECK_ERROR_PARAMS("731", 0, 2);
RECV(":server 731 alice");
CHECK_ERROR_PARAMS("731", 1, 2);
/* without notify */
RECV(":server 730 alice : nick1!user1@host1,nick2!user2@host2 ");
CHECK_SRV("--", "notify: nick1 (user1@host1) is connected",
"irc_notify,irc_notify_join,nick_nick1,notify_message,log3");
CHECK_SRV("--", "notify: nick2 (user2@host2) is connected",
"irc_notify,irc_notify_join,nick_nick2,notify_message,log3");
RECV(":server 730 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_SRV("--", "notify: nick1 (user1@host1) is connected",
"irc_notify,irc_notify_join,nick_nick1,notify_message,log3");
CHECK_SRV("--", "notify: nick2 (user2@host2) is connected",
"irc_notify,irc_notify_join,nick_nick2,notify_message,log3");
RECV(":server 731 alice : nick1!user1@host1,nick2!user2@host2 ");
CHECK_SRV("--", "notify: nick1 (user1@host1) is offline",
"irc_notify,irc_notify_quit,nick_nick1,notify_message,log3");
CHECK_SRV("--", "notify: nick2 (user2@host2) is offline",
"irc_notify,irc_notify_quit,nick_nick2,notify_message,log3");
RECV(":server 731 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_SRV("--", "notify: nick1 (user1@host1) is offline",
"irc_notify,irc_notify_quit,nick_nick1,notify_message,log3");
CHECK_SRV("--", "notify: nick2 (user2@host2) is offline",
"irc_notify,irc_notify_quit,nick_nick2,notify_message,log3");
/* with notify on nick1 */
run_cmd_quiet ("/notify add nick1 " IRC_FAKE_SERVER);
RECV(":server 730 alice : nick1!user1@host1,nick2!user2@host2 ");
CHECK_SRV("--", "notify: nick1 (user1@host1) is connected",
"irc_notify,irc_notify_join,nick_nick1,notify_message,log3");
CHECK_SRV("--", "notify: nick2 (user2@host2) is connected",
"irc_notify,irc_notify_join,nick_nick2,notify_message,log3");
RECV(":server 730 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_SRV("--", "notify: nick2 (user2@host2) is connected",
"irc_notify,irc_notify_join,nick_nick2,notify_message,log3");
RECV(":server 731 alice : nick1!user1@host1,nick2!user2@host2 ");
CHECK_SRV("--", "notify: nick1 (user1@host1) has quit",
"irc_notify,irc_notify_quit,nick_nick1,notify_message,log3");
CHECK_SRV("--", "notify: nick2 (user2@host2) is offline",
"irc_notify,irc_notify_quit,nick_nick2,notify_message,log3");
RECV(":server 731 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_SRV("--", "notify: nick2 (user2@host2) is offline",
"irc_notify,irc_notify_quit,nick_nick2,notify_message,log3");
RECV(":server 730 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_SRV("--", "notify: nick1 (user1@host1) has connected",
"irc_notify,irc_notify_join,nick_nick1,notify_message,log3");
CHECK_SRV("--", "notify: nick2 (user2@host2) is connected",
"irc_notify,irc_notify_join,nick_nick2,notify_message,log3");
run_cmd_quiet ("/mute /notify del nick1 " IRC_FAKE_SERVER);
/* with notify on nick1 and nick2 */
run_cmd_quiet ("/notify add nick1 " IRC_FAKE_SERVER);
run_cmd_quiet ("/notify add nick2 " IRC_FAKE_SERVER);
RECV(":server 730 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_SRV("--", "notify: nick1 (user1@host1) is connected",
"irc_notify,irc_notify_join,nick_nick1,notify_message,log3");
CHECK_SRV("--", "notify: nick2 (user2@host2) is connected",
"irc_notify,irc_notify_join,nick_nick2,notify_message,log3");
RECV(":server 731 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_SRV("--", "notify: nick1 (user1@host1) has quit",
"irc_notify,irc_notify_quit,nick_nick1,notify_message,log3");
CHECK_SRV("--", "notify: nick2 (user2@host2) has quit",
"irc_notify,irc_notify_quit,nick_nick2,notify_message,log3");
RECV(":server 730 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_SRV("--", "notify: nick1 (user1@host1) has connected",
"irc_notify,irc_notify_join,nick_nick1,notify_message,log3");
CHECK_SRV("--", "notify: nick2 (user2@host2) has connected",
"irc_notify,irc_notify_join,nick_nick2,notify_message,log3");
run_cmd_quiet ("/mute /notify del nick1 " IRC_FAKE_SERVER);
run_cmd_quiet ("/mute /notify del nick2 " IRC_FAKE_SERVER);
}
/*
* Tests functions:
* irc_protocol_cb_732 (list of monitored nicks (RPL_MONLIST))
*/
TEST(IrcProtocolWithServer, 732)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 732");
CHECK_ERROR_PARAMS("732", 0, 1);
RECV(":server 732 alice");
CHECK_SRV("--", "", "irc_732,irc_numeric,nick_server,log3");
RECV(":server 732 alice : nick1!user1@host1,nick2!user2@host2 ");
CHECK_SRV("--", "nick1!user1@host1,nick2!user2@host2",
"irc_732,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_733 (end of a monitor list (RPL_ENDOFMONLIST))
*/
TEST(IrcProtocolWithServer, 733)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 733");
CHECK_ERROR_PARAMS("733", 0, 1);
RECV(":server 733 alice");
CHECK_SRV("--", "", "irc_733,irc_numeric,nick_server,log3");
RECV(":server 733 alice end");
CHECK_SRV("--", "end", "irc_733,irc_numeric,nick_server,log3");
RECV(":server 733 alice : End of MONITOR list ");
CHECK_SRV("--", " End of MONITOR list ", "irc_733,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_734 (monitor list is full (ERR_MONLISTFULL))
*/
TEST(IrcProtocolWithServer, 734)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 734");
CHECK_ERROR_PARAMS("734", 0, 3);
RECV(":server 734 alice");
CHECK_ERROR_PARAMS("734", 1, 3);
RECV(":server 734 alice 10");
CHECK_ERROR_PARAMS("734", 2, 3);
RECV(":server 734 alice 10 nick1,nick2");
CHECK_SRV("=!=", " (10)", "irc_734,irc_numeric,nick_server,log3");
RECV(":server 734 alice 10 nick1,nick2 full");
CHECK_SRV("=!=", "full (10)", "irc_734,irc_numeric,nick_server,log3");
RECV(":server 734 alice 10 nick1,nick2 : \002Monitor list is full ");
CHECK_SRV("=!=", " Monitor list is full (10)",
"irc_734,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_742 (mode cannot be set)
*/
TEST(IrcProtocolWithServer, 742)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 742");
CHECK_ERROR_PARAMS("742", 0, 2);
RECV(":server 742 alice");
CHECK_ERROR_PARAMS("742", 1, 2);
RECV(":server 742 alice #test");
CHECK_SRV("--", "#test", "irc_742,irc_numeric,nick_server,log3");
RECV(":server 742 alice #test n nstlk : \002MODE cannot be set due to channel "
"having an active MLOCK restriction policy ");
CHECK_CHAN("--",
"#test: n nstlk MODE cannot be set due to channel having "
"an active MLOCK restriction policy ",
"irc_742,irc_numeric,nick_server,log3");
RECV(":server 742 alice #test2 n nstlk :\002MODE cannot be set due to channel "
"having an active MLOCK restriction policy");
CHECK_SRV("--",
"#test2: n nstlk MODE cannot be set due to channel having "
"an active MLOCK restriction policy",
"irc_742,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_900 (logged in as (SASL))
*/
TEST(IrcProtocolWithServer, 900)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 900");
CHECK_ERROR_PARAMS("900", 0, 4);
RECV(":server 900 alice");
CHECK_ERROR_PARAMS("900", 1, 4);
RECV(":server 900 alice alice!user@host");
CHECK_ERROR_PARAMS("900", 2, 4);
RECV(":server 900 alice alice!user@host alice");
CHECK_ERROR_PARAMS("900", 3, 4);
RECV(":server 900 alice alice!user@host alice logged");
CHECK_SRV("--", "logged (alice!user@host)",
"irc_900,irc_numeric,nick_server,log3");
RECV(":server 900 alice alice!user@host alice : "
"\002You are now logged in as mynick ");
CHECK_SRV("--", " You are now logged in as mynick (alice!user@host)",
"irc_900,irc_numeric,nick_server,log3");
RECV(":server 900 * * alice : \002You are now logged in as mynick ");
CHECK_SRV("--", " You are now logged in as mynick ",
"irc_900,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_901 (you are now logged out)
*/
TEST(IrcProtocolWithServer, 901)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 901");
CHECK_ERROR_PARAMS("901", 0, 3);
RECV(":server 901 alice");
CHECK_ERROR_PARAMS("901", 1, 3);
RECV(":server 901 alice nick!user@host");
CHECK_ERROR_PARAMS("901", 2, 3);
RECV(":server 901 alice nick!user@host logged");
CHECK_SRV("--", "logged", "irc_901,irc_numeric,nick_server,log3");
RECV(":server 901 alice nick!user@host : \002You are now logged out ");
CHECK_SRV("--", " You are now logged out ",
"irc_901,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_903 (SASL OK)
* irc_protocol_cb_907 (SASL OK)
*/
TEST(IrcProtocolWithServer, 903_907)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 903");
CHECK_ERROR_PARAMS("903", 0, 1);
/* not enough parameters */
RECV(":server 907");
CHECK_ERROR_PARAMS("907", 0, 1);
RECV(":server 903 alice ok");
CHECK_SRV("--", "ok", "irc_903,irc_numeric,nick_server,log3");
RECV(":server 903 alice : \002SASL authentication successful ");
CHECK_SRV("--", " SASL authentication successful ",
"irc_903,irc_numeric,nick_server,log3");
RECV(":server 903 * : SASL authentication successful ");
CHECK_SRV("--", " SASL authentication successful ",
"irc_903,irc_numeric,nick_server,log3");
RECV(":server 907 alice ok");
CHECK_SRV("--", "ok", "irc_907,irc_numeric,nick_server,log3");
RECV(":server 907 alice : \002SASL authentication successful ");
CHECK_SRV("--", " SASL authentication successful ",
"irc_907,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_902 (SASL failed)
* irc_protocol_cb_904 (SASL failed)
* irc_protocol_cb_905 (SASL failed)
* irc_protocol_cb_906 (SASL failed)
*/
TEST(IrcProtocolWithServer, 902_904_905_906)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 902");
CHECK_ERROR_PARAMS("902", 0, 1);
/* not enough parameters */
RECV(":server 904");
CHECK_ERROR_PARAMS("904", 0, 1);
/* not enough parameters */
RECV(":server 905");
CHECK_ERROR_PARAMS("905", 0, 1);
/* not enough parameters */
RECV(":server 906");
CHECK_ERROR_PARAMS("906", 0, 1);
RECV(":server 902 alice error");
CHECK_SRV("--", "error", "irc_902,irc_numeric,nick_server,log3");
RECV(":server 902 alice : \002SASL authentication failed ");
CHECK_SRV("--", " SASL authentication failed ",
"irc_902,irc_numeric,nick_server,log3");
RECV(":server 904 alice error");
CHECK_SRV("--", "error", "irc_904,irc_numeric,nick_server,log3");
RECV(":server 904 alice : \002SASL authentication failed ");
CHECK_SRV("--", " SASL authentication failed ",
"irc_904,irc_numeric,nick_server,log3");
RECV(":server 905 alice error");
CHECK_SRV("--", "error", "irc_905,irc_numeric,nick_server,log3");
RECV(":server 905 alice : \002SASL authentication failed ");
CHECK_SRV("--", " SASL authentication failed ",
"irc_905,irc_numeric,nick_server,log3");
RECV(":server 906 alice error");
CHECK_SRV("--", "error", "irc_906,irc_numeric,nick_server,log3");
RECV(":server 906 alice : \002SASL authentication failed ");
CHECK_SRV("--", " SASL authentication failed ",
"irc_906,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_936 (censored word)
*/
TEST(IrcProtocolWithServer, 936)
{
SRV_INIT_JOIN;
/* not enough parameters */
RECV(":server 936");
CHECK_ERROR_PARAMS("936", 0, 2);
RECV(":server 936 alice");
CHECK_ERROR_PARAMS("936", 1, 2);
RECV(":server 936 alice #test");
CHECK_SRV("--", "#test", "irc_936,irc_numeric,nick_server,log3");
RECV(":server 936 alice #test CENSORED_WORD "
": \002Your message contained a censored word, and was blocked ");
CHECK_CHAN("--",
"#test: CENSORED_WORD Your message contained a censored word, "
"and was blocked ",
"irc_936,irc_numeric,nick_server,log3");
}
/*
* Tests functions:
* irc_protocol_cb_server_mode_reason
*
* Messages:
* 973: whois (secure connection)
* 974: whois (secure connection)
* 975: whois (secure connection)
*/
TEST(IrcProtocolWithServer, server_mode_reason)
{
SRV_INIT;
/* not enough parameters */
RECV(":server 973");
CHECK_ERROR_PARAMS("973", 0, 1);
RECV(":server 973 alice");
CHECK_NO_MSG;
RECV(":server 973 alice mode");
CHECK_SRV("--", "mode", "irc_973,irc_numeric,nick_server,log3");
RECV(":server 973 alice mode test");
CHECK_SRV("--", "mode: test", "irc_973,irc_numeric,nick_server,log3");
RECV(":server 973 alice mode : test ");
CHECK_SRV("--", "mode: test ", "irc_973,irc_numeric,nick_server,log3");
RECV(":server 974 alice");
CHECK_NO_MSG;
RECV(":server 974 alice mode");
CHECK_SRV("--", "mode", "irc_974,irc_numeric,nick_server,log3");
RECV(":server 974 alice mode test");
CHECK_SRV("--", "mode: test", "irc_974,irc_numeric,nick_server,log3");
RECV(":server 974 alice mode : test ");
CHECK_SRV("--", "mode: test ", "irc_974,irc_numeric,nick_server,log3");
RECV(":server 975 alice");
CHECK_NO_MSG;
RECV(":server 975 alice mode");
CHECK_SRV("--", "mode", "irc_975,irc_numeric,nick_server,log3");
RECV(":server 975 alice mode test");
CHECK_SRV("--", "mode: test", "irc_975,irc_numeric,nick_server,log3");
RECV(":server 975 alice mode : test ");
CHECK_SRV("--", "mode: test ", "irc_975,irc_numeric,nick_server,log3");
RECV(":server 973 bob");
CHECK_SRV("--", "bob", "irc_973,irc_numeric,nick_server,log3");
RECV(":server 973 bob mode");
CHECK_SRV("--", "bob: mode", "irc_973,irc_numeric,nick_server,log3");
RECV(":server 973 bob mode test");
CHECK_SRV("--", "bob: mode test", "irc_973,irc_numeric,nick_server,log3");
RECV(":server 973 bob mode : test ");
CHECK_SRV("--", "bob: mode test ", "irc_973,irc_numeric,nick_server,log3");
RECV(":server 974 bob");
CHECK_SRV("--", "bob", "irc_974,irc_numeric,nick_server,log3");
RECV(":server 974 bob mode");
CHECK_SRV("--", "bob: mode", "irc_974,irc_numeric,nick_server,log3");
RECV(":server 974 bob mode test");
CHECK_SRV("--", "bob: mode test", "irc_974,irc_numeric,nick_server,log3");
RECV(":server 974 bob mode : test ");
CHECK_SRV("--", "bob: mode test ", "irc_974,irc_numeric,nick_server,log3");
RECV(":server 975 bob");
CHECK_SRV("--", "bob", "irc_975,irc_numeric,nick_server,log3");
RECV(":server 975 bob mode");
CHECK_SRV("--", "bob: mode", "irc_975,irc_numeric,nick_server,log3");
RECV(":server 975 bob mode test");
CHECK_SRV("--", "bob: mode test", "irc_975,irc_numeric,nick_server,log3");
RECV(":server 975 bob mode : test ");
CHECK_SRV("--", "bob: mode test ", "irc_975,irc_numeric,nick_server,log3");
}
|