github.com/iDigitalFlame/xmt@v0.5.4/c2/cfg/transform_test.go (about) 1 // Copyright (C) 2020 - 2023 iDigitalFlame 2 // 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation, either version 3 of the License, or 6 // any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program. If not, see <https://www.gnu.org/licenses/>. 15 // 16 17 package cfg 18 19 import "testing" 20 21 func TestTransform(t *testing.T) { 22 c := Pack( 23 TransformB64, 24 TransformB64Shift(10), 25 TransformDNS("test.com"), 26 ) 27 28 if _, err := c.Build(); err == nil { 29 t.Fatalf("TestTransform(): Invalid build should have failed!") 30 } 31 32 if n := c.Len(); n != 14 { 33 t.Fatalf(`TestTransform(): Len returned invalid size "%d" should ne "14"!`, n) 34 } 35 if c[0] != byte(TransformB64) { 36 t.Fatalf(`TestTransform(): Invalid byte at position "0"!`) 37 } 38 if c[1] != byte(valB64Shift) || c[2] != 10 { 39 t.Fatalf(`TestTransform(): Invalid byte at position "1"!`) 40 } 41 if c[3] != byte(valDNS) || c[6] != 't' { 42 t.Fatalf(`TestTransform(): Invalid byte at position "3:6"!`) 43 } 44 }