-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdecode_test.go
52 lines (47 loc) · 15.5 KB
/
decode_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package applereceipt
import (
"os"
"strings"
"testing"
"time"
. "github.com/smartystreets/goconvey/convey"
"github.com/devsisters/go-applereceipt/applepki"
)
func TestDecodeBase64(t *testing.T) {
Convey("DecodeBase64 function can decode receipts", t, func() {
const sandboxReceipt = "MIIURAYJKoZIhvcNAQcCoIIUNTCCFDECAQExCzAJBgUrDgMCGgUAMIIDggYJKoZIhvcNAQcBoIIDcwSCA28xggNrMAoCAQgCAQEEAhYAMAoCARQCAQEEAgwAMAsCAQECAQEEAwIBADALAgELAgEBBAMCAQAwCwIBDwIBAQQDAgEAMAsCARACAQEEAwIBADALAgEZAgEBBAMCAQMwDAIBCgIBAQQEFgI0KzAMAgEOAgEBBAQCAgDNMA0CAQ0CAQEEBQIDAiTUMA0CARMCAQEEBQwDMS4wMA4CAQkCAQEEBgIEUDI2MDASAgEDAgEBBAoMCDEwMDAxMTAwMBgCAQQCAQIEEFb8NoPul2OWuSEs3dV3TggwGwIBAAIBAQQTDBFQcm9kdWN0aW9uU2FuZGJveDAbAgECAgEBBBMMEWNvbS5kZXZzaXN0ZXJzLmdiMBwCAQUCAQEEFG13MQBtWUHO/8h48zvLWLIGblVlMB4CAQwCAQEEFhYUMjAyMy0wMi0yMVQwNzo1MDoxN1owHgIBEgIBAQQWFhQyMDEzLTA4LTAxVDA3OjAwOjAwWjBCAgEGAgEBBDq0ossqtJfjHcl+Kkt1ogdeuQJNRU2QHZMztC3cPy3egpTQTpTgn4kdUzWgmCDfGShMvW/Y9XUTauHTMFECAQcCAQEESZlP8vA2X5FWOJa3kc7tT8E+bPdDfL1ZUCkOJjUW6oa8c0TC/3zTd0ZlPeAqEwnepd0DMoPhtgym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vIB+x9OYOLUyDTOMSxv5pPCmv/K/xZpwUJfBdAVhEedNO3iyM7R6PVbyTi69G3cN8PReEnyvFteO3ntRcXqNx+IjXKJdXZD9Zr1KIkIxH3oayPc4FgxhtbCS+SsvhESPBgOJ4V9T0mZyCKM2r3DYLP3uujL/lTaltkwGMzd/c6ByxW69oPIQ7aunMZT7XZNn/Bh1XZp5m5MkL72NVxnn6hUrcbvZNCJBIqxw8dtk2cXmPIS4AXUKqK1drk/NAJBzewdXUhMYIBsTCCAa0CAQEwgYkwdTELMAkGA1UEBhMCVVMxEzARBgNVBAoMCkFwcGxlIEluYy4xCzAJBgNVBAsMAkc3MUQwQgYDVQQDDDtBcHBsZSBXb3JsZHdpZGUgRGV2ZWxvcGVyIFJlbGF0aW9ucyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eQIQLasDG73WZXPSByl5PESXxDAJBgUrDgMCGgUAMA0GCSqGSIb3DQEBAQUABIIBAGGDpJ/EAge8cVd1vuOJMnMM53EBcckybBnig4ptcAY6Y4BLWVkTsBfzM8ukbo8D7wuSfbv0bmdXpq9gVYEmxwNm4oMpmlC8m4VgxTGUcaeK+vfGzAKwYzC9u3XmL7hlnJpj2tAn3La5SqmLO7d761VI5hHgRWn8GLosonBMS9t//XPWPdSJ01j8JzjlQOmbAZ1Cj3zx/vMb7x79mAw46ZoxJpXkE7irJdBVmOK25A+2huvn/7vQFNLyxiTt7nw3imuoVwzx8I2kwsutIJFGyJbbZTszOvG4B2NsqajDTDx03XajHU++toFP6LiP+v4ckyWBxAn1e9STtpX6HkTUz98="
Convey("without verification", func() {
receipt, err := DecodeBase64(sandboxReceipt, nil)
So(err, ShouldBeNil)
So(receipt.BundleIdentifier, ShouldEqual, "com.devsisters.gb")
So(receipt.InAppPurchaseReceipts, ShouldHaveLength, 1)
So(receipt.InAppPurchaseReceipts[0].ProductIdentifier, ShouldEqual, "gb.tier5.seqcookie.a")
So(receipt.InAppPurchaseReceipts[0].PurchaseDate, ShouldEqual, time.Date(2023, 2, 8, 7, 58, 58, 0, time.UTC))
So(receipt.InAppPurchaseReceipts[0].Quantity, ShouldEqual, 1)
})
Convey("with verification", func() {
receipt, err := DecodeBase64(sandboxReceipt, applepki.CertPool())
if err != nil && strings.Contains(err.Error(), "temporarily override with GODEBUG=x509sha1=1") {
err = os.Setenv("GODEBUG", "x509sha1=1")
So(err, ShouldBeNil)
receipt, err = DecodeBase64(sandboxReceipt, applepki.CertPool())
}
So(err, ShouldBeNil)
So(receipt.BundleIdentifier, ShouldEqual, "com.devsisters.gb")
So(receipt.InAppPurchaseReceipts, ShouldHaveLength, 1)
So(receipt.InAppPurchaseReceipts[0].ProductIdentifier, ShouldEqual, "gb.tier5.seqcookie.a")
So(receipt.InAppPurchaseReceipts[0].PurchaseDate, ShouldEqual, time.Date(2023, 2, 8, 7, 58, 58, 0, time.UTC))
So(receipt.InAppPurchaseReceipts[0].Quantity, ShouldEqual, 1)
})
})
Convey("DecodeBase64 can verify old receipts that was signed with now-expired certificates", t, func() {
const oldReceipt = "MIIT4wYJKoZIhvcNAQcCoIIT1DCCE9ACAQExCzAJBgUrDgMCGgUAMIIDhAYJKoZIhvcNAQcBoIIDdQSCA3ExggNtMAoCARQCAQEEAgwAMAsCARkCAQEEAwIBAzAMAgEDAgEBBAQMAjEyMAwCAQoCAQEEBBYCNCswDAIBDgIBAQQEAgIAjTAMAgETAgEBBAQMAjEyMA0CAQsCAQEEBQIDA1o3MA0CAQ0CAQEEBQIDAWC+MA4CAQECAQEEBgIEOWc9wjAOAgEJAgEBBAYCBFAyNDcwDgIBEAIBAQQGAgQwYVW3MBACAQ8CAQEECAIGQJZIGW/cMBQCAQACAQEEDAwKUHJvZHVjdGlvbjAYAgEEAgECBBBL+yYA2sKtpWxhRntKG7PKMBsCAQICAQEEEwwRY29tLmRldnNpc3RlcnMuZ2IwHAIBBQIBAQQU3dHLbdYlrJaKWiQIabfCuqYRy/UwHgIBCAIBAQQWFhQyMDE2LTA5LTI3VDExOjU1OjM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37Yyb3PN3m/J20ncwT8EfhYOFG5k9RzfyqZtAjizUsZAS2L70c5vu0mQPy3lPNNiiPvl4/2vIB+x9OYOLUyDTOMSxv5pPCmv/K/xZpwUJfBdAVhEedNO3iyM7R6PVbyTi69G3cN8PReEnyvFteO3ntRcXqNx+IjXKJdXZD9Zr1KIkIxH3oayPc4FgxhtbCS+SsvhESPBgOJ4V9T0mZyCKM2r3DYLP3uujL/lTaltkwGMzd/c6ByxW69oPIQ7aunMZT7XZNn/Bh1XZp5m5MkL72NVxnn6hUrcbvZNCJBIqxw8dtk2cXmPIS4AXUKqK1drk/NAJBzewdXUhMYIByzCCAccCAQEwgaMwgZYxCzAJBgNVBAYTAlVTMRMwEQYDVQQKDApBcHBsZSBJbmMuMSwwKgYDVQQLDCNBcHBsZSBXb3JsZHdpZGUgRGV2ZWxvcGVyIFJlbGF0aW9uczFEMEIGA1UEAww7QXBwbGUgV29ybGR3aWRlIERldmVsb3BlciBSZWxhdGlvbnMgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkCCA7rV4fnngmNMAkGBSsOAwIaBQAwDQYJKoZIhvcNAQEBBQAEggEAQ99FQjMJPU1W7e7HGD+K/2amMgDEIB3WNd/dg2tl3cHJG8W77qTgFyYNR6GU+AAFflabYvrvw+X2Yy9rMVCBzPlP9T+W5PCo0RxQK1M64aUryRLrnNLqbwG3IwmNxUac8whEhEF7ZH8RMISm54uXO6GdAyHqFi8UW9mRLHeewelTGTD/4jBhcLJE9HGZ02uzFR56hO4boWojgFOTYZs3ax6gSsIxCsvPyEHJDhbUUGSYgGTb4hJ3Byn4TFRHPdshHgbCTyKy2UPN8eA5ovARPbeCsFhcpdaw45pNPLOxS3yv0YJ5QpPQoT6LHXr9h56q5Lz3+F9aQLz5fPVzHJTgKQ=="
receipt, err := DecodeBase64(oldReceipt, nil)
So(err, ShouldBeNil)
So(receipt.BundleIdentifier, ShouldEqual, "com.devsisters.gb")
So(receipt.InAppPurchaseReceipts, ShouldHaveLength, 1)
So(receipt.InAppPurchaseReceipts[0].ProductIdentifier, ShouldEqual, "gb.tier1.crystal")
So(receipt.InAppPurchaseReceipts[0].PurchaseDate, ShouldEqual, time.Date(2016, 9, 27, 11, 54, 2, 0, time.UTC))
So(receipt.InAppPurchaseReceipts[0].Quantity, ShouldEqual, 1)
})
}