X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=test%2Finvite-join.c;h=52a922a89a9509695639dd88e90623255e039884;hb=f73f697142bd5ce32d9b7273ed73ea798594854d;hp=c9ebea6043d2a39b05f02c9e163711eec028a61b;hpb=fa05f996c5500c056a36c1d43e33a407f876643c;p=meshlink diff --git a/test/invite-join.c b/test/invite-join.c index c9ebea60..52a922a8 100644 --- a/test/invite-join.c +++ b/test/invite-join.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "meshlink.h" @@ -105,8 +106,6 @@ int main() { return 1; } - free(baz_url); - if(!meshlink_start(mesh2)) { fprintf(stderr, "Baz could not start\n"); return 1; @@ -139,6 +138,15 @@ int main() { return 1; } + // Check that an invitation cannot be used twice + + if(meshlink_join(mesh3, baz_url)) { + fprintf(stderr, "Quux could join foo's mesh using an already used invitation\n"); + return 1; + } + + free(baz_url); + // Check that nodes cannot join with expired invitations meshlink_set_invitation_timeout(mesh1, 0); @@ -150,6 +158,31 @@ int main() { free(quux_url); + // Check that existing nodes cannot join another mesh + + char *corge_url = meshlink_invite(mesh3, NULL, "corge"); + + if(!corge_url) { + fprintf(stderr, "Quux could not generate an invitation for corge\n"); + return 1; + } + + fprintf(stderr, "Invitation URL for corge: %s\n", corge_url); + + if(!meshlink_start(mesh3)) { + fprintf(stderr, "Quux could not start\n"); + return 1; + } + + meshlink_stop(mesh2); + + if(meshlink_join(mesh2, corge_url)) { + fprintf(stderr, "Bar could join twice\n"); + return 1; + } + + free(corge_url); + // Clean up. meshlink_close(mesh3);