[yast-commit] r67408 - in /trunk/dns-server: package/ src/ testsuite/tests/
Author: locilka Date: Fri Feb 10 13:27:51 2012 New Revision: 67408 URL: http://svn.opensuse.org/viewcvs/yast?rev=67408&view=rev Log: - Fixed transforming records from absolute to relative format while they are listed in UI (bnc#746363). Added: trunk/dns-server/testsuite/tests/DnsServerHelperFunctions.err trunk/dns-server/testsuite/tests/DnsServerHelperFunctions.out trunk/dns-server/testsuite/tests/DnsServerHelperFunctions.ycp Modified: trunk/dns-server/package/yast2-dns-server.changes trunk/dns-server/src/DnsServerHelperFunctions.ycp trunk/dns-server/src/dialog-masterzone.ycp Modified: trunk/dns-server/package/yast2-dns-server.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/dns-server/package/yast2-dns-server.changes?rev=67408&r1=67407&r2=67408&view=diff ============================================================================== --- trunk/dns-server/package/yast2-dns-server.changes (original) +++ trunk/dns-server/package/yast2-dns-server.changes Fri Feb 10 13:27:51 2012 @@ -1,4 +1,10 @@ ------------------------------------------------------------------ +Fri Feb 10 13:13:43 CET 2012 - locilka@suse.com + +- Fixed transforming records from absolute to relative format + while they are listed in UI (bnc#746363). + +------------------------------------------------------------------ Thu Feb 9 15:16:58 CET 2012 - locilka@suse.com - Fixed transforming records from relative to absolute format. Modified: trunk/dns-server/src/DnsServerHelperFunctions.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/dns-server/src/DnsServerHelperFunctions.ycp?rev=67408&r1=67407&r2=67408&view=diff ============================================================================== --- trunk/dns-server/src/DnsServerHelperFunctions.ycp (original) +++ trunk/dns-server/src/DnsServerHelperFunctions.ycp Fri Feb 10 13:27:51 2012 @@ -216,5 +216,39 @@ DnsServer::StoreZone (); } +map <string, list <string> > skip_converting_to_relative = $[ + "key" : [ + ], + "value" : [ + "TXT", "SPF", "SRV" + ] +]; + +global string RRToRelativeName (string absolute_name, string zone_name, string record_type, string key_or_value) { + if (absolute_name == nil || zone_name == nil) { + y2error ("Erroneous record: %1/%2/%3/%4", absolute_name, zone_name, record_type, key_or_value); + return nil; + } + + if (key_or_value != "key" && key_or_value != "value") { + y2error ("Unknown key/value %1", key_or_value); + return absolute_name; + } + + // these records are not wanted to be converted to a relative name + if (contains (skip_converting_to_relative[key_or_value]:[], toupper(record_type))) { + y2debug ("Not converting %1/%2", key_or_value, record_type); + return absolute_name; + } + + string remove_this_to_be_relative = "\\." + zone_name + "\\.$"; + string relative_name = regexpsub (absolute_name, "([^ \t]*)" + remove_this_to_be_relative, "\\1"); + if (relative_name != nil) { + return relative_name; + } + + return absolute_name; +} + /* EOF */ } Modified: trunk/dns-server/src/dialog-masterzone.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/dns-server/src/dialog-masterzone.ycp?rev=67408&r1=67407&r2=67408&view=diff ============================================================================== --- trunk/dns-server/src/dialog-masterzone.ycp (original) +++ trunk/dns-server/src/dialog-masterzone.ycp Fri Feb 10 13:27:51 2012 @@ -32,20 +32,6 @@ include "dns-server/misc.ycp"; -string ToRelativeName (string absolute_name, string zone_name) { - if (absolute_name == nil || zone_name == nil) { - return nil; - } - - string remove_this_to_be_relative = "." + zone_name + "."; - string relative_name = regexpsub(absolute_name, "(.*)" + remove_this_to_be_relative, "\\1"); - if ((relative_name != nil) && (! regexpmatch(relative_name, "\\."))) { - return relative_name; - } - - return absolute_name; -} - // zone ACL --> list <string> available_zones_to_connect = []; @@ -1198,14 +1184,14 @@ // Applies to all UI::ChangeWidget (`id ("add_record_name"), `Value, - ToRelativeName( - Punycode::DecodeDomainName (current_key), decoded_zone_name + DnsServerHelperFunctions::RRToRelativeName( + Punycode::DecodeDomainName (current_key), decoded_zone_name, current_type, "key" ) ); UI::ChangeWidget (`id ("add_record_type"), `Value, current_type); UI::ChangeWidget (`id ("add_record_val"), `Value, - ToRelativeName( - Punycode::DecodeDomainName (current_val), decoded_zone_name + DnsServerHelperFunctions::RRToRelativeName( + Punycode::DecodeDomainName (current_val), decoded_zone_name, current_type, "value" ) ); } @@ -1252,11 +1238,17 @@ list items = maplist (integer r, ret, { counter = counter + 1; + string record_type = current_zone["records", r, "type"]:""; + return `item ( `id (r), - ToRelativeName (decoded_names[counter]:current_zone["records", r, "key"]:"", decoded_zone_name), - current_zone["records", r, "type"]:"", - ToRelativeName (decoded_names[counter+const_plus]:current_zone["records", r, "value"]:"", decoded_zone_name) + DnsServerHelperFunctions::RRToRelativeName ( + decoded_names[counter]:current_zone["records", r, "key"]:"", decoded_zone_name, record_type, "key" + ), + record_type, + DnsServerHelperFunctions::RRToRelativeName ( + decoded_names[counter+const_plus]:current_zone["records", r, "value"]:"", decoded_zone_name, record_type, "value" + ) ); }); Added: trunk/dns-server/testsuite/tests/DnsServerHelperFunctions.err URL: http://svn.opensuse.org/viewcvs/yast/trunk/dns-server/testsuite/tests/DnsServerHelperFunctions.err?rev=67408&view=auto ============================================================================== (empty) Added: trunk/dns-server/testsuite/tests/DnsServerHelperFunctions.out URL: http://svn.opensuse.org/viewcvs/yast/trunk/dns-server/testsuite/tests/DnsServerHelperFunctions.out?rev=67408&view=auto ============================================================================== --- trunk/dns-server/testsuite/tests/DnsServerHelperFunctions.out (added) +++ trunk/dns-server/testsuite/tests/DnsServerHelperFunctions.out Fri Feb 10 13:27:51 2012 @@ -0,0 +1,12 @@ +Dump ========================================================== +Return dhcp1 +Return relative-name-1 +Return relative-name-2 +Return dhcp1.subdomain +Return dhcp1.different-example.com. +Return v=spf1 include:example.com -all +Return some-text +Return v=spf1 include:example.com -all +Return _http._tcp +Return 0 5 80 example.com. +Dump ========================================================== Added: trunk/dns-server/testsuite/tests/DnsServerHelperFunctions.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/dns-server/testsuite/tests/DnsServerHelperFunctions.ycp?rev=67408&view=auto ============================================================================== --- trunk/dns-server/testsuite/tests/DnsServerHelperFunctions.ycp (added) +++ trunk/dns-server/testsuite/tests/DnsServerHelperFunctions.ycp Fri Feb 10 13:27:51 2012 @@ -0,0 +1,113 @@ +/** + * File: DnsServerHelperFunctions.ycp + * Package: Configuration of dns-server + * Summary: Testsuite helper module + * Authors: Lukas Ocilka <locilka@suse.com> + * Copyright: Copyright 2012, Novell, Inc. All rights reserved. + * + * $Id$ + * + * Testsuite for helper functions module + */ + +{ + include "testsuite.ycp"; + // testedfiles: DnsServerHelperFunctions.ycp + + map READ = $[]; + map WRITE = $[]; + map EXEC = $[]; + + TESTSUITE_INIT ([READ, WRITE, EXEC], nil); + + import "DnsServerHelperFunctions"; + import "Mode"; + + Mode::SetMode("test"); + + string zone = "example.com"; + + DUMP ("=========================================================="); + + // cuts the zone name off + TEST (``(DnsServerHelperFunctions::RRToRelativeName ( + "dhcp1." + zone + ".", + zone, + "A", + "key" + )), [READ, WRITE, EXEC], nil); + + // CNAME - key can be relative + TEST (``(DnsServerHelperFunctions::RRToRelativeName ( + "relative-name-1." + zone + ".", + zone, + "cname", + "key" + )), [READ, WRITE, EXEC], nil); + + // CNAME - value can be relative + TEST (``(DnsServerHelperFunctions::RRToRelativeName ( + "relative-name-2." + zone + ".", + zone, + "cname", + "value" + )), [READ, WRITE, EXEC], nil); + + // cuts the zone name off (leaves subdomain) + TEST (``(DnsServerHelperFunctions::RRToRelativeName ( + "dhcp1.subdomain." + zone + ".", + zone, + "A", + "key" + )), [READ, WRITE, EXEC], nil); + + // different zone name + TEST (``(DnsServerHelperFunctions::RRToRelativeName ( + "dhcp1.different-" + zone + ".", + zone, + "A", + "key" + )), [READ, WRITE, EXEC], nil); + + // TXT record (value), not changed + TEST (``(DnsServerHelperFunctions::RRToRelativeName ( + "v=spf1 include:" + zone + " -all", + zone, + "TXT", + "value" + )), [READ, WRITE, EXEC], nil); + + // TXT record (key), can be realtive + TEST (``(DnsServerHelperFunctions::RRToRelativeName ( + "some-text." + zone + ".", + zone, + "TXT", + "key" + )), [READ, WRITE, EXEC], nil); + + // SPF record (value), not changed + TEST (``(DnsServerHelperFunctions::RRToRelativeName ( + "v=spf1 include:" + zone + " -all", + zone, + "SPF", + "value" + )), [READ, WRITE, EXEC], nil); + + // SRV record (key) can be realtive + TEST (``(DnsServerHelperFunctions::RRToRelativeName ( + "_http._tcp." + zone + ".", + zone, + "SRV", + "key" + )), [READ, WRITE, EXEC], nil); + + // SRV record (value) can't be realtive + TEST (``(DnsServerHelperFunctions::RRToRelativeName ( + "0 5 80 " + zone + ".", + zone, + "SRV", + "value" + )), [READ, WRITE, EXEC], nil); + + DUMP ("=========================================================="); +} -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
locilka@svn2.opensuse.org