-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ncm-nss: replace LC::Check with FileWriter
Use FileWriter instead of LC::Check and add a simple unit test of the behaviour.
- Loading branch information
Showing
3 changed files
with
62 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/perl | ||
# -*- mode: cperl -*- | ||
use strict; | ||
use warnings; | ||
|
||
use Test::More; | ||
use Test::Quattor qw(simple); | ||
use NCM::Component::sysctl; | ||
use Test::MockModule; | ||
use CAF::Object; | ||
|
||
$CAF::Object::NoAction = 1; | ||
|
||
my $mock = Test::MockModule->new('NCM::Component::nss'); | ||
|
||
=pod | ||
=head1 DESCRIPTION | ||
Test the configure() method. | ||
=cut | ||
|
||
my $cmp = NCM::Component::nss->new('nss'); | ||
my $cfg = get_config_for_profile('simple'); | ||
my $testfile = "/etc/nsswitch.conf"; | ||
my $testcmd = "/usr/sbin/buildldap -d passwd"; | ||
|
||
is($cmp->Configure($cfg), 1, "Configure succeeds"); | ||
my $fh = get_file($testfile); | ||
ok($fh, "$testfile was created"); | ||
isa_ok($fh, "CAF::FileWriter"); | ||
like("$fh", qr{^passwd: files ldap$}m, "passwd line present and correct"); | ||
ok(defined(get_command($testcmd)), "$testcmd was run"); | ||
ok(!defined(get_command('/usr/sbin/builddb')), "inactive db was not built"); | ||
|
||
done_testing(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
object template simple; | ||
|
||
#function pkg_repl = { null; }; | ||
#include 'components/nss/config'; | ||
#"/software/components/nss/dependencies/pre" = null; | ||
|
||
prefix "/software/components/nss"; | ||
"databases/passwd" = list("files", "ldap"); | ||
"build/ldap/script" = "/usr/sbin/buildldap -d <DB>"; | ||
"build/ldap/active" = true; | ||
"build/db/script" = "/usr/sbin/builddb"; | ||
# active has a de-facto value of false in the code | ||
#"build/db/active" = false; | ||
|
||
|