Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
403 changes: 403 additions & 0 deletions .github/workflows/build.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
AUTOMAKE_OPTIONS = gnu

SUBDIRS = src doc
SUBDIRS = src doc tests
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@ AC_CHECK_FUNCS([strchr strdup strerror strstr getline getopt_long regcomp strnca

AC_CONFIG_FILES([Makefile
doc/Makefile
src/Makefile])
src/Makefile
tests/Makefile])
AC_OUTPUT
40 changes: 40 additions & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Tests for ffe

AM_CFLAGS = -I$(top_srcdir)/src
AM_CPPFLAGS = -I$(top_srcdir)/src $(LIBGCRYPT_CFLAGS)
LDADD = $(LIBGCRYPT_LIBS)
TESTS_ENVIRONMENT = FFE_BIN='$(FFE_BIN)' srcdir='$(srcdir)'

# Path to the ffe binary
FFE_BIN = $(top_builddir)/src/ffe

# Test scripts (shell scripts)
TESTS = run_tests.sh

# Ensure ffe binary is built before tests run
check-local: $(FFE_BIN)

$(FFE_BIN):
cd $(top_builddir)/src && $(MAKE) ffe

clean-local:
rm -f *.log

# Distribute all test files including subdirectories
EXTRA_DIST = run_tests.sh \
fixed_length/fixed_length.fferc \
fixed_length/fixed_length.input \
fixed_length/fixed_length.expected \
fixed_length/test_fixed_length.sh \
separated/separated.fferc \
separated/separated.input \
separated/separated.expected \
separated/test_separated.sh \
binary/binary.fferc \
binary/binary.input \
binary/binary.expected \
binary/test_binary.sh \
expressions/expression.expected \
expressions/fixed_length.fferc \
expressions/fixed_length.input \
expressions/test_expressions.sh
4 changes: 4 additions & 0 deletions tests/anonymize/anonymize.input
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Alice,Johnson,35,12345
Bob,Smith,42,67890
Carol,Williams,28,54321
David,Brown,51,98765
26 changes: 26 additions & 0 deletions tests/anonymize/anonymize_basic.fferc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
structure data {
type separated ,

record person {
field first_name
field last_name
field age
field id
}
}

anonymize test1 {
method first_name MASK
method last_name MASK 2
method age MASK -2 1
method id MASK 1 3
}

output raw {
data "%d"
}

output default {
data "%n: %t\n"
indent " "
}
29 changes: 29 additions & 0 deletions tests/anonymize/anonymize_bcd.fferc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
structure bcd_test
{
type binary
record bcd_record
{
field bcd_field bcd_be_3
}
}

anonymize test_bcd_mask {
method bcd_field MASK
}

anonymize test_bcd_hash {
method bcd_field HASH
}

anonymize test_bcd_random {
method bcd_field RANDOM
}

output raw {
data "%d"
}

output default
{
data "%n = %d (%h)\n"
}
28 changes: 28 additions & 0 deletions tests/anonymize/anonymize_binary.fferc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
structure bin_data
{
type binary
record b
{
field text 5
field byte_int int8
field integer int32_le
field number double_le
field bcd_number bcd_be_3
field hex hex_be_4
}
}

anonymize test_binary {
method text MASK
method integer RANDOM
method bcd_number HASH
}

output raw {
data "%d"
}

output default
{
data "%n = %d (%h)\n"
}
20 changes: 20 additions & 0 deletions tests/anonymize/anonymize_fixed.fferc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
structure data {
type fixed
record person {
field first_name 10
field last_name 10
field age 3
field id 5
}
}

anonymize test_fixed {
method first_name HASH
method last_name HASH 2
method age NRANDOM
method id MASK
}

output default {
data "%d"
}
4 changes: 4 additions & 0 deletions tests/anonymize/anonymize_fixed.input
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Alice Johnson 03512345
Bob Smith 04267890
Carol Williams 02854321
David Brown 05198765
4 changes: 4 additions & 0 deletions tests/anonymize/anonymize_fixed_exact.input
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Alice Johnson 03512345
Bob Smith 04267890
Carol Williams 02854321
David Brown 05198765
26 changes: 26 additions & 0 deletions tests/anonymize/anonymize_hash.fferc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
structure data {
type separated ,

record person {
field first_name
field last_name
field age
field id
}
}

anonymize test_hash {
method first_name HASH
method last_name HASH 2
method age NHASH
method id HASH 1 3
}

output raw {
data "%d"
}

