libnm/tests: add tests for libnm handling invalid connections
authorThomas Haller <thaller@redhat.com>
Thu, 24 Dec 2015 16:20:39 +0000 (17:20 +0100)
committerThomas Haller <thaller@redhat.com>
Sat, 26 Dec 2015 18:09:11 +0000 (19:09 +0100)
commit92f122525dab49fece51b6b6bda99c762507f7c9
tree42bfd0f27b542dbee3fa8cab31b3103b5ef4a4f7
parent212e1c3a8481fef1ce780ed9b17d17fd51acdee3
libnm/tests: add tests for libnm handling invalid connections

Add test showing how libnm/libnm-glib handles invalid connections,
i.e. connections that fail nm_connection_verify(). libnm implements
settings a static types (via different NMSetting types). This makes
it unavoidable that eventually a newer server version will
expose connections that fail verification in the client.

For example, master added a new base type NMSettingTun. This setting type
was not backported to legacy libnm-glib, thus such connection will not verify.
Also, we want that newer server versions are backward compatible with older
library versions. Thus also a pre-NMSettingTun libnm version has the same
problem.

The test shows that libnm is agnostic to whether the connection verifies.
That is consistent behavior, but possibly problematic because most
accessors to connections assert against a valid connection. Thus using
the common nm_connection*() functions on an invalid connection can lead
to problems.
Also, due to the static nature of our NMSetting types, some properties
can be silently dropped and thus mangling the connection without the
library user noticing.

libnm-glib prints a g_warning() whenever parsing an invalid connection.
When an invalid connection is added initially, it is exposed to the library
user. When a connection gets later invalidated due to an update, the
connection disappears and it stays missing even if a subsequent update
makes the connection valid again.

libnm-glib's behavior indicates that we might wanted to hide invalid
connections from the user. But it's very broken there.
libnm-glib/tests/test-nm-client.c
libnm/tests/test-nm-client.c