package postprocess

import "testing"

func TestIsJKS(t *testing.T) {
	type args struct {
		cc string
	}
	tests := []struct {
		name     string
		text     []byte
		isSecret bool
	}{
		{
			"Invalid JKS file",
			[]byte("Random Binary Data"),
			false,
		},
		{
			"Invalid JKS file",
			[]byte("This is not a JKS file."),
			false,
		},
		{
			"Invalid JKS file",
			[]byte("Non-JKS File"),
			false,
		},
		{
			"Valid JKS file",
			[]byte{254, 237, 254, 237, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, 112, 97, 115, 115, 119, 111, 114, 100, 0, 0,
				1, 153, 153, 150, 70, 250, 0, 0, 5, 1, 48, 130, 4, 253, 48, 14, 6, 10, 43, 6, 1, 4, 1, 42, 2, 17, 1, 1, 5, 0,
				4, 130, 4, 233, 105, 32, 213, 132, 23, 200, 121, 15, 159, 30, 94, 83, 170, 110, 13, 74, 235, 221, 33, 98, 217,
				233, 82, 42, 172, 2, 28, 100, 49, 227, 204, 246, 11, 132, 206, 248, 237, 209, 92, 241, 110, 200, 154, 206, 136,
				37, 220, 183, 236, 238, 175, 201, 143, 190, 125, 228, 3, 125, 34, 142, 170, 146, 222, 186, 2, 206, 2, 229, 68,
				208, 160, 93, 109, 112, 55, 83, 25, 34, 50, 135, 161, 55, 191, 204, 217, 168, 173, 101, 214, 94, 173, 57, 185,
				204, 10, 171, 156, 55, 55, 137, 222, 21, 79, 124, 245, 2, 15, 33, 49, 210, 116, 114, 75, 209, 122, 102, 140, 1,
				75, 99, 25, 70, 149, 14, 14, 206, 63, 202, 76, 169, 12, 53, 250, 65, 204, 216, 206, 51, 39, 249, 224, 233, 97,
				82, 2, 190, 38, 75, 152, 100, 232, 157, 43, 38, 101, 194, 224, 203, 181, 94, 97, 43, 142, 178, 72, 164, 120, 53,
				127, 43, 38, 196, 158, 215, 1, 28, 24, 17, 112, 144, 86, 161, 80, 128, 210, 75, 30, 24, 150, 239, 51, 166, 96, 98,
				213, 12, 140, 251, 43, 70, 47, 117, 221, 65, 101, 170, 236, 6, 93, 61, 75, 117, 8, 164, 7, 236, 135, 201, 5, 191, 100,
				134, 133, 193, 132, 173, 63, 31, 198, 240, 66, 178, 2, 17, 216, 237, 44, 128, 111, 114, 24, 171, 75, 89, 60, 88, 88,
				244, 123, 243, 66, 50, 147, 187, 30, 214, 145, 246, 14, 144, 167, 56, 77, 43, 229, 196, 242, 114, 47, 141, 229, 65,
				114, 201, 242, 185, 25, 145, 24, 93, 2, 163, 169, 231, 128, 146, 113, 56, 24, 198, 144, 189, 54, 189, 227, 122, 42,
				205, 230, 68, 4, 125, 138, 176, 186, 209, 122, 57, 126, 127, 161, 250, 27, 112, 21, 53, 164, 255, 145, 165, 241, 55,
				32, 235, 206, 39, 233, 183, 132, 253, 184, 172, 229, 135, 207, 211, 37, 166, 224, 68, 197, 32, 20, 39, 6, 195, 225, 82,
				23, 176, 251, 130, 76, 153, 73, 7, 117, 15, 162, 104, 232, 184, 54, 138, 57, 69, 180, 178, 152, 252, 226, 197, 30, 2, 172,
				207, 107, 184, 150, 194, 142, 101, 90, 30, 38, 31, 47, 57, 87, 65, 42, 189, 214, 4, 37, 10, 105, 106, 40, 38, 81, 96, 70,
				160, 230, 71, 73, 123, 237, 108, 99, 63, 89, 118, 195, 36, 180, 95, 96, 92, 124, 34, 44, 254, 43, 156, 86, 62, 84, 124, 118,
				148, 119, 252, 57, 72, 60, 175, 103, 31, 187, 85, 118, 214, 101, 88, 96, 254, 202, 98, 232, 145, 94, 246, 96, 120, 233, 248,
				70, 51, 82, 177, 170, 65, 2, 68, 51, 190, 167, 192, 219, 151, 89, 241, 254, 77, 129, 199, 89, 192, 134, 36, 110, 102, 61,
				67, 28, 102, 14, 125, 30, 14, 234, 191, 242, 164, 51, 116, 146, 130, 86, 196, 175, 56, 99, 131, 18, 9, 55, 167, 137, 225,
				166, 162, 192, 105, 217, 55, 50, 222, 15, 149, 243, 39, 9, 131, 196, 34, 229, 195, 158, 56, 140, 72, 182, 253, 164, 116,
				88, 148, 216, 26, 130, 18, 11, 194, 38, 203, 234, 86, 129, 26, 23, 224, 187, 90, 69, 199, 151, 25, 120, 58, 183, 110, 165,
				237, 180, 88, 249, 205, 92, 182, 208, 221, 225, 244, 32, 20, 248, 224, 167, 103, 99, 52, 48, 28, 190, 205, 29, 98, 116, 76,
				153, 42, 58, 88, 125, 102, 159, 171, 102, 37, 161, 191, 114, 254, 156, 43, 172, 84, 207, 124, 251, 9, 147, 178, 178, 19, 185,
				205, 106, 156, 248, 157, 76, 46, 140, 108, 45, 71, 123, 248, 127, 189, 210, 111, 142, 60, 206, 142, 95, 78, 155, 141, 192, 72,
				82, 168, 59, 80, 74, 235, 10, 239, 123, 40, 57, 246, 156, 77, 253, 149, 232, 164, 166, 172, 17, 122, 31, 98, 3, 105, 29, 208, 3,
				20, 249, 172, 88, 36, 235, 94, 5, 198, 105, 185, 108, 86, 168, 207, 39, 132, 243, 12, 216, 140, 180, 2, 248, 213, 251, 20,
				253, 63, 50, 199, 203, 252, 3, 189, 243, 253, 187, 156, 177, 85, 74, 142, 188, 213, 197, 62, 224, 9, 204, 21, 236, 24, 5,
				89, 116, 181, 244, 135, 197, 81, 156, 167, 170, 128, 198, 84, 227, 27, 212, 202, 61, 211, 220, 188, 55, 148, 214, 189, 35,
				44, 144, 239, 146, 63, 100, 214, 241, 130, 229, 93, 208, 175, 199, 240, 87, 127, 148, 20, 74, 233, 166, 141, 13, 234, 3, 170,
				169, 158, 35, 102, 163, 92, 21, 22, 93, 229, 182, 66, 13, 67, 208, 220, 39, 207, 86, 246, 131, 88, 90, 148, 254, 97, 246, 51,
				107, 2, 210, 134, 22, 213, 239, 35, 177, 96, 124, 26, 205, 238, 222, 101, 223, 76, 39, 49, 17, 17, 213, 159, 88, 247, 241, 144,
				13, 221, 109, 19, 220, 22, 160, 167, 4, 44, 179, 221, 89, 139, 3, 172, 167, 81, 77, 198, 171, 13, 58, 244, 97, 49, 185, 154, 205,
				193, 156, 147, 37, 171, 52, 32, 89, 197, 209, 180, 207, 247, 228, 154, 37, 19, 187, 162, 7, 46, 170, 149, 56, 82, 30, 134, 20, 59,
				62, 108, 238, 72, 156, 59, 11, 54, 119, 55, 204, 41, 107, 230, 91, 70, 203, 251, 160, 168, 163, 196, 57, 247, 43, 154, 19, 63, 93,
				162, 182, 195, 69, 67, 92, 146, 19, 208, 22, 24, 64, 92, 134, 35, 19, 106, 46, 171, 223, 115, 25, 228, 74, 62, 198, 163, 231, 228,
				103, 116, 61, 115, 110, 143, 234, 106, 73, 15, 53, 138, 230, 204, 45, 149, 187, 204, 52, 153, 53, 111, 52, 33, 167, 27, 175, 94,
				174, 88, 93, 131, 201, 188, 46, 230, 218, 164, 255, 139, 245, 226, 107, 10, 63, 111, 126, 6, 241, 213, 129, 246, 157, 131, 133,
				134, 130, 249, 146, 163, 39, 212, 219, 205, 232, 182, 114, 181, 167, 99, 246, 198, 75, 125, 94, 92, 101, 131, 156, 146, 147, 147,
				1, 107, 80, 158, 77, 93, 215, 12, 5, 55, 89, 90, 70, 213, 143, 69, 40, 208, 56, 248, 184, 249, 198, 19, 154, 12, 176, 90, 138, 194,
				181, 29, 241, 131, 229, 235, 108, 72, 231, 92, 125, 244, 95, 126, 85, 114, 36, 160, 36, 67, 215, 248, 204, 126, 156, 147, 94, 150, 66,
				97, 40, 22, 230, 193, 110, 22, 116, 150, 29, 119, 215, 119, 207, 68, 0, 142, 184, 244, 220, 183, 209, 231, 74, 142, 179, 226, 50, 213,
				243, 201, 224, 67, 182, 18, 126, 50, 209, 236, 250, 32, 98, 208, 19, 45, 43, 216, 34, 57, 228, 246, 250, 236, 241, 161, 195, 204, 171,
				148, 202, 206, 139, 42, 150, 210, 66, 87, 244, 169, 57, 4, 52, 128, 95, 181, 61, 34, 202, 190, 238, 11, 218, 209, 176, 193, 4, 198,
				52, 141, 94, 92, 8, 67, 86, 216, 250, 187, 150, 114, 254, 243, 86, 88, 224, 122, 184, 48, 196, 198, 103, 53, 31, 78, 101, 211, 193,
				119, 17, 95, 169, 175, 139, 151, 6, 216, 191, 115, 160, 255, 60, 52, 252, 97, 65, 121, 130, 116, 26, 97, 70, 227, 16, 20, 13, 103, 48,
				126, 236, 197, 8, 25, 59, 114, 180, 88, 209, 145, 75, 148, 164, 165, 16, 0, 0, 0, 1, 0, 5, 88, 46, 53, 48, 57, 0, 0, 2, 199, 48, 130, 2,
				195, 48, 130, 1, 171, 160, 3, 2, 1, 2, 2, 4, 35, 179, 171, 221, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 11, 5, 0, 48, 18, 49, 16,
				48, 14, 6, 3, 85, 4, 3, 19, 7, 101, 120, 97, 109, 112, 108, 101, 48, 30, 23, 13, 50, 53, 48, 57, 51, 48, 48, 55, 52, 54, 50, 54, 90, 23,
				13, 50, 53, 49, 50, 50, 57, 48, 55, 52, 54, 50, 54, 90, 48, 18, 49, 16, 48, 14, 6, 3, 85, 4, 3, 19, 7, 101, 120, 97, 109, 112, 108, 101,
				48, 130, 1, 34, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 130, 1, 15, 0, 48, 130, 1, 10, 2, 130, 1, 1, 0, 161, 27, 101,
				84, 177, 200, 117, 241, 251, 97, 71, 128, 102, 150, 107, 38, 211, 3, 114, 80, 26, 96, 139, 170, 216, 107, 7, 240, 97, 85, 149, 14, 193,
				188, 208, 126, 222, 140, 154, 120, 102, 220, 155, 155, 21, 95, 232, 179, 112, 141, 81, 108, 165, 94, 81, 46, 168, 96, 9, 63, 202, 31,
				69, 48, 151, 80, 71, 18, 147, 192, 247, 188, 107, 165, 60, 165, 209, 230, 36, 194, 228, 64, 155, 185, 119, 2, 136, 87, 149, 11, 14,
				223, 111, 109, 103, 13, 228, 170, 80, 167, 219, 138, 207, 51, 240, 103, 207, 241, 110, 121, 126, 78, 240, 94, 226, 83, 189, 122, 77,
				228, 175, 80, 171, 190, 204, 95, 105, 226, 27, 244, 167, 59, 254, 126, 210, 83, 81, 202, 143, 206, 230, 128, 171, 112, 12, 186, 41, 57,
				194, 209, 106, 214, 114, 206, 114, 133, 62, 112, 244, 23, 196, 26, 160, 199, 214, 170, 212, 111, 81, 208, 191, 14, 190, 17, 73, 194, 236,
				110, 187, 198, 210, 140, 175, 209, 217, 228, 34, 182, 191, 19, 109, 127, 200, 197, 80, 48, 243, 57, 164, 190, 196, 201, 72, 108, 69, 44, 143,
				117, 197, 57, 235, 24, 2, 157, 208, 227, 15, 55, 22, 65, 28, 180, 4, 238, 233, 247, 64, 179, 171, 185, 207, 242, 143, 195, 40, 4, 141, 191,
				234, 12, 238, 233, 29, 145, 79, 125, 71, 141, 66, 143, 225, 150, 24, 155, 190, 129, 2, 3, 1, 0, 1, 163, 33, 48, 31, 48, 29, 6, 3, 85, 29, 14,
				4, 22, 4, 20, 72, 52, 249, 197, 8, 135, 232, 251, 123, 225, 154, 27, 197, 196, 29, 85, 169, 71, 33, 213, 48, 13, 6, 9, 42, 134, 72, 134, 247,
				13, 1, 1, 11, 5, 0, 3, 130, 1, 1, 0, 141, 153, 20, 70, 102, 12, 179, 34, 80, 241, 223, 253, 139, 9, 115, 244, 201, 1, 233, 233, 37, 78, 86, 49,
				51, 206, 52, 77, 224, 86, 97, 11, 43, 10, 245, 61, 53, 246, 91, 102, 157, 172, 21, 95, 7, 148, 141, 160, 86, 32, 178, 39, 138, 203, 59, 212, 59,
				163, 203, 187, 178, 239, 79, 141, 234, 209, 113, 40, 15, 158, 106, 229, 220, 253, 180, 240, 9, 112, 81, 16, 50, 122, 30, 41, 140, 255, 189, 3,
				219, 169, 152, 235, 88, 121, 124, 73, 37, 180, 241, 157, 43, 215, 240, 169, 198, 154, 77, 40, 21, 220, 18, 118, 84, 20, 199, 219, 54, 245, 10,
				87, 72, 232, 143, 5, 197, 115, 60, 82, 25, 54, 255, 144, 204, 237, 216, 118, 246, 138, 159, 104, 131, 25, 59, 176, 62, 97, 49, 185, 185, 40, 177,
				250, 130, 72, 117, 107, 217, 123, 238, 104, 182, 135, 201, 133, 58, 40, 197, 76, 167, 139, 135, 139, 230, 203, 226, 247, 61, 111, 141, 255, 194,
				228, 241, 90, 17, 68, 61, 132, 38, 23, 74, 52, 11, 53, 27, 74, 172, 229, 209, 222, 231, 60, 188, 205, 214, 26, 249, 50, 210, 36, 48, 200, 229,
				71, 137, 58, 218, 159, 110, 234, 244, 208, 80, 187, 46, 145, 50, 121, 150, 80, 70, 38, 24, 85, 224, 175, 219, 86, 245, 242, 191, 83, 194, 5, 114,
				82, 236, 230, 0, 130, 224, 80, 117, 164, 15, 165, 174, 242, 161, 35, 6, 82, 13, 71, 215, 190, 9, 235, 21, 180, 60, 197, 184, 136, 253, 106},
			true,
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := JKS(tt.text); got != tt.isSecret {
				t.Errorf("TestIsJKS() = %v, want %v", got, tt.isSecret)
			}
		})
	}
}
