summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-08-31 16:51:09 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:36:17 -0500
commit0712cbdab4c397b9f74fcd681f40df9c9c2c59a8 (patch)
tree05a6e0151391ed749c6ea51c254747ac34c78a55
parent52bcf4c5a3a371e13530fe83c8b4ca06dad10b8f (diff)
downloadsamba-0712cbdab4c397b9f74fcd681f40df9c9c2c59a8.tar.gz
samba-0712cbdab4c397b9f74fcd681f40df9c9c2c59a8.tar.bz2
samba-0712cbdab4c397b9f74fcd681f40df9c9c2c59a8.zip
r9834: More tests for the upgrade from Samba3
(This used to be commit d2db164d6f674cada470e871c558c75f98244141)
-rwxr-xr-xsource4/script/tests/test_s3upgrade.sh11
-rw-r--r--source4/scripting/ejs/smbcalls_samba3.c42
-rw-r--r--source4/scripting/libjs/upgrade.js30
-rwxr-xr-xsource4/setup/upgrade9
-rwxr-xr-xtestdata/samba3/verify51
5 files changed, 126 insertions, 17 deletions
diff --git a/source4/script/tests/test_s3upgrade.sh b/source4/script/tests/test_s3upgrade.sh
index 50aa52f067..e4e5d828e5 100755
--- a/source4/script/tests/test_s3upgrade.sh
+++ b/source4/script/tests/test_s3upgrade.sh
@@ -7,11 +7,8 @@ then
exit 1
fi
-DATADIR=$PREFIX/upgrade
+mkdir -p $PREFIX
+rm -f $PREFIX/*
-mkdir -p $DATADIR
-rm -f $DATADIR/*
-
-bin/smbscript setup/upgrade --targetdir=$DATADIR ../testdata/samba3 ../testdata/samba3/smb.conf
-
-# FIXME: Do some sanity checks on the output files
+bin/smbscript ../testdata/samba3/verify ../testdata/samba3
+bin/smbscript setup/upgrade --verify --targetdir=$PREFIX ../testdata/samba3 ../testdata/samba3/smb.conf
diff --git a/source4/scripting/ejs/smbcalls_samba3.c b/source4/scripting/ejs/smbcalls_samba3.c
index 0d54d54dcc..0e4743eca9 100644
--- a/source4/scripting/ejs/smbcalls_samba3.c
+++ b/source4/scripting/ejs/smbcalls_samba3.c
@@ -55,6 +55,10 @@ static struct MprVar mprRegistry(struct samba3_regdb *reg)
mprAddArray(&ks, i, k);
}
+ if (i == 0) {
+ mprSetVar(&ks, "length", mprCreateIntegerVar(i));
+ }
+
mprSetVar(&mpv, "keys", ks);
return mpv;
@@ -104,6 +108,11 @@ static struct MprVar mprIdmapDb(struct samba3_idmapdb *db)
mprAddArray(&mps, i, mp);
}
+ if (i == 0) {
+ mprSetVar(&mpv, "length", mprCreateIntegerVar(i));
+ }
+
+
mprSetVar(&mpv, "mappings", mps);
return mpv;
@@ -131,6 +140,11 @@ static struct MprVar mprGroupMappings(struct samba3_groupdb *db)
mprAddArray(&mpv, i, g);
}
+ if (i == 0) {
+ mprSetVar(&mpv, "length", mprCreateIntegerVar(i));
+ }
+
+
return mpv;
}
@@ -158,6 +172,10 @@ static struct MprVar mprAliases(struct samba3_groupdb *db)
mprSetVar(&a, "members", am);
}
+ if (i == 0) {
+ mprSetVar(&mpv, "length", mprCreateIntegerVar(i));
+ }
+
return mpv;
}
@@ -219,6 +237,10 @@ static struct MprVar mprSecrets(struct samba3_secrets *sec)
mprAddArray(&es, i, mprDomainSecrets(&sec->domains[i]));
}
+ if (i == 0) {
+ mprSetVar(&es, "length", mprCreateIntegerVar(i));
+ }
+
mprSetVar(&mpv, "domains", es);
es = mprObject("trusted_domains");
@@ -247,6 +269,10 @@ static struct MprVar mprSecrets(struct samba3_secrets *sec)
mprAddArray(&es, i, e);
}
+ if (i == 0) {
+ mprSetVar(&es, "length", mprCreateIntegerVar(i));
+ }
+
mprSetVar(&mpv, "trusted_domains", es);
es = mprObject("array");
@@ -279,6 +305,10 @@ static struct MprVar mprSecrets(struct samba3_secrets *sec)
mprAddArray(&es, i, e);
}
+ if (i == 0) {
+ mprSetVar(&es, "length", mprCreateIntegerVar(i));
+ }
+
mprSetVar(&mpv, "afs_keyfiles", es);
mprSetVar(&mpv, "ipc_cred", mprCredentials(sec->ipc_cred));
@@ -301,6 +331,10 @@ static struct MprVar mprShares(struct samba3 *samba3)
mprAddArray(&mpv, i, s);
}
+ if (i == 0) {
+ mprSetVar(&mpv, "length", mprCreateIntegerVar(i));
+ }
+
return mpv;
}
@@ -348,6 +382,10 @@ static struct MprVar mprSamAccounts(struct samba3 *samba3)
mprAddArray(&mpv, i, m);
}
+ if (i == 0) {
+ mprSetVar(&mpv, "length", mprCreateIntegerVar(i));
+ }
+
return mpv;
}
@@ -375,6 +413,10 @@ static struct MprVar mprWinsEntries(struct samba3 *samba3)
mprAddArray(&mpv, i, w);
}
+ if (i == 0) {
+ mprSetVar(&mpv, "length", mprCreateIntegerVar(i));
+ }
+
return mpv;
}
diff --git a/source4/scripting/libjs/upgrade.js b/source4/scripting/libjs/upgrade.js
index e78865f196..59e433b0f2 100644
--- a/source4/scripting/libjs/upgrade.js
+++ b/source4/scripting/libjs/upgrade.js
@@ -448,26 +448,26 @@ dn: @MAP=samba3sam
message("Importing users\n");
for (var i in samba3.samaccounts) {
- message("... " + samba3.samaccounts[i].username);
+ var msg = "... " + samba3.samaccounts[i].username;
var ldif = upgrade_sam_account(samba3.samaccounts[i],subobj.BASEDN);
ok = samdb.add(ldif);
if (!ok) {
- message("... error: " + samdb.errstring());
+ msg = msg + "... error: " + samdb.errstring();
ret = ret + 1;
}
- message("\n");
+ message(msg + "\n");
}
message("Importing groups\n");
for (var i in samba3.groupmappings) {
- message("... " + samba3.groupmappings[i].nt_name);
+ var msg = "... " + samba3.groupmappings[i].nt_name;
var ldif = upgrade_sam_group(samba3.groupmappings[i],subobj.BASEDN);
ok = samdb.add(ldif);
if (!ok) {
- message("... error: " + samdb.errstring());
+ msg = msg + "... error: " + samdb.errstring();
ret = ret + 1;
}
- message("\n");
+ message(msg + "\n");
}
message("Importing registry data\n");
@@ -480,13 +480,13 @@ dn: @MAP=samba3sam
assert(ok);
var ldif = upgrade_registry(samba3.registry, hn, regdb);
for (var j in ldif) {
- message("... ... " + j);
+ var msg = "... ... " + j;
ok = regdb.add(ldif[j]);
if (!ok) {
- message("... error: " + regdb.errstring());
+ msg = msg + "... error: " + regdb.errstring();
ret = ret + 1;
}
- message("\n");
+ message(msg + "\n");
}
}
@@ -502,3 +502,15 @@ dn: @MAP=samba3sam
return ret;
}
+
+function upgrade_verify(subobj, samba3,paths,message)
+{
+ message("Verifying account policies\n");
+ var samldb = ldb_init();
+ var ne = 0;
+
+ var ok = samldb.connect(paths.samdb);
+ assert(ok);
+
+ // FIXME
+}
diff --git a/source4/setup/upgrade b/source4/setup/upgrade
index 331892c3db..8dc10caa3f 100755
--- a/source4/setup/upgrade
+++ b/source4/setup/upgrade
@@ -10,6 +10,7 @@ options = GetOptions(ARGV,
"POPT_AUTOHELP",
"POPT_COMMON_SAMBA",
"POPT_COMMON_VERSION",
+ 'verify',
'targetdir=s',
'quiet', 'blank');
@@ -92,4 +93,10 @@ if (ret > 0) {
} else {
message("All OK\n");
}
-return 0;
+
+if (options.verify != undefined) {
+ message("Verifying...\n");
+ ret = upgrade_verify(subobj, samba3,paths,message);
+}
+
+return ret;
diff --git a/testdata/samba3/verify b/testdata/samba3/verify
new file mode 100755
index 0000000000..ed6ed95189
--- /dev/null
+++ b/testdata/samba3/verify
@@ -0,0 +1,51 @@
+#!/usr/bin/env smbscript
+/* Verifies that the data present in this directory
+ Can be read correctly by Samba4. Do not update
+ without changing the corresponding TDB file!
+ Written by Jelmer Vernooij, 2005.
+ */
+
+libinclude("base.js");
+
+var path = substr(ARGV[0], 0, -strlen("verify"));
+printf("Reading from %s\n", path);
+
+var s = samba3_read(path, path+"smb.conf");
+assert(s != undefined);
+
+// smb.conf checks
+assert(s.configuration.get("passdb backend") != undefined);
+
+var data = s.configuration.data();
+assert(data != undefined);
+var global = data["global"];
+assert(global != undefined);
+assert(global["passdb backend"] == s.configuration.get("passdb backend"));
+assert(global["passdb backend"] != undefined);
+
+println("smb.conf ok");
+
+assert(s.winsentries.length == 22);
+assert(s.samaccounts.length == 3);
+assert(s.shares.length == 0);
+assert(s.registry.keys.length == 28);
+assert(s.groupmappings.length == 13);
+assert(s.aliases.length == 0);
+assert(s.idmapdb.mappings.length == 4);
+
+println("database entry count correct");
+
+// account policies
+assert(s.policy.min_password_length == 5);
+assert(s.policy.minimum_password_age == 0);
+assert(s.policy.maximum_password_age == 999999999);
+assert(s.policy.refuse_machine_password_change == 0);
+assert(s.policy.reset_count_minutes == 0);
+assert(s.policy.disconnect_time == -1);
+assert(s.policy.user_must_logon_to_change_password == 0);
+assert(s.policy.password_history == 0);
+assert(s.policy.lockout_duration == 0);
+assert(s.policy.bad_lockout_minutes == 0);
+
+println("account policies ok");
+