Bladeren bron

added test for chpasswd function

Strobel, Stefan | Friedrich Lütze GmbH 9 maanden geleden
bovenliggende
commit
ffafbff7fe
1 gewijzigde bestanden met toevoegingen van 35 en 0 verwijderingen
  1. 35 0
      test/integrationtest_auth/test_integration_auth.cpp

+ 35 - 0
test/integrationtest_auth/test_integration_auth.cpp

@@ -683,3 +683,38 @@ SCENARIO("Check custom login with custom login function") {
     }
 }
 
+SCENARIO("Check if passwords can be changed") {
+    GIVEN("An initialized shellmatta instance with initialized auth") {
+
+        TEST_SHELLMATTA_SETUP;
+
+        TEST_SHELLMATTA_AUTH_SETUP;
+
+        WHEN("The password of the shellmatta user is changed") {
+
+            ret = shellmatta_auth_chpasswd(handle, "shimatta", "new_password");
+            CHECK(ret == SHELLMATTA_OK);
+
+            AND_WHEN("The user shellmatta logges in passing the new credentials") {
+
+                ret = shellmatta_processData(handle, (char*)"login -u shimatta -p new_password\r", 34);
+                CHECK(ret == SHELLMATTA_OK);
+
+                THEN("The shimatta user is logged in") {
+                    REQUIRE(1 == shellmatta_auth_getLoggedInUserId(handle));
+                }
+
+            }
+
+            AND_WHEN("The user shellmatta logges in passing the old credentials") {
+
+                ret = shellmatta_processData(handle, (char*)"login -u shimatta -p 12345678\r", 30);
+                CHECK(ret == SHELLMATTA_OK);
+
+                THEN("The shimatta user is not logged in") {
+                    REQUIRE(0 == shellmatta_auth_getLoggedInUserId(handle));
+                }
+            }
+        }
+    }
+}