From 1ab7409b183f83a7747d0f473041e6f679262750 Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Sat, 29 Jun 2019 03:56:06 +0200 Subject: [PATCH] Very basic initial spec. --- spec/basics.cr | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 spec/basics.cr diff --git a/spec/basics.cr b/spec/basics.cr new file mode 100644 index 0000000..600bb89 --- /dev/null +++ b/spec/basics.cr @@ -0,0 +1,53 @@ +require "spec" + +require "../src/authd.cr" + +describe "authd" do + it "runs basic functions" do + # Database setup. + File.write "passwd", "" + File.write "group", "" + + ENV["IPC_RUNDIR"]="." + + # authd (dæmon) setup. + authd_process = Process.new( + "./bin/authd", + args: [ + "-u", "passwd", + "-g", "group" + ] + ) + + # Actual test begins here. + authd = AuthD::Client.new + + pp! authd.add_user "test", "test" + + # User should be there, we just created it! + user = authd.get_user?("test", "test").as AuthD::User + + (user.login == "test").should be_true + + user2 = authd.add_user("test2", "test").as AuthD::User + + (user2.uid != user.uid).should be_true + + authd.mod_user user.uid, password: "oh no" + user_bis = authd.get_user?("test", "oh no").as AuthD::User + + user_bis.to_h.should eq(user.to_h) + + # User should be there, we just created it! + user2 = authd.get_user?("test2", "test").as AuthD::User + + (user2.uid != user.uid).should be_true + + authd.close + + # authd (dæmon) cleanup. + authd_process.kill + authd_process.wait + end +end +