diff --git a/test/diff_check/build_matrix_test.exs b/test/diff_check/build_matrix_test.exs index caeb6c4..aba9e2f 100644 --- a/test/diff_check/build_matrix_test.exs +++ b/test/diff_check/build_matrix_test.exs @@ -47,4 +47,675 @@ defmodule DiffCheck.BuildMatrixTest do assert BuildMatrix.call(list1, list2) == expected_result end + + test "with inverted list builds a 2D hash map" do + list1 = ["B", "D", "C", "A", "B"] + list2 = ["A", "B", "C", "B", "D", "A", "B"] + + expected_result = %{ + {0, 0} => 0, + {0, 1} => 1, + {0, 2} => 1, + {0, 3} => 1, + {0, 4} => 1, + {1, 0} => 0, + {1, 1} => 1, + {1, 2} => 1, + {1, 3} => 1, + {1, 4} => 2, + {2, 0} => 0, + {2, 1} => 1, + {2, 2} => 2, + {2, 3} => 2, + {2, 4} => 2, + {3, 0} => 1, + {3, 1} => 1, + {3, 2} => 2, + {3, 3} => 2, + {3, 4} => 2, + {4, 0} => 1, + {4, 1} => 2, + {4, 2} => 2, + {4, 3} => 3, + {4, 4} => 3, + {0, 5} => 1, + {0, 6} => 1, + {1, 5} => 2, + {1, 6} => 2, + {2, 5} => 2, + {2, 6} => 2, + {3, 5} => 3, + {3, 6} => 3, + {4, 5} => 3, + {4, 6} => 4 + } + + assert BuildMatrix.call(list1, list2) == expected_result + end + + test "with fixture files builds a map" do + file1 = read_file("../support/fixtures/test_response_1.json") + file2 = read_file("../support/fixtures/test_response_2.json") + + expected_result = %{ + {0, 0} => 1, + {0, 1} => 1, + {0, 2} => 1, + {0, 3} => 1, + {0, 4} => 1, + {0, 5} => 1, + {0, 6} => 1, + {0, 7} => 1, + {0, 8} => 1, + {0, 9} => 1, + {0, 10} => 1, + {0, 11} => 1, + {0, 12} => 1, + {0, 13} => 1, + {0, 14} => 1, + {0, 15} => 1, + {0, 16} => 1, + {0, 17} => 1, + {0, 18} => 1, + {0, 19} => 1, + {0, 20} => 1, + {0, 21} => 1, + {0, 22} => 1, + {0, 23} => 1, + {0, 24} => 1, + {0, 25} => 1, + {0, 26} => 1, + {0, 27} => 1, + {0, 28} => 1, + {1, 0} => 1, + {1, 1} => 2, + {1, 2} => 2, + {1, 3} => 2, + {1, 4} => 2, + {1, 5} => 2, + {1, 6} => 2, + {1, 7} => 2, + {1, 8} => 2, + {1, 9} => 2, + {1, 10} => 2, + {1, 11} => 2, + {1, 12} => 2, + {1, 13} => 2, + {1, 14} => 2, + {1, 15} => 2, + {1, 16} => 2, + {1, 17} => 2, + {1, 18} => 2, + {1, 19} => 2, + {1, 20} => 2, + {1, 21} => 2, + {1, 22} => 2, + {1, 23} => 2, + {1, 24} => 2, + {1, 25} => 2, + {1, 26} => 2, + {1, 27} => 2, + {1, 28} => 2, + {2, 0} => 1, + {2, 1} => 2, + {2, 2} => 3, + {2, 3} => 3, + {2, 4} => 3, + {2, 5} => 3, + {2, 6} => 3, + {2, 7} => 3, + {2, 8} => 3, + {2, 9} => 3, + {2, 10} => 3, + {2, 11} => 3, + {2, 12} => 3, + {2, 13} => 3, + {2, 14} => 3, + {2, 15} => 3, + {2, 16} => 3, + {2, 17} => 3, + {2, 18} => 3, + {2, 19} => 3, + {2, 20} => 3, + {2, 21} => 3, + {2, 22} => 3, + {2, 23} => 3, + {2, 24} => 3, + {2, 25} => 3, + {2, 26} => 3, + {2, 27} => 3, + {2, 28} => 3, + {3, 0} => 1, + {3, 1} => 2, + {3, 2} => 3, + {3, 3} => 4, + {3, 4} => 4, + {3, 5} => 4, + {3, 6} => 4, + {3, 7} => 4, + {3, 8} => 4, + {3, 9} => 4, + {3, 10} => 4, + {3, 11} => 4, + {3, 12} => 4, + {3, 13} => 4, + {3, 14} => 4, + {3, 15} => 4, + {3, 16} => 4, + {3, 17} => 4, + {3, 18} => 4, + {3, 19} => 4, + {3, 20} => 4, + {3, 21} => 4, + {3, 22} => 4, + {3, 23} => 4, + {3, 24} => 4, + {3, 25} => 4, + {3, 26} => 4, + {3, 27} => 4, + {3, 28} => 4, + {4, 0} => 1, + {4, 1} => 2, + {4, 2} => 3, + {4, 3} => 4, + {4, 4} => 5, + {4, 5} => 5, + {4, 6} => 5, + {4, 7} => 5, + {4, 8} => 5, + {4, 9} => 5, + {4, 10} => 5, + {4, 11} => 5, + {4, 12} => 5, + {4, 13} => 5, + {4, 14} => 5, + {4, 15} => 5, + {4, 16} => 5, + {4, 17} => 5, + {4, 18} => 5, + {4, 19} => 5, + {4, 20} => 5, + {4, 21} => 5, + {4, 22} => 5, + {4, 23} => 5, + {4, 24} => 5, + {4, 25} => 5, + {4, 26} => 5, + {4, 27} => 5, + {4, 28} => 5, + {5, 0} => 1, + {5, 1} => 2, + {5, 2} => 3, + {5, 3} => 4, + {5, 4} => 5, + {5, 5} => 6, + {5, 6} => 6, + {5, 7} => 6, + {5, 8} => 6, + {5, 9} => 6, + {5, 10} => 6, + {5, 11} => 6, + {5, 12} => 6, + {5, 13} => 6, + {5, 14} => 6, + {5, 15} => 6, + {5, 16} => 6, + {5, 17} => 6, + {5, 18} => 6, + {5, 19} => 6, + {5, 20} => 6, + {5, 21} => 6, + {5, 22} => 6, + {5, 23} => 6, + {5, 24} => 6, + {5, 25} => 6, + {5, 26} => 6, + {5, 27} => 6, + {5, 28} => 6, + {6, 0} => 1, + {6, 1} => 2, + {6, 2} => 3, + {6, 3} => 4, + {6, 4} => 5, + {6, 5} => 6, + {6, 6} => 7, + {6, 7} => 7, + {6, 8} => 7, + {6, 9} => 7, + {6, 10} => 7, + {6, 11} => 7, + {6, 12} => 7, + {6, 13} => 7, + {6, 14} => 7, + {6, 15} => 7, + {6, 16} => 7, + {6, 17} => 7, + {6, 18} => 7, + {6, 19} => 7, + {6, 20} => 7, + {6, 21} => 7, + {6, 22} => 7, + {6, 23} => 7, + {6, 24} => 7, + {6, 25} => 7, + {6, 26} => 7, + {6, 27} => 7, + {6, 28} => 7, + {7, 0} => 1, + {7, 1} => 2, + {7, 2} => 3, + {7, 3} => 4, + {7, 4} => 5, + {7, 5} => 6, + {7, 6} => 7, + {7, 7} => 7, + {7, 8} => 7, + {7, 9} => 7, + {7, 10} => 7, + {7, 11} => 7, + {7, 12} => 7, + {7, 13} => 7, + {7, 14} => 7, + {7, 15} => 8, + {7, 16} => 8, + {7, 17} => 8, + {7, 18} => 8, + {7, 19} => 8, + {7, 20} => 8, + {7, 21} => 8, + {7, 22} => 8, + {7, 23} => 8, + {7, 24} => 8, + {7, 25} => 8, + {7, 26} => 8, + {7, 27} => 8, + {7, 28} => 8, + {8, 0} => 1, + {8, 1} => 2, + {8, 2} => 3, + {8, 3} => 4, + {8, 4} => 5, + {8, 5} => 6, + {8, 6} => 7, + {8, 7} => 7, + {8, 8} => 7, + {8, 9} => 7, + {8, 10} => 7, + {8, 11} => 7, + {8, 12} => 7, + {8, 13} => 7, + {8, 14} => 7, + {8, 15} => 8, + {8, 16} => 8, + {8, 17} => 8, + {8, 18} => 8, + {8, 19} => 8, + {8, 20} => 8, + {8, 21} => 8, + {8, 22} => 8, + {8, 23} => 8, + {8, 24} => 8, + {8, 25} => 8, + {8, 26} => 8, + {8, 27} => 8, + {8, 28} => 8, + {9, 0} => 1, + {9, 1} => 2, + {9, 2} => 3, + {9, 3} => 4, + {9, 4} => 5, + {9, 5} => 6, + {9, 6} => 7, + {9, 7} => 7, + {9, 8} => 7, + {9, 9} => 8, + {9, 10} => 8, + {9, 11} => 8, + {9, 12} => 8, + {9, 13} => 8, + {9, 14} => 8, + {9, 15} => 8, + {9, 16} => 8, + {9, 17} => 9, + {9, 18} => 9, + {9, 19} => 9, + {9, 20} => 9, + {9, 21} => 9, + {9, 22} => 9, + {9, 23} => 9, + {9, 24} => 9, + {9, 25} => 9, + {9, 26} => 9, + {9, 27} => 9, + {9, 28} => 9, + {10, 0} => 1, + {10, 1} => 2, + {10, 2} => 3, + {10, 3} => 4, + {10, 4} => 5, + {10, 5} => 6, + {10, 6} => 7, + {10, 7} => 7, + {10, 8} => 7, + {10, 9} => 8, + {10, 10} => 9, + {10, 11} => 9, + {10, 12} => 9, + {10, 13} => 9, + {10, 14} => 9, + {10, 15} => 9, + {10, 16} => 9, + {10, 17} => 9, + {10, 18} => 10, + {10, 19} => 10, + {10, 20} => 10, + {10, 21} => 10, + {10, 22} => 10, + {10, 23} => 10, + {10, 24} => 10, + {10, 25} => 10, + {10, 26} => 10, + {10, 27} => 10, + {10, 28} => 10, + {11, 0} => 1, + {11, 1} => 2, + {11, 2} => 3, + {11, 3} => 4, + {11, 4} => 5, + {11, 5} => 6, + {11, 6} => 7, + {11, 7} => 7, + {11, 8} => 7, + {11, 9} => 8, + {11, 10} => 9, + {11, 11} => 9, + {11, 12} => 9, + {11, 13} => 9, + {11, 14} => 9, + {11, 15} => 9, + {11, 16} => 9, + {11, 17} => 9, + {11, 18} => 10, + {11, 19} => 11, + {11, 20} => 11, + {11, 21} => 11, + {11, 22} => 11, + {11, 23} => 11, + {11, 24} => 11, + {11, 25} => 11, + {11, 26} => 11, + {11, 27} => 11, + {11, 28} => 11, + {12, 0} => 1, + {12, 1} => 2, + {12, 2} => 3, + {12, 3} => 4, + {12, 4} => 5, + {12, 5} => 6, + {12, 6} => 7, + {12, 7} => 7, + {12, 8} => 7, + {12, 9} => 8, + {12, 10} => 9, + {12, 11} => 9, + {12, 12} => 9, + {12, 13} => 9, + {12, 14} => 9, + {12, 15} => 9, + {12, 16} => 9, + {12, 17} => 9, + {12, 18} => 10, + {12, 19} => 11, + {12, 20} => 12, + {12, 21} => 12, + {12, 22} => 12, + {12, 23} => 12, + {12, 24} => 12, + {12, 25} => 12, + {12, 26} => 12, + {12, 27} => 12, + {12, 28} => 12, + {13, 0} => 1, + {13, 1} => 2, + {13, 2} => 3, + {13, 3} => 4, + {13, 4} => 5, + {13, 5} => 6, + {13, 6} => 7, + {13, 7} => 7, + {13, 8} => 7, + {13, 9} => 8, + {13, 10} => 9, + {13, 11} => 9, + {13, 12} => 9, + {13, 13} => 9, + {13, 14} => 9, + {13, 15} => 9, + {13, 16} => 9, + {13, 17} => 9, + {13, 18} => 10, + {13, 19} => 11, + {13, 20} => 12, + {13, 21} => 13, + {13, 22} => 13, + {13, 23} => 13, + {13, 24} => 13, + {13, 25} => 13, + {13, 26} => 13, + {13, 27} => 13, + {13, 28} => 13, + {14, 0} => 1, + {14, 1} => 2, + {14, 2} => 3, + {14, 3} => 4, + {14, 4} => 5, + {14, 5} => 6, + {14, 6} => 7, + {14, 7} => 7, + {14, 8} => 7, + {14, 9} => 8, + {14, 10} => 9, + {14, 11} => 9, + {14, 12} => 9, + {14, 13} => 9, + {14, 14} => 9, + {14, 15} => 9, + {14, 16} => 9, + {14, 17} => 9, + {14, 18} => 10, + {14, 19} => 11, + {14, 20} => 12, + {14, 21} => 13, + {14, 22} => 14, + {14, 23} => 14, + {14, 24} => 14, + {14, 25} => 14, + {14, 26} => 14, + {14, 27} => 14, + {14, 28} => 14, + {15, 0} => 1, + {15, 1} => 2, + {15, 2} => 3, + {15, 3} => 4, + {15, 4} => 5, + {15, 5} => 6, + {15, 6} => 7, + {15, 7} => 7, + {15, 8} => 7, + {15, 9} => 8, + {15, 10} => 9, + {15, 11} => 9, + {15, 12} => 9, + {15, 13} => 9, + {15, 14} => 9, + {15, 15} => 9, + {15, 16} => 9, + {15, 17} => 9, + {15, 18} => 10, + {15, 19} => 11, + {15, 20} => 12, + {15, 21} => 13, + {15, 22} => 14, + {15, 23} => 15, + {15, 24} => 15, + {15, 25} => 15, + {15, 26} => 15, + {15, 27} => 15, + {15, 28} => 15, + {16, 0} => 1, + {16, 1} => 2, + {16, 2} => 3, + {16, 3} => 4, + {16, 4} => 5, + {16, 5} => 6, + {16, 6} => 7, + {16, 7} => 7, + {16, 8} => 7, + {16, 9} => 8, + {16, 10} => 9, + {16, 11} => 9, + {16, 12} => 9, + {16, 13} => 9, + {16, 14} => 9, + {16, 15} => 9, + {16, 16} => 9, + {16, 17} => 9, + {16, 18} => 10, + {16, 19} => 11, + {16, 20} => 12, + {16, 21} => 13, + {16, 22} => 14, + {16, 23} => 15, + {16, 24} => 15, + {16, 25} => 15, + {16, 26} => 15, + {16, 27} => 15, + {16, 28} => 15, + {17, 0} => 1, + {17, 1} => 2, + {17, 2} => 3, + {17, 3} => 4, + {17, 4} => 5, + {17, 5} => 6, + {17, 6} => 7, + {17, 7} => 7, + {17, 8} => 7, + {17, 9} => 8, + {17, 10} => 9, + {17, 11} => 9, + {17, 12} => 9, + {17, 13} => 9, + {17, 14} => 9, + {17, 15} => 9, + {17, 16} => 9, + {17, 17} => 9, + {17, 18} => 10, + {17, 19} => 11, + {17, 20} => 12, + {17, 21} => 13, + {17, 22} => 14, + {17, 23} => 15, + {17, 24} => 15, + {17, 25} => 16, + {17, 26} => 16, + {17, 27} => 16, + {17, 28} => 16, + {18, 0} => 1, + {18, 1} => 2, + {18, 2} => 3, + {18, 3} => 4, + {18, 4} => 5, + {18, 5} => 6, + {18, 6} => 7, + {18, 7} => 7, + {18, 8} => 7, + {18, 9} => 8, + {18, 10} => 9, + {18, 11} => 9, + {18, 12} => 9, + {18, 13} => 9, + {18, 14} => 9, + {18, 15} => 9, + {18, 16} => 9, + {18, 17} => 9, + {18, 18} => 10, + {18, 19} => 11, + {18, 20} => 12, + {18, 21} => 13, + {18, 22} => 14, + {18, 23} => 15, + {18, 24} => 15, + {18, 25} => 16, + {18, 26} => 17, + {18, 27} => 17, + {18, 28} => 17, + {19, 0} => 1, + {19, 1} => 2, + {19, 2} => 3, + {19, 3} => 4, + {19, 4} => 5, + {19, 5} => 6, + {19, 6} => 7, + {19, 7} => 7, + {19, 8} => 7, + {19, 9} => 8, + {19, 10} => 9, + {19, 11} => 9, + {19, 12} => 9, + {19, 13} => 9, + {19, 14} => 9, + {19, 15} => 9, + {19, 16} => 9, + {19, 17} => 9, + {19, 18} => 10, + {19, 19} => 11, + {19, 20} => 12, + {19, 21} => 13, + {19, 22} => 14, + {19, 23} => 15, + {19, 24} => 15, + {19, 25} => 16, + {19, 26} => 17, + {19, 27} => 18, + {19, 28} => 18, + {20, 0} => 1, + {20, 1} => 2, + {20, 2} => 3, + {20, 3} => 4, + {20, 4} => 5, + {20, 5} => 6, + {20, 6} => 7, + {20, 7} => 7, + {20, 8} => 7, + {20, 9} => 8, + {20, 10} => 9, + {20, 11} => 9, + {20, 12} => 9, + {20, 13} => 9, + {20, 14} => 9, + {20, 15} => 9, + {20, 16} => 9, + {20, 17} => 9, + {20, 18} => 10, + {20, 19} => 11, + {20, 20} => 12, + {20, 21} => 13, + {20, 22} => 14, + {20, 23} => 15, + {20, 24} => 15, + {20, 25} => 16, + {20, 26} => 17, + {20, 27} => 18, + {20, 28} => 19 + } + + assert BuildMatrix.call(file1, file2) == expected_result + end + + defp read_file(file_path) do + file_path + |> Path.expand(__DIR__) + |> File.read!() + |> String.split("\n") + end end diff --git a/test/diff_check/print_diff_test.exs b/test/diff_check/print_diff_test.exs index 504d8cb..df41f2a 100644 --- a/test/diff_check/print_diff_test.exs +++ b/test/diff_check/print_diff_test.exs @@ -58,4 +58,720 @@ defmodule DiffCheck.PrintDiffTest do assert PrintDiff.call(matrix, list1, list2) == expected_result end + + test "with inverted lists builds the correct list of the diff" do + list1 = ["B", "D", "C", "A", "B"] + list2 = ["A", "B", "C", "B", "D", "A", "B"] + + matrix = %{ + {0, 0} => 0, + {0, 1} => 1, + {0, 2} => 1, + {0, 3} => 1, + {0, 4} => 1, + {1, 0} => 0, + {1, 1} => 1, + {1, 2} => 1, + {1, 3} => 1, + {1, 4} => 2, + {2, 0} => 0, + {2, 1} => 1, + {2, 2} => 2, + {2, 3} => 2, + {2, 4} => 2, + {3, 0} => 1, + {3, 1} => 1, + {3, 2} => 2, + {3, 3} => 2, + {3, 4} => 2, + {4, 0} => 1, + {4, 1} => 2, + {4, 2} => 2, + {4, 3} => 3, + {4, 4} => 3, + {0, 5} => 1, + {0, 6} => 1, + {1, 5} => 2, + {1, 6} => 2, + {2, 5} => 2, + {2, 6} => 2, + {3, 5} => 3, + {3, 6} => 3, + {4, 5} => 3, + {4, 6} => 4 + } + + expected_result = [ + "+ A", + " B", + "- D", + " C", + "+ B", + "+ D", + " A", + " B" + ] + + assert PrintDiff.call(matrix, list1, list2) == expected_result + end + + test "with fixture files lists the diff between both files" do + file1 = read_file("../support/fixtures/test_response_1.json") + file2 = read_file("../support/fixtures/test_response_2.json") + + matrix = %{ + {0, 0} => 1, + {0, 1} => 1, + {0, 2} => 1, + {0, 3} => 1, + {0, 4} => 1, + {0, 5} => 1, + {0, 6} => 1, + {0, 7} => 1, + {0, 8} => 1, + {0, 9} => 1, + {0, 10} => 1, + {0, 11} => 1, + {0, 12} => 1, + {0, 13} => 1, + {0, 14} => 1, + {0, 15} => 1, + {0, 16} => 1, + {0, 17} => 1, + {0, 18} => 1, + {0, 19} => 1, + {0, 20} => 1, + {0, 21} => 1, + {0, 22} => 1, + {0, 23} => 1, + {0, 24} => 1, + {0, 25} => 1, + {0, 26} => 1, + {0, 27} => 1, + {0, 28} => 1, + {1, 0} => 1, + {1, 1} => 2, + {1, 2} => 2, + {1, 3} => 2, + {1, 4} => 2, + {1, 5} => 2, + {1, 6} => 2, + {1, 7} => 2, + {1, 8} => 2, + {1, 9} => 2, + {1, 10} => 2, + {1, 11} => 2, + {1, 12} => 2, + {1, 13} => 2, + {1, 14} => 2, + {1, 15} => 2, + {1, 16} => 2, + {1, 17} => 2, + {1, 18} => 2, + {1, 19} => 2, + {1, 20} => 2, + {1, 21} => 2, + {1, 22} => 2, + {1, 23} => 2, + {1, 24} => 2, + {1, 25} => 2, + {1, 26} => 2, + {1, 27} => 2, + {1, 28} => 2, + {2, 0} => 1, + {2, 1} => 2, + {2, 2} => 3, + {2, 3} => 3, + {2, 4} => 3, + {2, 5} => 3, + {2, 6} => 3, + {2, 7} => 3, + {2, 8} => 3, + {2, 9} => 3, + {2, 10} => 3, + {2, 11} => 3, + {2, 12} => 3, + {2, 13} => 3, + {2, 14} => 3, + {2, 15} => 3, + {2, 16} => 3, + {2, 17} => 3, + {2, 18} => 3, + {2, 19} => 3, + {2, 20} => 3, + {2, 21} => 3, + {2, 22} => 3, + {2, 23} => 3, + {2, 24} => 3, + {2, 25} => 3, + {2, 26} => 3, + {2, 27} => 3, + {2, 28} => 3, + {3, 0} => 1, + {3, 1} => 2, + {3, 2} => 3, + {3, 3} => 4, + {3, 4} => 4, + {3, 5} => 4, + {3, 6} => 4, + {3, 7} => 4, + {3, 8} => 4, + {3, 9} => 4, + {3, 10} => 4, + {3, 11} => 4, + {3, 12} => 4, + {3, 13} => 4, + {3, 14} => 4, + {3, 15} => 4, + {3, 16} => 4, + {3, 17} => 4, + {3, 18} => 4, + {3, 19} => 4, + {3, 20} => 4, + {3, 21} => 4, + {3, 22} => 4, + {3, 23} => 4, + {3, 24} => 4, + {3, 25} => 4, + {3, 26} => 4, + {3, 27} => 4, + {3, 28} => 4, + {4, 0} => 1, + {4, 1} => 2, + {4, 2} => 3, + {4, 3} => 4, + {4, 4} => 5, + {4, 5} => 5, + {4, 6} => 5, + {4, 7} => 5, + {4, 8} => 5, + {4, 9} => 5, + {4, 10} => 5, + {4, 11} => 5, + {4, 12} => 5, + {4, 13} => 5, + {4, 14} => 5, + {4, 15} => 5, + {4, 16} => 5, + {4, 17} => 5, + {4, 18} => 5, + {4, 19} => 5, + {4, 20} => 5, + {4, 21} => 5, + {4, 22} => 5, + {4, 23} => 5, + {4, 24} => 5, + {4, 25} => 5, + {4, 26} => 5, + {4, 27} => 5, + {4, 28} => 5, + {5, 0} => 1, + {5, 1} => 2, + {5, 2} => 3, + {5, 3} => 4, + {5, 4} => 5, + {5, 5} => 6, + {5, 6} => 6, + {5, 7} => 6, + {5, 8} => 6, + {5, 9} => 6, + {5, 10} => 6, + {5, 11} => 6, + {5, 12} => 6, + {5, 13} => 6, + {5, 14} => 6, + {5, 15} => 6, + {5, 16} => 6, + {5, 17} => 6, + {5, 18} => 6, + {5, 19} => 6, + {5, 20} => 6, + {5, 21} => 6, + {5, 22} => 6, + {5, 23} => 6, + {5, 24} => 6, + {5, 25} => 6, + {5, 26} => 6, + {5, 27} => 6, + {5, 28} => 6, + {6, 0} => 1, + {6, 1} => 2, + {6, 2} => 3, + {6, 3} => 4, + {6, 4} => 5, + {6, 5} => 6, + {6, 6} => 7, + {6, 7} => 7, + {6, 8} => 7, + {6, 9} => 7, + {6, 10} => 7, + {6, 11} => 7, + {6, 12} => 7, + {6, 13} => 7, + {6, 14} => 7, + {6, 15} => 7, + {6, 16} => 7, + {6, 17} => 7, + {6, 18} => 7, + {6, 19} => 7, + {6, 20} => 7, + {6, 21} => 7, + {6, 22} => 7, + {6, 23} => 7, + {6, 24} => 7, + {6, 25} => 7, + {6, 26} => 7, + {6, 27} => 7, + {6, 28} => 7, + {7, 0} => 1, + {7, 1} => 2, + {7, 2} => 3, + {7, 3} => 4, + {7, 4} => 5, + {7, 5} => 6, + {7, 6} => 7, + {7, 7} => 7, + {7, 8} => 7, + {7, 9} => 7, + {7, 10} => 7, + {7, 11} => 7, + {7, 12} => 7, + {7, 13} => 7, + {7, 14} => 7, + {7, 15} => 8, + {7, 16} => 8, + {7, 17} => 8, + {7, 18} => 8, + {7, 19} => 8, + {7, 20} => 8, + {7, 21} => 8, + {7, 22} => 8, + {7, 23} => 8, + {7, 24} => 8, + {7, 25} => 8, + {7, 26} => 8, + {7, 27} => 8, + {7, 28} => 8, + {8, 0} => 1, + {8, 1} => 2, + {8, 2} => 3, + {8, 3} => 4, + {8, 4} => 5, + {8, 5} => 6, + {8, 6} => 7, + {8, 7} => 7, + {8, 8} => 7, + {8, 9} => 7, + {8, 10} => 7, + {8, 11} => 7, + {8, 12} => 7, + {8, 13} => 7, + {8, 14} => 7, + {8, 15} => 8, + {8, 16} => 8, + {8, 17} => 8, + {8, 18} => 8, + {8, 19} => 8, + {8, 20} => 8, + {8, 21} => 8, + {8, 22} => 8, + {8, 23} => 8, + {8, 24} => 8, + {8, 25} => 8, + {8, 26} => 8, + {8, 27} => 8, + {8, 28} => 8, + {9, 0} => 1, + {9, 1} => 2, + {9, 2} => 3, + {9, 3} => 4, + {9, 4} => 5, + {9, 5} => 6, + {9, 6} => 7, + {9, 7} => 7, + {9, 8} => 7, + {9, 9} => 8, + {9, 10} => 8, + {9, 11} => 8, + {9, 12} => 8, + {9, 13} => 8, + {9, 14} => 8, + {9, 15} => 8, + {9, 16} => 8, + {9, 17} => 9, + {9, 18} => 9, + {9, 19} => 9, + {9, 20} => 9, + {9, 21} => 9, + {9, 22} => 9, + {9, 23} => 9, + {9, 24} => 9, + {9, 25} => 9, + {9, 26} => 9, + {9, 27} => 9, + {9, 28} => 9, + {10, 0} => 1, + {10, 1} => 2, + {10, 2} => 3, + {10, 3} => 4, + {10, 4} => 5, + {10, 5} => 6, + {10, 6} => 7, + {10, 7} => 7, + {10, 8} => 7, + {10, 9} => 8, + {10, 10} => 9, + {10, 11} => 9, + {10, 12} => 9, + {10, 13} => 9, + {10, 14} => 9, + {10, 15} => 9, + {10, 16} => 9, + {10, 17} => 9, + {10, 18} => 10, + {10, 19} => 10, + {10, 20} => 10, + {10, 21} => 10, + {10, 22} => 10, + {10, 23} => 10, + {10, 24} => 10, + {10, 25} => 10, + {10, 26} => 10, + {10, 27} => 10, + {10, 28} => 10, + {11, 0} => 1, + {11, 1} => 2, + {11, 2} => 3, + {11, 3} => 4, + {11, 4} => 5, + {11, 5} => 6, + {11, 6} => 7, + {11, 7} => 7, + {11, 8} => 7, + {11, 9} => 8, + {11, 10} => 9, + {11, 11} => 9, + {11, 12} => 9, + {11, 13} => 9, + {11, 14} => 9, + {11, 15} => 9, + {11, 16} => 9, + {11, 17} => 9, + {11, 18} => 10, + {11, 19} => 11, + {11, 20} => 11, + {11, 21} => 11, + {11, 22} => 11, + {11, 23} => 11, + {11, 24} => 11, + {11, 25} => 11, + {11, 26} => 11, + {11, 27} => 11, + {11, 28} => 11, + {12, 0} => 1, + {12, 1} => 2, + {12, 2} => 3, + {12, 3} => 4, + {12, 4} => 5, + {12, 5} => 6, + {12, 6} => 7, + {12, 7} => 7, + {12, 8} => 7, + {12, 9} => 8, + {12, 10} => 9, + {12, 11} => 9, + {12, 12} => 9, + {12, 13} => 9, + {12, 14} => 9, + {12, 15} => 9, + {12, 16} => 9, + {12, 17} => 9, + {12, 18} => 10, + {12, 19} => 11, + {12, 20} => 12, + {12, 21} => 12, + {12, 22} => 12, + {12, 23} => 12, + {12, 24} => 12, + {12, 25} => 12, + {12, 26} => 12, + {12, 27} => 12, + {12, 28} => 12, + {13, 0} => 1, + {13, 1} => 2, + {13, 2} => 3, + {13, 3} => 4, + {13, 4} => 5, + {13, 5} => 6, + {13, 6} => 7, + {13, 7} => 7, + {13, 8} => 7, + {13, 9} => 8, + {13, 10} => 9, + {13, 11} => 9, + {13, 12} => 9, + {13, 13} => 9, + {13, 14} => 9, + {13, 15} => 9, + {13, 16} => 9, + {13, 17} => 9, + {13, 18} => 10, + {13, 19} => 11, + {13, 20} => 12, + {13, 21} => 13, + {13, 22} => 13, + {13, 23} => 13, + {13, 24} => 13, + {13, 25} => 13, + {13, 26} => 13, + {13, 27} => 13, + {13, 28} => 13, + {14, 0} => 1, + {14, 1} => 2, + {14, 2} => 3, + {14, 3} => 4, + {14, 4} => 5, + {14, 5} => 6, + {14, 6} => 7, + {14, 7} => 7, + {14, 8} => 7, + {14, 9} => 8, + {14, 10} => 9, + {14, 11} => 9, + {14, 12} => 9, + {14, 13} => 9, + {14, 14} => 9, + {14, 15} => 9, + {14, 16} => 9, + {14, 17} => 9, + {14, 18} => 10, + {14, 19} => 11, + {14, 20} => 12, + {14, 21} => 13, + {14, 22} => 14, + {14, 23} => 14, + {14, 24} => 14, + {14, 25} => 14, + {14, 26} => 14, + {14, 27} => 14, + {14, 28} => 14, + {15, 0} => 1, + {15, 1} => 2, + {15, 2} => 3, + {15, 3} => 4, + {15, 4} => 5, + {15, 5} => 6, + {15, 6} => 7, + {15, 7} => 7, + {15, 8} => 7, + {15, 9} => 8, + {15, 10} => 9, + {15, 11} => 9, + {15, 12} => 9, + {15, 13} => 9, + {15, 14} => 9, + {15, 15} => 9, + {15, 16} => 9, + {15, 17} => 9, + {15, 18} => 10, + {15, 19} => 11, + {15, 20} => 12, + {15, 21} => 13, + {15, 22} => 14, + {15, 23} => 15, + {15, 24} => 15, + {15, 25} => 15, + {15, 26} => 15, + {15, 27} => 15, + {15, 28} => 15, + {16, 0} => 1, + {16, 1} => 2, + {16, 2} => 3, + {16, 3} => 4, + {16, 4} => 5, + {16, 5} => 6, + {16, 6} => 7, + {16, 7} => 7, + {16, 8} => 7, + {16, 9} => 8, + {16, 10} => 9, + {16, 11} => 9, + {16, 12} => 9, + {16, 13} => 9, + {16, 14} => 9, + {16, 15} => 9, + {16, 16} => 9, + {16, 17} => 9, + {16, 18} => 10, + {16, 19} => 11, + {16, 20} => 12, + {16, 21} => 13, + {16, 22} => 14, + {16, 23} => 15, + {16, 24} => 15, + {16, 25} => 15, + {16, 26} => 15, + {16, 27} => 15, + {16, 28} => 15, + {17, 0} => 1, + {17, 1} => 2, + {17, 2} => 3, + {17, 3} => 4, + {17, 4} => 5, + {17, 5} => 6, + {17, 6} => 7, + {17, 7} => 7, + {17, 8} => 7, + {17, 9} => 8, + {17, 10} => 9, + {17, 11} => 9, + {17, 12} => 9, + {17, 13} => 9, + {17, 14} => 9, + {17, 15} => 9, + {17, 16} => 9, + {17, 17} => 9, + {17, 18} => 10, + {17, 19} => 11, + {17, 20} => 12, + {17, 21} => 13, + {17, 22} => 14, + {17, 23} => 15, + {17, 24} => 15, + {17, 25} => 16, + {17, 26} => 16, + {17, 27} => 16, + {17, 28} => 16, + {18, 0} => 1, + {18, 1} => 2, + {18, 2} => 3, + {18, 3} => 4, + {18, 4} => 5, + {18, 5} => 6, + {18, 6} => 7, + {18, 7} => 7, + {18, 8} => 7, + {18, 9} => 8, + {18, 10} => 9, + {18, 11} => 9, + {18, 12} => 9, + {18, 13} => 9, + {18, 14} => 9, + {18, 15} => 9, + {18, 16} => 9, + {18, 17} => 9, + {18, 18} => 10, + {18, 19} => 11, + {18, 20} => 12, + {18, 21} => 13, + {18, 22} => 14, + {18, 23} => 15, + {18, 24} => 15, + {18, 25} => 16, + {18, 26} => 17, + {18, 27} => 17, + {18, 28} => 17, + {19, 0} => 1, + {19, 1} => 2, + {19, 2} => 3, + {19, 3} => 4, + {19, 4} => 5, + {19, 5} => 6, + {19, 6} => 7, + {19, 7} => 7, + {19, 8} => 7, + {19, 9} => 8, + {19, 10} => 9, + {19, 11} => 9, + {19, 12} => 9, + {19, 13} => 9, + {19, 14} => 9, + {19, 15} => 9, + {19, 16} => 9, + {19, 17} => 9, + {19, 18} => 10, + {19, 19} => 11, + {19, 20} => 12, + {19, 21} => 13, + {19, 22} => 14, + {19, 23} => 15, + {19, 24} => 15, + {19, 25} => 16, + {19, 26} => 17, + {19, 27} => 18, + {19, 28} => 18, + {20, 0} => 1, + {20, 1} => 2, + {20, 2} => 3, + {20, 3} => 4, + {20, 4} => 5, + {20, 5} => 6, + {20, 6} => 7, + {20, 7} => 7, + {20, 8} => 7, + {20, 9} => 8, + {20, 10} => 9, + {20, 11} => 9, + {20, 12} => 9, + {20, 13} => 9, + {20, 14} => 9, + {20, 15} => 9, + {20, 16} => 9, + {20, 17} => 9, + {20, 18} => 10, + {20, 19} => 11, + {20, 20} => 12, + {20, 21} => 13, + {20, 22} => 14, + {20, 23} => 15, + {20, 24} => 15, + {20, 25} => 16, + {20, 26} => 17, + {20, 27} => 18, + {20, 28} => 19 + } + + expected_result = [ + " [", + " {", + " \"http_version\": \"HTTP/1.1\",", + " \"request\": {", + " \"body\": null,", + " \"headers\": [", + "+ {", + "+ \"name\": \"Cache-Control\",", + "+ \"value\": \"no-cache\"", + "+ },", + "+ {", + "+ \"name\": \"Content-Type\",", + "+ \"value\": \"application/json\"", + "+ },", + " {", + " \"name\": \"Accept\",", + "- \"value\": \"*/*\"", + "+ \"value\": \"application/json\"", + " },", + " {", + " \"name\": \"Connection\",", + " \"value\": \"keep-alive\"", + " }", + " ],", + " \"method\": \"GET\",", + "- \"url\": \"https://status.thebank.engineering/status.json?downtimeTimestamp=1691577508.930853\"", + "+ \"url\": \"https://thebank.engineering/api/apps/A3254415/configuration?osVersion=16.5appType=iPhone&appVersion=13.4.0\"", + " }", + " }", + " ]", + " " + ] + + assert PrintDiff.call(matrix, file1, file2) == expected_result + end + + defp read_file(file_path) do + file_path + |> Path.expand(__DIR__) + |> File.read!() + |> String.split("\n") + end end diff --git a/test/diff_check_test.exs b/test/diff_check_test.exs index b36edc1..71788d8 100644 --- a/test/diff_check_test.exs +++ b/test/diff_check_test.exs @@ -3,12 +3,16 @@ defmodule DiffCheckTest do doctest DiffCheck test "works with valid arguments" do - file1 = Path.expand("support/fixtures/13.3.7_.json", __DIR__) - file2 = Path.expand("support/fixtures/13.4.0_.json", __DIR__) + file1 = Path.expand("support/fixtures/test_response_1.json", __DIR__) + file2 = Path.expand("support/fixtures/test_response_2.json", __DIR__) assert DiffCheck.main([file1, file2]) == :ok end + test "fails with non-existent files" do + assert DiffCheck.main(["foo", "bar"]) == {:error, "One or both files do not exist"} + end + test "fails with incomplete arguments" do assert DiffCheck.main([]) == {:error, "You must provide exactly two arguments"} end diff --git a/test/support/fixtures/13.3.7_.json b/test/support/fixtures/13.3.7_.json deleted file mode 100755 index 87c1070..0000000 --- a/test/support/fixtures/13.3.7_.json +++ /dev/null @@ -1,285 +0,0 @@ -[ - { - "http_version": "HTTP/1.1", - "request": { - "body": null, - "headers": [ - { - "name": "Host", - "value": "status.thebank.teller.engineering" - }, - { - "name": "Accept", - "value": "*/*" - }, - { - "name": "User-Agent", - "value": "TheBankMobile/13.3.7 (iPhone; iOS 16.5)" - }, - { - "name": "Accept-Language", - "value": "en-US;q=1" - }, - { - "name": "Accept-Encoding", - "value": "gzip, deflate, br" - }, - { - "name": "Connection", - "value": "keep-alive" - } - ], - "method": "GET", - "url": "https://status.thebank.teller.engineering/status.json?downtimeTimestamp=1691577508.930853" - }, - "response": { - "body": "{\r\n \"id\": \"NWUzZWMyOT222222NTUzYzc0YjMz555555Y4YjM3ZW44444hY2I2OQ==\"\r\n}\r\n", - "headers": [ - { - "name": "Content-Type", - "value": "application/json" - }, - { - "name": "Last-Modified", - "value": "Sun, 12 Jun 2022 07:56:20 GMT" - }, - { - "name": "Accept-Ranges", - "value": "bytes" - }, - { - "name": "ETag", - "value": "\"f91062e7317ed81:0\"" - }, - { - "name": "Server", - "value": "Microsoft-IIS/8.5" - }, - { - "name": "X-Powered-By", - "value": "ASP.NET" - }, - { - "name": "Date", - "value": "Wed, 09 Aug 2023 10:38:29 GMT" - }, - { - "name": "Content-Length", - "value": "77" - } - ], - "status_code": 200, - "status_text": "OK" - } - }, - { - "http_version": "HTTP/1.1", - "request": { - "body": null, - "headers": [ - { - "name": "Host", - "value": "thebank.teller.engineering" - }, - { - "name": "Content-Type", - "value": "application/json" - }, - { - "name": "Accept", - "value": "application/json" - }, - { - "name": "Connection", - "value": "keep-alive" - }, - { - "name": "Cookie", - "value": "AppVersion=13.3.7;AppType=iPhone;AI=A3254414;" - }, - { - "name": "User-Agent", - "value": "TheBankMobile/13.3.7 (iPhone; iOS 16.5)" - }, - { - "name": "Accept-Language", - "value": "en-US;q=1" - }, - { - "name": "Cache-Control", - "value": "no-cache" - }, - { - "name": "Accept-Encoding", - "value": "gzip, deflate, br" - } - ], - "method": "GET", - "url": "https://thebank.teller.engineering/api/apps/A3254414/configuration?osVersion=16.5appType=iPhone&appVersion=13.3.7" - }, - "response": { - "body": "{\"appId\":\"A3254414\",\"appName\":\"The Bank Mobile\",\"properties\":{\"balanceEnablement\":\"Enabled\",\"showAccountNumberEnablement\":\"Enabled\",\"faceIdAuthEnablement\":\"Enabled\",\"billingAndPaymentsEnablement\":\"Disabled\",\"chatEnablement\":\"Disabled\",\"zelleEnablement\":\"Enabled\",\"rewardsEnablement\":\"Disabled\",\"sessionTimeout\":660}}", - "headers": [ - { - "name": "Cache-Control", - "value": "no-store, max-age=0" - }, - { - "name": "Pragma", - "value": "no-cache" - }, - { - "name": "Content-Type", - "value": "application/json; charset=utf-8" - }, - { - "name": "Set-Cookie", - "value": "CorrelationId=c7129b04-498b-4fcc-9a3e-940a9ab3caf6;HttpOnly;Secure" - }, - { - "name": "X-Content-Type-Options", - "value": "nosniff" - }, - { - "name": "X-Frame-Options", - "value": "deny" - }, - { - "name": "Strict-Transport-Security", - "value": "max-age=31536000; includeSubdomains" - }, - { - "name": "Content-Security-Policy", - "value": "default-src 'self';style-src 'self';script-src 'self'; frame-ancestors 'self'" - }, - { - "name": "X-Xss-Protection", - "value": "1; mode=block" - }, - { - "name": "Add-No-Store", - "value": "" - }, - { - "name": "Server-Timing", - "value": "dtSInfo;desc=\"0\"" - }, - { - "name": "Date", - "value": "Wed, 09 Aug 2023 10:38:30 GMT" - }, - { - "name": "Content-Length", - "value": "5525" - }, - { - "name": "Set-Cookie", - "value": "persist__data=TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQWxpcXVhbSB2ZWxpdCBzZW0sIGNvbnZhbGxpcyBhdCBudW5jIGVnZXN0YXMsIHVsdHJpY2llcyB2dWxwdXRhdGUgbmVxdWUuIE51bGxhIHRlbXB1cyBpYWN1bGlzIHBvc3VlcmU=; path=/; Httponly; Secure" - } - ], - "status_code": 200, - "status_text": "OK" - } - }, - { - "http_version": "HTTP/1.1", - "request": { - "body": "{\"credentials\":{\"username\":\"foo\",\"password\":\"bar\",\"appId\":\"A3254414\"},\"applicationInfo\":{\"pushProvider\":\"APNS\",\"versionNumber\":\"13.3.7\",\"pushAppId\":\"engineering.teller.thebank\",\"clientType\":\"iPhone\"},\"deviceInfo\":{\"os\":\"iPhone OS\",\"clientDeviceFingerprint\":\"Language__en-us___Platform__iPhone___ScreenColorDepth__32___DeviceUUID__F30AC5E4-1A35-4D75-94FA-586CFA9F64DF___ScreenWidth__375___ScreenHeight__812___GUID__421659E7-4281-464A-976B-54F5EDFCF2D3\",\"screenHeight\":812,\"osVersion\":\"16.5\",\"type\":\"iPhone\",\"name\":\"iPhone\",\"deviceIntegrity\":0,\"uniqueId\":\"F30AC5E4-1A35-4D75-94FA-586CFA9F64DF\",\"screenWidth\":375}}", - "headers": [ - { - "name": "Host", - "value": "thebank.teller.engineering" - }, - { - "name": "Content-Type", - "value": "application/json" - }, - { - "name": "Accept", - "value": "application/json" - }, - { - "name": "Accept-Encoding", - "value": "gzip, deflate, br" - }, - { - "name": "Connection", - "value": "keep-alive" - }, - { - "name": "Cookie", - "value": "AppVersion=13.3.7;AppType=iPhone;AI=A3254414;CorrelationId=c7129b04-498b-4fcc-9a3e-940a9ab3caf6;persist__data=TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQWxpcXVhbSB2ZWxpdCBzZW0sIGNvbnZhbGxpcyBhdCBudW5jIGVnZXN0YXMsIHVsdHJpY2llcyB2dWxwdXRhdGUgbmVxdWUuIE51bGxhIHRlbXB1cyBpYWN1bGlzIHBvc3VlcmU=;" - }, - { - "name": "User-Agent", - "value": "TheBankMobile/13.3.7 (iPhone; iOS 16.5)" - }, - { - "name": "Accept-Language", - "value": "en-us" - }, - { - "name": "Cache-Control", - "value": "no-cache" - }, - { - "name": "Content-Length", - "value": "621" - } - ], - "method": "POST", - "url": "https://thebank.teller.engineering/api/accesstokens/usernameandpassword" - }, - "response": { - "body": "{\"message\":\"Forbidden\",\"code\":1000}", - "headers": [ - { - "name": "Cache-Control", - "value": "no-store, max-age=0" - }, - { - "name": "Pragma", - "value": "no-cache" - }, - { - "name": "Content-Type", - "value": "application/json; charset=utf-8" - }, - { - "name": "X-Content-Type-Options", - "value": "nosniff" - }, - { - "name": "X-Frame-Options", - "value": "deny" - }, - { - "name": "Strict-Transport-Security", - "value": "max-age=31536000; includeSubdomains" - }, - { - "name": "Content-Security-Policy", - "value": "default-src 'self';style-src 'self';script-src 'self'; frame-ancestors 'self'" - }, - { - "name": "X-Xss-Protection", - "value": "1; mode=block" - }, - { - "name": "Add-No-Store", - "value": "" - }, - { - "name": "Date", - "value": "Wed, 09 Aug 2023 10:38:44 GMT" - }, - { - "name": "Content-Length", - "value": "35" - } - ], - "status_code": 403, - "status_text": "Forbidden" - } - } -] diff --git a/test/support/fixtures/13.4.0_.json b/test/support/fixtures/13.4.0_.json deleted file mode 100755 index c3a0e1d..0000000 --- a/test/support/fixtures/13.4.0_.json +++ /dev/null @@ -1,398 +0,0 @@ -[ - { - "http_version": "HTTP/1.1", - "request": { - "body": null, - "headers": [ - { - "name": "Host", - "value": "thebank.teller.engineering" - }, - { - "name": "Cache-Control", - "value": "no-cache" - }, - { - "name": "Content-Type", - "value": "application/json" - }, - { - "name": "Accept", - "value": "application/json" - }, - { - "name": "Cookie", - "value": "AppVersion=13.4.0;AppType=iPhone;AI=A3254415;" - }, - { - "name": "User-Agent", - "value": "TheBankMobile/13.4.0 (iPhone; iOS 16.5)" - }, - { - "name": "x-sectrace", - "value": "b645a590-b5e3-49c6-9efe-ce774f02de08" - }, - { - "name": "Accept-Language", - "value": "en-US;q=1" - }, - { - "name": "Accept-Encoding", - "value": "gzip, deflate, br" - }, - { - "name": "Connection", - "value": "keep-alive" - } - ], - "method": "GET", - "url": "https://thebank.teller.engineering/api/apps/A3254415/configuration?osVersion=16.5appType=iPhone&appVersion=13.4.0" - }, - "response": { - "body": "{\"appId\":\"A3254415\",\"appName\":\"The Bank Mobile\",\"properties\":{\"balanceEnablement\":\"Enabled\",\"showAccountNumberEnablement\":\"Enabled\",\"paymentsEnablement\":\"Disabled\",\"chatEnablement\":\"Disabled\",\"aiEnablement\":\"Disabled\",\"zelleEnablement\":\"Enabled\",\"rewardsEnablement\":\"Disabled\",\"sessionTimeout\":660}}", - "headers": [ - { - "name": "Cache-Control", - "value": "no-store, max-age=0" - }, - { - "name": "Pragma", - "value": "no-cache" - }, - { - "name": "Content-Type", - "value": "application/json; charset=utf-8" - }, - { - "name": "Set-Cookie", - "value": "CorrelationId=c7129b04-498b-4fcc-9a3e-940a9ab3caf6;HttpOnly;Secure" - }, - { - "name": "X-Content-Type-Options", - "value": "nosniff" - }, - { - "name": "X-Frame-Options", - "value": "deny" - }, - { - "name": "Strict-Transport-Security", - "value": "max-age=31536000; includeSubdomains" - }, - { - "name": "Content-Security-Policy", - "value": "default-src 'self';style-src 'self';script-src 'self'; frame-ancestors 'self'" - }, - { - "name": "X-Xss-Protection", - "value": "1; mode=block" - }, - { - "name": "Add-No-Store", - "value": "" - }, - { - "name": "Server-Timing", - "value": "dtSInfo;desc=\"0\"" - }, - { - "name": "Date", - "value": "Wed, 09 Aug 2023 10:38:30 GMT" - }, - { - "name": "Content-Length", - "value": "5525" - }, - { - "name": "Set-Cookie", - "value": "persist__data=TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQWxpcXVhbSB2ZWxpdCBzZW0sIGNvbnZhbGxpcyBhdCBudW5jIGVnZXN0YXMsIHVsdHJpY2llcyB2dWxwdXRhdGUgbmVxdWUuIE51bGxhIHRlbXB1cyBpYWN1bGlzIHBvc3VlcmU=; path=/; Httponly; Secure" - } - ], - "status_code": 200, - "status_text": "OK" - } - }, - { - "http_version": "HTTP/1.1", - "request": { - "body": null, - "headers": [ - { - "name": "Host", - "value": "status.thebank.teller.engineering" - }, - { - "name": "Accept", - "value": "*/*" - }, - { - "name": "User-Agent", - "value": "TheBankMobile/13.4.0 (iPhone; iOS 16.5)" - }, - { - "name": "Accept-Language", - "value": "en-US;q=0.8" - }, - { - "name": "Accept-Encoding", - "value": "gzip, deflate, br" - }, - { - "name": "Connection", - "value": "keep-alive" - } - ], - "method": "GET", - "url": "https://status.thebank.teller.engineering/status.json?downtimeTimestamp=1691577508.930853" - }, - "response": { - "body": "{\r\n \"id\": \"NWUzZWMyOT222222NTUzYzc0YjMz555555Y4YjM3ZW44444hY2I2OQ==\"\r\n}\r\n", - "headers": [ - { - "name": "Content-Type", - "value": "application/json" - }, - { - "name": "Last-Modified", - "value": "Sun, 12 Jun 2022 07:56:20 GMT" - }, - { - "name": "Accept-Ranges", - "value": "bytes" - }, - { - "name": "ETag", - "value": "\"f91062e7317ed81:0\"" - }, - { - "name": "Server", - "value": "Microsoft-IIS/8.5" - }, - { - "name": "X-Powered-By", - "value": "ASP.NET" - }, - { - "name": "Date", - "value": "Wed, 09 Aug 2023 10:38:29 GMT" - }, - { - "name": "Content-Length", - "value": "77" - } - ], - "status_code": 200, - "status_text": "OK" - } - }, - { - "http_version": "HTTP/1.1", - "request": { - "body": "dGVsbGVyLWNoYWxsZW5nZQ==", - "headers": [ - { - "name": "Host", - "value": "thebank.teller.engineering" - }, - { - "name": "Cache-Control", - "value": "no-cache" - }, - { - "name": "Content-Type", - "value": "application/json" - }, - { - "name": "Accept", - "value": "application/json" - }, - { - "name": "Cookie", - "value": "AppVersion=13.4.0;AppType=iPhone;AI=A3254415;" - }, - { - "name": "User-Agent", - "value": "TheBankMobile/13.4.0 (iPhone; iOS 16.5)" - }, - { - "name": "x-sectrace", - "value": "b645a590-b5e3-49c6-9efe-ce774f02de08" - }, - { - "name": "Accept-Language", - "value": "en-US;q=1" - }, - { - "name": "Accept-Encoding", - "value": "gzip, deflate, br" - }, - { - "name": "Connection", - "value": "keep-alive" - } - ], - "method": "POST", - "url": "https://thebank.teller.engineering/api/sectrace/verify" - }, - "response": { - "body": "{\"status\":\"accepted\"}", - "headers": [ - { - "name": "Cache-Control", - "value": "no-store, max-age=0" - }, - { - "name": "Pragma", - "value": "no-cache" - }, - { - "name": "Content-Type", - "value": "application/json; charset=utf-8" - }, - { - "name": "Set-Cookie", - "value": "CorrelationId=c7129b04-498b-4fcc-9a3e-940a9ab3caf6;HttpOnly;Secure" - }, - { - "name": "X-Content-Type-Options", - "value": "nosniff" - }, - { - "name": "X-Frame-Options", - "value": "deny" - }, - { - "name": "Strict-Transport-Security", - "value": "max-age=31536000; includeSubdomains" - }, - { - "name": "Content-Security-Policy", - "value": "default-src 'self';style-src 'self';script-src 'self'; frame-ancestors 'self'" - }, - { - "name": "X-Xss-Protection", - "value": "1; mode=block" - }, - { - "name": "Add-No-Store", - "value": "" - }, - { - "name": "Server-Timing", - "value": "dtSInfo;desc=\"0\"" - }, - { - "name": "Date", - "value": "Wed, 09 Aug 2023 10:38:30 GMT" - }, - { - "name": "Content-Length", - "value": "5525" - }, - { - "name": "Set-Cookie", - "value": "persist__data=TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQWxpcXVhbSB2ZWxpdCBzZW0sIGNvbnZhbGxpcyBhdCBudW5jIGVnZXN0YXMsIHVsdHJpY2llcyB2dWxwdXRhdGUgbmVxdWUuIE51bGxhIHRlbXB1cyBpYWN1bGlzIHBvc3VlcmU=; path=/; Httponly; Secure" - } - ], - "status_code": 200, - "status_text": "OK" - } - }, - { - "http_version": "HTTP/1.1", - "request": { - "body": "{\"credentials\":{\"password\":\"bar\",\"username\":\"foo\",\"appId\":\"A3254415\"},\"applicationInfo\":{\"pushProvider\":\"APNS\",\"versionNumber\":\"13.4.0\",\"pushAppId\":\"engineering.teller.thebank\"},\"deviceInfo\":{\"os\":\"iPhone OS\",\"clientDeviceFingerprint\":\"Language__en-us___Platform__iPhone___ScreenColorDepth__32___DeviceUUID__F30AC5E4-1A35-4D75-94FA-586CFA9F64DF___ScreenHeight__812___ScreenWidth__375___GUID__421659E7-4281-464A-976B-54F5EDFCF2D3\",\"screenHeight\":812,\"osVersion\":\"16.5\",\"type\":\"iPhone\",\"name\":\"iPhone\",\"deviceIntegrity\":0,\"uniqueId\":\"F30AC5E4-1A35-4D75-94FA-586CFA9F64DF\",\"screenWidth\":375}}", - "headers": [ - { - "name": "Host", - "value": "thebank.teller.engineering" - }, - { - "name": "Content-Type", - "value": "application/json" - }, - { - "name": "Accept", - "value": "application/json" - }, - { - "name": "Connection", - "value": "keep-alive" - }, - { - "name": "Cookie", - "value": "AppVersion=13.4.0;AppType=iPhone;AI=A3254415;CorrelationId=c7129b04-498b-4fcc-9a3e-940a9ab3caf6;persist__data=TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGGFkaXBpc2NpbmcgZWxpdC4gQWxpcXVhbSB2ZWxpdCBzZW0sIGNvbnZhbGxpcyBhdCBudW5jIGVnZXN0YXMsIHVsdHJpY2llcyB2dWxwdXRhdGUgbmVxdWUuIE5N1bGlzIHBvc3VlcmU=;" - }, - { - "name": "User-Agent", - "value": "TheBankMobile/13.4.0 (iPhone; iOS 16.5)" - }, - { - "name": "x-sectrace", - "value": "57c1618d-d03d-4563-9b04-11c9e3cb67e4" - }, - { - "name": "Accept-Language", - "value": "en-us" - }, - { - "name": "Accept-Encoding", - "value": "gzip, deflate, br" - }, - { - "name": "Content-Length", - "value": "621" - } - ], - "method": "POST", - "url": "https://thebank.teller.engineering/api/accesstokens/usernameandpassword" - }, - "response": { - "body": "{\"message\":\"Forbidden\",\"code\":1001}", - "headers": [ - { - "name": "Cache-Control", - "value": "no-store, max-age=0" - }, - { - "name": "Content-Type", - "value": "application/json; charset=utf-8" - }, - { - "name": "X-Content-Type-Options", - "value": "nosniff" - }, - { - "name": "Strict-Transport-Security", - "value": "max-age=31536000; includeSubdomains" - }, - { - "name": "Content-Security-Policy", - "value": "default-src 'self';style-src 'self';script-src 'self'; frame-ancestors 'self'" - }, - { - "name": "X-Frame-Options", - "value": "deny" - }, - { - "name": "X-Xss-Protection", - "value": "1; mode=block" - }, - { - "name": "Pragma", - "value": "no-cache" - }, - { - "name": "Add-No-Store", - "value": "" - }, - { - "name": "Content-Length", - "value": "35" - } - ], - "status_code": 403, - "status_text": "Forbidden" - } - } -] diff --git a/test/support/fixtures/test_response_1.json b/test/support/fixtures/test_response_1.json new file mode 100755 index 0000000..7a36492 --- /dev/null +++ b/test/support/fixtures/test_response_1.json @@ -0,0 +1,20 @@ +[ + { + "http_version": "HTTP/1.1", + "request": { + "body": null, + "headers": [ + { + "name": "Accept", + "value": "*/*" + }, + { + "name": "Connection", + "value": "keep-alive" + } + ], + "method": "GET", + "url": "https://status.thebank.engineering/status.json?downtimeTimestamp=1691577508.930853" + } + } +] diff --git a/test/support/fixtures/test_response_2.json b/test/support/fixtures/test_response_2.json new file mode 100755 index 0000000..dd5bc7e --- /dev/null +++ b/test/support/fixtures/test_response_2.json @@ -0,0 +1,28 @@ +[ + { + "http_version": "HTTP/1.1", + "request": { + "body": null, + "headers": [ + { + "name": "Cache-Control", + "value": "no-cache" + }, + { + "name": "Content-Type", + "value": "application/json" + }, + { + "name": "Accept", + "value": "application/json" + }, + { + "name": "Connection", + "value": "keep-alive" + } + ], + "method": "GET", + "url": "https://thebank.engineering/api/apps/A3254415/configuration?osVersion=16.5appType=iPhone&appVersion=13.4.0" + } + } +]