1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

BIND: Simplify serial number generation (#652)

* The old algorithm was very complex for no good reason.
* The new algorithm is simply: Use yymmdd00 or (previous serial number +1) whichever is bigger.
This commit is contained in:
Tom Limoncelli
2020-02-23 14:50:00 -05:00
committed by GitHub
parent 772ca4e7dd
commit 3ce5b22d1a
3 changed files with 18 additions and 32 deletions

View File

@ -14,28 +14,31 @@ func Test_generate_serial_1(t *testing.T) {
Today time.Time
Expected uint32
}{
{0, d1, 2015010801},
{123, d1, 2015010801},
{0, d1, 2015010800},
{1, d1, 2015010800},
{123, d1, 2015010800},
{2015010800, d1, 2015010801},
{2015010801, d1, 2015010802},
{2015010802, d1, 2015010803},
{2015010898, d1, 2015010899},
{2015010899, d1, 2015010900},
{2015090401, d1, 2015090402},
{201509040, d1, 2015010801},
{20150904, d1, 2015010801},
{2015090, d1, 2015010801},
{201509040, d1, 2015010800},
{20150904, d1, 2015010800},
{2015090, d1, 2015010800},
// If the number is very large, just increment:
{2099000000, d1, 2099000001},
// Verify 32-bits is enough to carry us 200 years in the future:
{4015090401, d4, 4015090402},
// Verify Dec 31 edge-case:
{2015123099, d12, 2015123101},
{2015123099, d12, 2015123100},
{2015123100, d12, 2015123101},
{2015123101, d12, 2015123102},
{2015123102, d12, 2015123103},
{2015123198, d12, 2015123199},
{2015123199, d12, 2015123200},
{2015123200, d12, 2015123201},
{201512310, d12, 2015123101},
{201512310, d12, 2015123100},
}
for i, tst := range tests {