// -*- Mode: Go; indent-tabs-mode: t -*-

/*
 * Copyright (C) 2016 Canonical Ltd
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

// Package systestkeys defines trusted assertions and keys to use in tests.
package systestkeys

import (
	"fmt"

	"github.com/snapcore/snapd/asserts"
	"github.com/snapcore/snapd/asserts/sysdb"
)

const (
	TestRootPrivKey = `-----BEGIN PGP PRIVATE KEY BLOCK-----
Version: GnuPG v1

lQcYBFdylTwBEAC9bEPfbZAEtndD09tF7a2+XMLICpGF4zEglDgK6bYyDd2soh1D
6u+fjFIxa32Ibab5CeCeFRlPircYkAcZcRHLW89bF5UQLWMZ7VlZfUYL1krUSswb
OJhgHbyR7g03D0xTpu8UkM2ZhJ82su2H5nFlgs0FtCaO5nH3S4qHMVJhRSw/j4xw
kUa0xFuVtMO0UzLG1cM565MjFLjekYKBAfQyitgNDc1B8pZNCuPNF4nxrMvSOJ1t
S7yhgm9fbjT4I9LjE3jTtLBZkG9qj23+4+mJNF/h4TbvXq+ZaFq0rGimInnjpChl
w5AD4mxoAxeeIEYx2F8SBS1Uc2ACtDiiBx6EKifZGPWxM0AkpcJMAgSn3mexY5IL
uHDj4fP/XlxykvuEm2FVvjxTFrKQss5WRPNPpOVkzdy/UFn9rkKGU1PwmNdNxk5q
e1UlHjYXESMyV4yWbc6xW4GdZQdMWbthDvZZc0CJIcz1+wQeJ0WYGe9xmQLC+Vax
JWOKgbPE/o9ZEjiG1OPzoh9Rmwg9h5VMHdqdTG5/Q7/W1A7O/s9+cDZoE6idfKnm
rZBEoH9oGkHjEzzO+W9jalwCaJCAOmZxr8qjkuXhW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ftY7Y/Vh0l0g6g74C7//HA
XEzuuFGl2ccu1GEOM0viXkn9tGXC62gVX+TFJxNsg15qe62hQtLINkVKCi3s2zM7
3aai+ZwUOQ7E02WsUOgtJIWmRjbDpH7O+hZuYiJ4XmrojtR8o2huQw9fGvLhyiOn
H4KbW/+3S5hlW+ATgjdbumC1uOvMDEp6aL30vaUHD4TQKlCqmKxXMyFP3uh9bJyE
uqszOvLqGC6upDIUVgFw8/doJXwq/mBs4DQrqJJ3qA0bMjI8UkF3mJj62foS/HxX
1ip42ReKe21br0w+0tllfdzlnMDiNoOFhks5F2YM+bSNL4Uahthu4SbqAv6HuUHm
QrQRAbBzIzUmVnBXDAZT3JPHEOyWWECDbD8UkS4Xvw176lmEsAHB2GsrGYSWJt04
JONDXPT7aSeqpN/OscUrNgtoqfyuEVRlYAUM+ZLMvl1JSPxFeKnarlGFZ8DQ8J8n
B9M+dghZ
=erKK
-----END PGP PRIVATE KEY BLOCK-----
`

	encodedTestRootAccount = `type: account
authority-id: testrootorg
account-id: testrootorg
display-name: Test Root Org
timestamp: 2016-06-27T00:00:00.0Z
username: testrootorg
validation: certified

openpgp wsFcBAABCgAGBQJXcpitAAoJEM6nan6yFrPKzqUP+wUQz+TXSKTNbls1lnfq6kFgLWhR
RvIfCGysoActhRiiqmJwePhFKbzF8CM8RsR+WbPx7oc00CSE9LWzhu8xjw1bHnheIfE8boKO2oSX
N4iQFQjILniRksNxnjbzF+ZNsPSgIE0APr9YvGGg9P1ioSGjBbRGgPLGnBhpyWvE/EM+pkIxN4nE
0HpdnyMhbJmJv1M+3LKQPKIkw5khwCgeVNhWlSqpf1MhwisqjvH/RgotpOu/Qi20I+SRp9exB7ph
7bKpmEbHBxPsLcsunAxW7Ck1kdAt6vBE9XNBpz8IrSk9QQRgRCQ2WqKE4DGrPFERMmTDOhg+CnW8
pG4+lDcqf4rVjhJ27NXdgJJCelpGWfJAP8+fcpBGLEQb/RqpSNSYpEjjmHWwOlY2YengNCsrITNO
T59mqSm9EguQ+Z/YvGQ3G6a9oNThXsqo6KzAIGY96uPCCjxWxjK6bUnPXKg1slCCp/oELB35bbOh
FEVVOPHjRqdPmCZzpO0Fwf8sE+Ck2LUqnO8fM46A9vqOG6BXL/9eqeSmpshukwvd7b1XOvfT6iAt
L3dea3ooWp+m9fdWZZeqcbFANp3wG36Bymfhvu+xVpAc1eg3P9L6MTJRmudUk22St77KweN+P8mP
j/bmA6XRTM79PxGEv3wkTPf98l0aH2xL1JslsRgXLp+07NAq
`
	TestRootKeyID = "cea76a7eb216b3ca"

	encodedTestRootAccountKey = `type: account-key
authority-id: testrootorg
account-id: testrootorg
public-key-id: cea76a7eb216b3ca
public-key-fingerprint: e6ef383d57810cd54c0091f0cea76a7eb216b3ca
since: 2016-06-27T00:00:00.0Z
until: 2026-06-27T00:00:00.0Z
body-length: 1496

openpgp mQINBFdylTwBEAC9bEPfbZAEtndD09tF7a2+XMLICpGF4zEglDgK6bYyDd2soh1D6u+fjFIxa32Ibab5CeCeFRlPircYkAcZcRHLW89bF5UQLWMZ7VlZfUYL1krUSswbOJhgHbyR7g03D0xTpu8UkM2ZhJ82su2H5nFlgs0FtCaO5nH3S4qHMVJhRSw/j4xwkUa0xFuVtMO0UzLG1cM565MjFLjekYKBAfQyitgNDc1B8pZNCuPNF4nxrMvSOJ1tS7yhgm9fbjT4I9LjE3jTtLBZkG9qj23+4+mJNF/h4TbvXq+ZaFq0rGimInnjpChlw5AD4mxoAxeeIEYx2F8SBS1Uc2ACtDiiBx6EKifZGPWxM0AkpcJMAgSn3mexY5ILuHDj4fP/XlxykvuEm2FVvjxTFrKQss5WRPNPpOVkzdy/UFn9rkKGU1PwmNdNxk5qe1UlHjYXESMyV4yWbc6xW4GdZQdMWbthDvZZc0CJIcz1+wQeJ0WYGe9xmQLC+VaxJWOKgbPE/o9ZEjiG1OPzoh9Rmwg9h5VMHdqdTG5/Q7/W1A7O/s9+cDZoE6idfKnmrZBEoH9oGkHjEzzO+W9jalwCaJCAOmZxr8q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Aci4ZmDhYjRuM2eFSGotQcHSJ7nVJqsv
CPhuRgoSxVPCwnSa3WG2a2MGPhJnQqOWMMqd+zP9UrxW4JUDSqNWK2loJ+lcporO
m9aNFyyf8Nhs7PNjOcXTeOE7oBQLMMwRd3aSy84YQRamzjXG9U6C0lMPUDnVTk5W
rP9sczsqMrjIslwNSZFhFqT/NW/BzxdmuPe7zqIac4D5Vvv91Ph1PflpFPZXwSKw
00jpt5ZcurnJCJVps0oVlKjLgts34hMlhgRTRa5ozVxl8jU+32ZnjDiYhHtk8on6
5ZAepXDaLoUIVYS7IvwXahhPJbiTR3eMI7oTxv/mFnyFzLTYsBetix7mRntX0q09
x2edbS8SwTD/CU93+a161z/qw24/iQ871c7M6/kwkp0nw4kz3qzMd0wk7mjcGy5b
h+GeQgloWaupO28YFp8CZvE74KGb5HTFmXGSIJvJ+5qoCY8kNo/7TeobRrd7ZdvC
FJSTKNId2OfeU9hq9dE6SJEoB0KOgWpgvJeGz6v9L3BtjLPgkgo1Gngq7hFnJhd3
MQKv0/BPeDL47IEoc0RXMkWWRZLs3vjGAtKCK5B0MXTHPQvyr9qP8rSNN+z9kDQQ
cXL5aE5caL7jvfUI
=ZUAq
-----END PGP PRIVATE KEY BLOCK-----
`

	TestStoreKeyID = "190213b78d289b59"
)

var (
	TestRootAccount    asserts.Assertion
	TestRootAccountKey asserts.Assertion
)

func init() {
	acct, err := asserts.Decode([]byte(encodedTestRootAccount))
	if err != nil {
		panic(fmt.Sprintf("cannot decode trusted assertion: %v", err))
	}
	accKey, err := asserts.Decode([]byte(encodedTestRootAccountKey))
	if err != nil {
		panic(fmt.Sprintf("cannot decode trusted assertion: %v", err))
	}

	TestRootAccount = acct
	TestRootAccountKey = accKey
}

// Inject includes the test trusted assertions in the system trusted set.
func Inject() {
	sysdb.InjectTrusted([]asserts.Assertion{TestRootAccount, TestRootAccountKey})
}
