1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
12 check "gopkg.in/check.v1"
15 var _ = check.Suite(&ExportSuite{})
17 type ExportSuite struct{}
19 func (s *ExportSuite) TestExport(c *check.C) {
20 confdata := strings.Replace(string(DefaultYAML), "SAMPLE", "12345", -1)
21 cfg, err := testLoader(c, confdata, nil).Load()
22 c.Assert(err, check.IsNil)
23 cluster, err := cfg.GetCluster("xxxxx")
24 c.Assert(err, check.IsNil)
25 cluster.ManagementToken = "abcdefg"
27 var exported bytes.Buffer
28 err = ExportJSON(&exported, cluster)
29 c.Check(err, check.IsNil)
31 c.Logf("If all the new keys are safe, add these to whitelist in export.go:")
32 for _, k := range regexp.MustCompile(`"[^"]*"`).FindAllString(err.Error(), -1) {
33 c.Logf("\t%q: true,", strings.Replace(k, `"`, "", -1))
36 var exportedStr = exported.String()
37 c.Check(exportedStr, check.Matches, `(?ms).*ClusterID":"xxxxx.*`)
38 c.Check(exportedStr, check.Not(check.Matches), `(?ms).*abcdefg.*`)