output default {
data "%n: %t\n"
indent " "
}
39 changes: 39 additions & 0 deletions tests/anonymize/anonymize_hash_length.fferc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
structure data {
type separated ,

record person {
field first_name
field last_name
field age
field id
}
}

anonymize test_hash_length_16 {
method first_name HASH 1 0 16
method id HASH 1 0 16
}

anonymize test_hash_length_32 {
method first_name HASH 1 0 32
method id HASH 1 0 32
}

anonymize test_hash_length_64 {
method first_name HASH 1 0 64
method id HASH 1 0 64
}

anonymize test_hash_no_key {
method first_name HASH
method id HASH
}

output raw {
data "%d"
}

output default {
data "%n: %t\n"
indent " "
}
21 changes: 21 additions & 0 deletions tests/anonymize/anonymize_mask_char.fferc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
structure data {
type separated ,

record person {
field first_name
field last_name
field age
field id
}
}

anonymize test_mask_char {
method first_name MASK 1 0 "*"
method last_name MASK 1 0 "X"
method age MASK 1 0 "9"
method id MASK 1 0 "#"
}

output raw {
data "%d"
}
25 changes: 25 additions & 0 deletions tests/anonymize/anonymize_partial.fferc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
structure data {
type separated ,

record person {
field first_name
field last_name
field age
field id
}
}

anonymize test_partial {
# anonymize all but first character
method first_name MASK 2 0 "."
# anonymize last 3 characters
method last_name MASK -3 0 "X"
# anonymize middle character (position 2, length 1)
method age MASK 2 1 "*"
# anonymize first 3 characters
method id MASK 1 3 "#"
}

output raw {
data "%d"
}
26 changes: 26 additions & 0 deletions tests/anonymize/anonymize_random.fferc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
structure data {
type separated ,

record person {
field first_name
field last_name
field age
field id
}
}

anonymize test_random {
method first_name RANDOM
method last_name RANDOM
method age RANDOM
method id RANDOM
}

output raw {
data "%d"
}

output default {
data "%n: %t\n"
indent " "
}
1 change: 1 addition & 0 deletions tests/anonymize/bcd.input
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4E
4 changes: 4 additions & 0 deletions tests/anonymize/expected_fixed.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
P2Pl8h801KPLYSyu4Pnq76700000
0d6REUC5n 0MH2O6Njpa48200000
D3UKSHxYakDAjyUgr Er88100000
ubG PC1KhQuVyP8Kvx8q06300000
4 changes: 4 additions & 0 deletions tests/anonymize/expected_hash.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
a9T7U,JndZRAG,86,4yD45
k43,ShVt ,18,T1x90
KBLRI,WQ1JEYxB,11,1HF21
7E7mB,BlZ0I,06,6xw65
4 changes: 4 additions & 0 deletions tests/anonymize/expected_hash_length_16.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
a9T7U,Johnson,35,4yDDi
k43,Smith,42,T1xz7
KBLRI,Williams,28,1HFFh
7E7mB,Brown,51,6xwPy
4 changes: 4 additions & 0 deletions tests/anonymize/expected_hash_length_32.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
w8FYO,Johnson,35,PL8Py
FWo,Smith,42,aWzzE
pVzBm,Williams,28,VrsO2
dsCVe,Brown,51,vpw7j
4 changes: 4 additions & 0 deletions tests/anonymize/expected_hash_length_64.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eL3qO,Johnson,35,rcHRe
BzQ,Smith,42,WR6Zh
jHp8u,Williams,28,Zjhml
EE gE,Brown,51,3rUUa
4 changes: 4 additions & 0 deletions tests/anonymize/expected_hash_no_key.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
a9T7U,Johnson,35,4yDDi
k43,Smith,42,T1xz7
KBLRI,Williams,28,1HFFh
7E7mB,Brown,51,6xwPy
4 changes: 4 additions & 0 deletions tests/anonymize/expected_mask.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
00000,J000000,05,00045
000,S0000,02,00090
00000,W0000000,08,00021
00000,B0000,01,00065
4 changes: 4 additions & 0 deletions tests/anonymize/expected_mask_char.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*****,XXXXXXX,99,#####
***,XXXXX,99,#####
*****,XXXXXXXX,99,#####
*****,XXXXX,99,#####
4 changes: 4 additions & 0 deletions tests/anonymize/expected_partial.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
A....,XXXXXon,3*,###45
B..,XXXth,4*,###90
C....,XXXXXXms,2*,###21
D....,XXXwn,5*,###65
Loading