Commit Graph

23 Commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
01f62f11f7 transaction_test: Add tests checking the loaded services match 2023-11-30 02:49:29 +01:00
Marco Trevisan (Treviño)
c7ecbf20dc transaction: Add a test finalizer checking if transaction has ended
Check if a transaction is ended in in tests.
2023-11-30 02:49:29 +01:00
Marco Trevisan (Treviño)
c635cfc38a transaction: Add End() method and Remove Transaction finalizer
A PAM transaction needs to be ended in order to release the associated
resources, however this can't be sadly automated as the go finalizers
run in goroutines and this could cause problems to modules that we load.

In fact a module code may be called back during pam_end (to cleanup data
for example) and the module code could not be thread safe.

So let's make this more manual, but safer.
The transaction status is still preserved in the transaction so end will
be automatically called with the last-known status.

Closes: #14
2023-11-30 01:16:39 +01:00
Marco Trevisan (Treviño)
7162004668 transaction: Do not make Transaction to implement error interface anymore
As per previous commit, Transaction can't be used anymore as an error
value, but we instead we always return the status code.
2023-11-30 01:16:39 +01:00
Marco Trevisan (Treviño)
adffdfbbdc transaction: Never return Transaction as error
While transaction does implement error, it's not a valid error
implementer because it may have bogous values since it's not thread-safe
and so we may read the result of Error() when it's into an invalid state

As per this never return it as an error, while always return the Status
unless when not available, where we still return pam.Error.
2023-11-30 01:16:39 +01:00
Marco Trevisan (Treviño)
a5f5ad6470 transaction: Return errors wrapping pam.Error values on failure
If the transaction fails during start, there's no way to get the error
detail in a programmatic way, so let's wrap the pam.Error to allow more
per-type checks.
2023-11-30 01:16:39 +01:00
Marco Trevisan (Treviño)
ea51cc0fe4 transaction: Add tests for all the possible Status (and error) values
Use pam_debug.so to generate pam configurations at test time and
check if the returned values expect the ones we want.
2023-11-30 01:16:39 +01:00
Michael Steinert
a85a609bbe Run go fmt 2023-09-23 10:38:09 -05:00
Marco Trevisan (Treviño)
a22a1abf3f transaction_test: Add root-less tests to check pam conversation
Use pam_succeed_if to make it implicitly ask for the user name and
verify that the provided one is correct.

This can safely run as user.
2023-09-19 18:46:25 +02:00
Marco Trevisan (Treviño)
1cab6e699c transaction_test: Add more authentication tests to run as user
So that it's possible also to verify an info text conversation
2023-09-19 18:46:25 +02:00
Marco Trevisan (Treviño)
ca3e79e605 transaction_test: Enable conf-dir tests without root
They don't require the `test` user nor being ran as root
2023-09-19 18:18:56 +02:00
Marco Trevisan (Treviño)
d0c0c8bf18 tests: Move services to a subdirectory
It makes it cleaner to handle, plus it allows adding more.

Also rename the `my-service` to something more self-explanatory.
2023-09-19 18:17:54 +02:00
Didier Roche
376af17c46 Integration test for confdir handling.
Add tests to cover StartConfDir with custom services path.
2022-09-16 08:50:03 +02:00
Michael Steinert
39406aafe4 Attempt to modernize the repo 2021-12-03 12:05:27 -06:00
Michael Steinert
f29b9f28d6 Update CI build matrix & fix some lint 2019-02-15 12:06:59 -06:00
Michael Steinert
7f5fc62ba4 Remove dead code 2015-12-04 09:21:38 -06:00
Michael Steinert
8b3b6781b0 Test some failure conditions 2015-04-10 15:28:23 -05:00
Michael Steinert
61a0e177d2 Fix golint warnings 2015-04-10 15:04:52 -05:00
Michael Steinert
b4414b73f0 Improve test coverage 2015-04-09 11:37:39 -05:00
Michael Steinert
8fad614175 Test coverage for SetItem/GetItem 2015-03-30 18:26:47 -05:00
Michael Steinert
77471e65f1 Fix a silly bug and add test coverage 2015-03-30 18:13:10 -05:00
Michael Steinert
a0cde3fe01 Rework pam_getenvlist so it doesn't leak 2015-03-30 14:53:16 -05:00
Michael Steinert
9c771166c9 Add a test suite 2015-03-29 11:25:00 -05:00