authority_test.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. package authority
  2. import (
  3. "context"
  4. "crypto"
  5. "crypto/rand"
  6. "crypto/sha256"
  7. "crypto/x509"
  8. "encoding/hex"
  9. "encoding/pem"
  10. "fmt"
  11. "net"
  12. "os"
  13. "path/filepath"
  14. "reflect"
  15. "testing"
  16. "time"
  17. "github.com/pkg/errors"
  18. "github.com/smallstep/assert"
  19. "github.com/smallstep/certificates/authority/config"
  20. "github.com/smallstep/certificates/authority/provisioner"
  21. "github.com/smallstep/certificates/db"
  22. "go.step.sm/crypto/jose"
  23. "go.step.sm/crypto/minica"
  24. "go.step.sm/crypto/pemutil"
  25. )
  26. func TestMain(m *testing.M) {
  27. if err := initializeSystemCertPool(); err != nil {
  28. fmt.Fprintf(os.Stderr, "failed to initialize system cert pool: %v\n", err)
  29. fmt.Fprintln(os.Stderr, "See https://pkg.go.dev/crypto/x509#SystemCertPool")
  30. os.Exit(2)
  31. }
  32. os.Exit(m.Run())
  33. }
  34. func testAuthority(t *testing.T, opts ...Option) *Authority {
  35. maxjwk, err := jose.ReadKey("testdata/secrets/max_pub.jwk")
  36. assert.FatalError(t, err)
  37. clijwk, err := jose.ReadKey("testdata/secrets/step_cli_key_pub.jwk")
  38. assert.FatalError(t, err)
  39. disableRenewal := true
  40. enableSSHCA := true
  41. p := provisioner.List{
  42. &provisioner.JWK{
  43. Name: "Max",
  44. Type: "JWK",
  45. Key: maxjwk,
  46. },
  47. &provisioner.JWK{
  48. Name: "step-cli",
  49. Type: "JWK",
  50. Key: clijwk,
  51. Claims: &provisioner.Claims{
  52. EnableSSHCA: &enableSSHCA,
  53. },
  54. },
  55. &provisioner.JWK{
  56. Name: "dev",
  57. Type: "JWK",
  58. Key: maxjwk,
  59. Claims: &provisioner.Claims{
  60. DisableRenewal: &disableRenewal,
  61. },
  62. },
  63. &provisioner.JWK{
  64. Name: "renew_disabled",
  65. Type: "JWK",
  66. Key: maxjwk,
  67. Claims: &provisioner.Claims{
  68. DisableRenewal: &disableRenewal,
  69. },
  70. },
  71. &provisioner.SSHPOP{
  72. Name: "sshpop",
  73. Type: "SSHPOP",
  74. Claims: &provisioner.Claims{
  75. EnableSSHCA: &enableSSHCA,
  76. },
  77. },
  78. &provisioner.ACME{
  79. Name: "acme",
  80. Type: "ACME",
  81. },
  82. &provisioner.JWK{
  83. Name: "uninitialized",
  84. Type: "JWK",
  85. Key: clijwk,
  86. Claims: &provisioner.Claims{
  87. MinTLSDur: &provisioner.Duration{Duration: 5 * time.Minute},
  88. MaxTLSDur: &provisioner.Duration{Duration: time.Minute},
  89. },
  90. },
  91. }
  92. c := &Config{
  93. Address: "127.0.0.1:443",
  94. Root: []string{"testdata/certs/root_ca.crt"},
  95. IntermediateCert: "testdata/certs/intermediate_ca.crt",
  96. IntermediateKey: "testdata/secrets/intermediate_ca_key",
  97. SSH: &SSHConfig{
  98. HostKey: "testdata/secrets/ssh_host_ca_key",
  99. UserKey: "testdata/secrets/ssh_user_ca_key",
  100. },
  101. DNSNames: []string{"example.com"},
  102. Password: "pass",
  103. AuthorityConfig: &AuthConfig{
  104. Provisioners: p,
  105. },
  106. }
  107. a, err := New(c, opts...)
  108. assert.FatalError(t, err)
  109. // Avoid errors when test tokens are created before the test authority. This
  110. // happens in some tests where we re-create the same authority to test
  111. // special cases without re-creating the token.
  112. a.startTime = a.startTime.Add(-1 * time.Minute)
  113. return a
  114. }
  115. func TestAuthorityNew(t *testing.T) {
  116. type newTest struct {
  117. config *Config
  118. err error
  119. }
  120. tests := map[string]func(t *testing.T) *newTest{
  121. "ok": func(t *testing.T) *newTest {
  122. c, err := LoadConfiguration("../ca/testdata/ca.json")
  123. assert.FatalError(t, err)
  124. return &newTest{
  125. config: c,
  126. }
  127. },
  128. "fail bad root": func(t *testing.T) *newTest {
  129. c, err := LoadConfiguration("../ca/testdata/ca.json")
  130. assert.FatalError(t, err)
  131. c.Root = []string{"foo"}
  132. return &newTest{
  133. config: c,
  134. err: errors.New(`error reading "foo": no such file or directory`),
  135. }
  136. },
  137. "fail bad password": func(t *testing.T) *newTest {
  138. c, err := LoadConfiguration("../ca/testdata/ca.json")
  139. assert.FatalError(t, err)
  140. c.Password = "wrong"
  141. return &newTest{
  142. config: c,
  143. err: errors.New("error decrypting ../ca/testdata/secrets/intermediate_ca_key: x509: decryption password incorrect"),
  144. }
  145. },
  146. "fail loading CA cert": func(t *testing.T) *newTest {
  147. c, err := LoadConfiguration("../ca/testdata/ca.json")
  148. assert.FatalError(t, err)
  149. c.IntermediateCert = "wrong"
  150. return &newTest{
  151. config: c,
  152. err: errors.New(`error reading "wrong": no such file or directory`),
  153. }
  154. },
  155. }
  156. for name, genTestCase := range tests {
  157. t.Run(name, func(t *testing.T) {
  158. tc := genTestCase(t)
  159. auth, err := New(tc.config)
  160. if err != nil {
  161. if assert.NotNil(t, tc.err) {
  162. assert.HasPrefix(t, err.Error(), tc.err.Error())
  163. }
  164. } else {
  165. if assert.Nil(t, tc.err) {
  166. sum := sha256.Sum256(auth.rootX509Certs[0].Raw)
  167. root, ok := auth.certificates.Load(hex.EncodeToString(sum[:]))
  168. assert.Fatal(t, ok)
  169. assert.Equals(t, auth.rootX509Certs[0], root)
  170. assert.True(t, auth.initOnce)
  171. assert.NotNil(t, auth.x509CAService)
  172. for _, p := range tc.config.AuthorityConfig.Provisioners {
  173. var _p provisioner.Interface
  174. _p, ok = auth.provisioners.Load(p.GetID())
  175. assert.True(t, ok)
  176. assert.Equals(t, p, _p)
  177. var kid, encryptedKey string
  178. if kid, encryptedKey, ok = p.GetEncryptedKey(); ok {
  179. var key string
  180. key, ok = auth.provisioners.LoadEncryptedKey(kid)
  181. assert.True(t, ok)
  182. assert.Equals(t, encryptedKey, key)
  183. }
  184. }
  185. // sanity check
  186. _, ok = auth.provisioners.Load("fooo")
  187. assert.False(t, ok)
  188. }
  189. }
  190. })
  191. }
  192. }
  193. func TestAuthorityNew_bundles(t *testing.T) {
  194. ca0, err := minica.New()
  195. if err != nil {
  196. t.Fatal(err)
  197. }
  198. ca1, err := minica.New()
  199. if err != nil {
  200. t.Fatal(err)
  201. }
  202. ca2, err := minica.New()
  203. if err != nil {
  204. t.Fatal(err)
  205. }
  206. rootPath := t.TempDir()
  207. writeCert := func(fn string, certs ...*x509.Certificate) error {
  208. var b []byte
  209. for _, crt := range certs {
  210. b = append(b, pem.EncodeToMemory(&pem.Block{
  211. Type: "CERTIFICATE",
  212. Bytes: crt.Raw,
  213. })...)
  214. }
  215. return os.WriteFile(filepath.Join(rootPath, fn), b, 0600)
  216. }
  217. writeKey := func(fn string, signer crypto.Signer) error {
  218. _, err := pemutil.Serialize(signer, pemutil.ToFile(filepath.Join(rootPath, fn), 0600))
  219. return err
  220. }
  221. if err := writeCert("root0.crt", ca0.Root); err != nil {
  222. t.Fatal(err)
  223. }
  224. if err := writeCert("int0.crt", ca0.Intermediate); err != nil {
  225. t.Fatal(err)
  226. }
  227. if err := writeKey("int0.key", ca0.Signer); err != nil {
  228. t.Fatal(err)
  229. }
  230. if err := writeCert("root1.crt", ca1.Root); err != nil {
  231. t.Fatal(err)
  232. }
  233. if err := writeCert("int1.crt", ca1.Intermediate); err != nil {
  234. t.Fatal(err)
  235. }
  236. if err := writeKey("int1.key", ca1.Signer); err != nil {
  237. t.Fatal(err)
  238. }
  239. if err := writeCert("bundle0.crt", ca0.Root, ca1.Root); err != nil {
  240. t.Fatal(err)
  241. }
  242. if err := writeCert("bundle1.crt", ca1.Root, ca2.Root); err != nil {
  243. t.Fatal(err)
  244. }
  245. tests := []struct {
  246. name string
  247. config *config.Config
  248. wantErr bool
  249. }{
  250. {"ok ca0", &config.Config{
  251. Address: "127.0.0.1:443",
  252. Root: []string{filepath.Join(rootPath, "root0.crt")},
  253. IntermediateCert: filepath.Join(rootPath, "int0.crt"),
  254. IntermediateKey: filepath.Join(rootPath, "int0.key"),
  255. DNSNames: []string{"127.0.0.1"},
  256. AuthorityConfig: &AuthConfig{},
  257. }, false},
  258. {"ok bundle", &config.Config{
  259. Address: "127.0.0.1:443",
  260. Root: []string{filepath.Join(rootPath, "bundle0.crt")},
  261. IntermediateCert: filepath.Join(rootPath, "int0.crt"),
  262. IntermediateKey: filepath.Join(rootPath, "int0.key"),
  263. DNSNames: []string{"127.0.0.1"},
  264. AuthorityConfig: &AuthConfig{},
  265. }, false},
  266. {"ok federated ca1", &config.Config{
  267. Address: "127.0.0.1:443",
  268. Root: []string{filepath.Join(rootPath, "root0.crt")},
  269. FederatedRoots: []string{filepath.Join(rootPath, "root1.crt")},
  270. IntermediateCert: filepath.Join(rootPath, "int0.crt"),
  271. IntermediateKey: filepath.Join(rootPath, "int0.key"),
  272. DNSNames: []string{"127.0.0.1"},
  273. AuthorityConfig: &AuthConfig{},
  274. }, false},
  275. {"ok federated bundle", &config.Config{
  276. Address: "127.0.0.1:443",
  277. Root: []string{filepath.Join(rootPath, "root0.crt")},
  278. FederatedRoots: []string{filepath.Join(rootPath, "bundle1.crt")},
  279. IntermediateCert: filepath.Join(rootPath, "int0.crt"),
  280. IntermediateKey: filepath.Join(rootPath, "int0.key"),
  281. DNSNames: []string{"127.0.0.1"},
  282. AuthorityConfig: &AuthConfig{},
  283. }, false},
  284. {"fail root", &config.Config{
  285. Address: "127.0.0.1:443",
  286. Root: []string{filepath.Join(rootPath, "missing.crt")},
  287. IntermediateCert: filepath.Join(rootPath, "int0.crt"),
  288. IntermediateKey: filepath.Join(rootPath, "int0.key"),
  289. DNSNames: []string{"127.0.0.1"},
  290. AuthorityConfig: &AuthConfig{},
  291. }, true},
  292. {"fail federated", &config.Config{
  293. Address: "127.0.0.1:443",
  294. Root: []string{filepath.Join(rootPath, "root0.crt")},
  295. FederatedRoots: []string{filepath.Join(rootPath, "missing.crt")},
  296. IntermediateCert: filepath.Join(rootPath, "int0.crt"),
  297. IntermediateKey: filepath.Join(rootPath, "int0.key"),
  298. DNSNames: []string{"127.0.0.1"},
  299. AuthorityConfig: &AuthConfig{},
  300. }, true},
  301. }
  302. for _, tt := range tests {
  303. t.Run(tt.name, func(t *testing.T) {
  304. _, err := New(tt.config)
  305. if (err != nil) != tt.wantErr {
  306. t.Errorf("New() error = %v, wantErr %v", err, tt.wantErr)
  307. return
  308. }
  309. })
  310. }
  311. }
  312. func TestAuthority_GetDatabase(t *testing.T) {
  313. auth := testAuthority(t)
  314. authWithDatabase, err := New(auth.config, WithDatabase(auth.db))
  315. assert.FatalError(t, err)
  316. tests := []struct {
  317. name string
  318. auth *Authority
  319. want db.AuthDB
  320. }{
  321. {"ok", auth, auth.db},
  322. {"ok WithDatabase", authWithDatabase, auth.db},
  323. }
  324. for _, tt := range tests {
  325. t.Run(tt.name, func(t *testing.T) {
  326. if got := tt.auth.GetDatabase(); !reflect.DeepEqual(got, tt.want) {
  327. t.Errorf("Authority.GetDatabase() = %v, want %v", got, tt.want)
  328. }
  329. })
  330. }
  331. }
  332. func TestNewEmbedded(t *testing.T) {
  333. caPEM, err := os.ReadFile("testdata/certs/root_ca.crt")
  334. assert.FatalError(t, err)
  335. crt, err := pemutil.ReadCertificate("testdata/certs/intermediate_ca.crt")
  336. assert.FatalError(t, err)
  337. key, err := pemutil.Read("testdata/secrets/intermediate_ca_key", pemutil.WithPassword([]byte("pass")))
  338. assert.FatalError(t, err)
  339. type args struct {
  340. opts []Option
  341. }
  342. tests := []struct {
  343. name string
  344. args args
  345. wantErr bool
  346. }{
  347. {"ok", args{[]Option{WithX509RootBundle(caPEM), WithX509Signer(crt, key.(crypto.Signer))}}, false},
  348. {"ok empty config", args{[]Option{WithConfig(&Config{}), WithX509RootBundle(caPEM), WithX509Signer(crt, key.(crypto.Signer))}}, false},
  349. {"ok config file", args{[]Option{WithConfigFile("../ca/testdata/ca.json")}}, false},
  350. {"ok config", args{[]Option{WithConfig(&Config{
  351. Root: []string{"testdata/certs/root_ca.crt"},
  352. IntermediateCert: "testdata/certs/intermediate_ca.crt",
  353. IntermediateKey: "testdata/secrets/intermediate_ca_key",
  354. Password: "pass",
  355. AuthorityConfig: &AuthConfig{},
  356. })}}, false},
  357. {"fail options", args{[]Option{WithX509RootBundle([]byte("bad data"))}}, true},
  358. {"fail missing config", args{[]Option{WithConfig(nil), WithX509RootBundle(caPEM), WithX509Signer(crt, key.(crypto.Signer))}}, true},
  359. {"fail missing root", args{[]Option{WithX509Signer(crt, key.(crypto.Signer))}}, true},
  360. {"fail missing signer", args{[]Option{WithX509RootBundle(caPEM)}}, true},
  361. {"fail missing root file", args{[]Option{WithConfig(&Config{
  362. IntermediateCert: "testdata/certs/intermediate_ca.crt",
  363. IntermediateKey: "testdata/secrets/intermediate_ca_key",
  364. Password: "pass",
  365. AuthorityConfig: &AuthConfig{},
  366. })}}, true},
  367. {"fail missing issuer", args{[]Option{WithConfig(&Config{
  368. Root: []string{"testdata/certs/root_ca.crt"},
  369. IntermediateKey: "testdata/secrets/intermediate_ca_key",
  370. Password: "pass",
  371. AuthorityConfig: &AuthConfig{},
  372. })}}, true},
  373. {"fail missing signer", args{[]Option{WithConfig(&Config{
  374. Root: []string{"testdata/certs/root_ca.crt"},
  375. IntermediateCert: "testdata/certs/intermediate_ca.crt",
  376. Password: "pass",
  377. AuthorityConfig: &AuthConfig{},
  378. })}}, true},
  379. {"fail bad password", args{[]Option{WithConfig(&Config{
  380. Root: []string{"testdata/certs/root_ca.crt"},
  381. IntermediateCert: "testdata/certs/intermediate_ca.crt",
  382. IntermediateKey: "testdata/secrets/intermediate_ca_key",
  383. Password: "bad",
  384. AuthorityConfig: &AuthConfig{},
  385. })}}, true},
  386. }
  387. for _, tt := range tests {
  388. t.Run(tt.name, func(t *testing.T) {
  389. got, err := NewEmbedded(tt.args.opts...)
  390. if (err != nil) != tt.wantErr {
  391. t.Errorf("NewEmbedded() error = %v, wantErr %v", err, tt.wantErr)
  392. return
  393. }
  394. if err == nil {
  395. assert.True(t, got.initOnce)
  396. assert.NotNil(t, got.rootX509Certs)
  397. assert.NotNil(t, got.x509CAService)
  398. }
  399. })
  400. }
  401. }
  402. func TestNewEmbedded_Sign(t *testing.T) {
  403. caPEM, err := os.ReadFile("testdata/certs/root_ca.crt")
  404. assert.FatalError(t, err)
  405. crt, err := pemutil.ReadCertificate("testdata/certs/intermediate_ca.crt")
  406. assert.FatalError(t, err)
  407. key, err := pemutil.Read("testdata/secrets/intermediate_ca_key", pemutil.WithPassword([]byte("pass")))
  408. assert.FatalError(t, err)
  409. a, err := NewEmbedded(WithX509RootBundle(caPEM), WithX509Signer(crt, key.(crypto.Signer)))
  410. assert.FatalError(t, err)
  411. // Sign
  412. cr, err := x509.CreateCertificateRequest(rand.Reader, &x509.CertificateRequest{
  413. DNSNames: []string{"foo.bar.zar"},
  414. }, key)
  415. assert.FatalError(t, err)
  416. csr, err := x509.ParseCertificateRequest(cr)
  417. assert.FatalError(t, err)
  418. cert, err := a.SignWithContext(context.Background(), csr, provisioner.SignOptions{})
  419. assert.FatalError(t, err)
  420. assert.Equals(t, []string{"foo.bar.zar"}, cert[0].DNSNames)
  421. assert.Equals(t, crt, cert[1])
  422. }
  423. func TestNewEmbedded_GetTLSCertificate(t *testing.T) {
  424. caPEM, err := os.ReadFile("testdata/certs/root_ca.crt")
  425. assert.FatalError(t, err)
  426. crt, err := pemutil.ReadCertificate("testdata/certs/intermediate_ca.crt")
  427. assert.FatalError(t, err)
  428. key, err := pemutil.Read("testdata/secrets/intermediate_ca_key", pemutil.WithPassword([]byte("pass")))
  429. assert.FatalError(t, err)
  430. a, err := NewEmbedded(WithX509RootBundle(caPEM), WithX509Signer(crt, key.(crypto.Signer)))
  431. assert.FatalError(t, err)
  432. // GetTLSCertificate
  433. cert, err := a.GetTLSCertificate()
  434. assert.FatalError(t, err)
  435. assert.Equals(t, []string{"localhost"}, cert.Leaf.DNSNames)
  436. assert.True(t, cert.Leaf.IPAddresses[0].Equal(net.ParseIP("127.0.0.1")))
  437. assert.True(t, cert.Leaf.IPAddresses[1].Equal(net.ParseIP("::1")))
  438. }
  439. func TestAuthority_CloseForReload(t *testing.T) {
  440. tests := []struct {
  441. name string
  442. auth *Authority
  443. }{
  444. {"ok", testAuthority(t)},
  445. }
  446. for _, tt := range tests {
  447. t.Run(tt.name, func(t *testing.T) {
  448. tt.auth.CloseForReload()
  449. })
  450. }
  451. }
  452. func testScepAuthority(t *testing.T, opts ...Option) *Authority {
  453. p := provisioner.List{
  454. &provisioner.SCEP{
  455. Name: "scep1",
  456. Type: "SCEP",
  457. },
  458. }
  459. c := &Config{
  460. Address: "127.0.0.1:8443",
  461. InsecureAddress: "127.0.0.1:8080",
  462. Root: []string{"testdata/scep/root.crt"},
  463. IntermediateCert: "testdata/scep/intermediate.crt",
  464. IntermediateKey: "testdata/scep/intermediate.key",
  465. DNSNames: []string{"example.com"},
  466. Password: "pass",
  467. AuthorityConfig: &AuthConfig{
  468. Provisioners: p,
  469. },
  470. }
  471. a, err := New(c, opts...)
  472. assert.FatalError(t, err)
  473. return a
  474. }
  475. func TestAuthority_GetSCEP(t *testing.T) {
  476. _ = testScepAuthority(t)
  477. p := provisioner.List{
  478. &provisioner.SCEP{
  479. Name: "scep1",
  480. Type: "SCEP",
  481. },
  482. }
  483. type fields struct {
  484. config *Config
  485. }
  486. tests := []struct {
  487. name string
  488. fields fields
  489. wantService bool
  490. wantErr bool
  491. }{
  492. {
  493. name: "ok",
  494. fields: fields{
  495. config: &Config{
  496. Address: "127.0.0.1:8443",
  497. InsecureAddress: "127.0.0.1:8080",
  498. Root: []string{"testdata/scep/root.crt"},
  499. IntermediateCert: "testdata/scep/intermediate.crt",
  500. IntermediateKey: "testdata/scep/intermediate.key",
  501. DNSNames: []string{"example.com"},
  502. Password: "pass",
  503. AuthorityConfig: &AuthConfig{
  504. Provisioners: p,
  505. },
  506. },
  507. },
  508. wantService: true,
  509. wantErr: false,
  510. },
  511. {
  512. name: "wrong password",
  513. fields: fields{
  514. config: &Config{
  515. Address: "127.0.0.1:8443",
  516. InsecureAddress: "127.0.0.1:8080",
  517. Root: []string{"testdata/scep/root.crt"},
  518. IntermediateCert: "testdata/scep/intermediate.crt",
  519. IntermediateKey: "testdata/scep/intermediate.key",
  520. DNSNames: []string{"example.com"},
  521. Password: "wrongpass",
  522. AuthorityConfig: &AuthConfig{
  523. Provisioners: p,
  524. },
  525. },
  526. },
  527. wantService: false,
  528. wantErr: true,
  529. },
  530. }
  531. for _, tt := range tests {
  532. t.Run(tt.name, func(t *testing.T) {
  533. a, err := New(tt.fields.config)
  534. if (err != nil) != tt.wantErr {
  535. t.Errorf("Authority.New(), error = %v, wantErr %v", err, tt.wantErr)
  536. return
  537. }
  538. if tt.wantService {
  539. if got := a.GetSCEP(); (got != nil) != tt.wantService {
  540. t.Errorf("Authority.GetSCEPService() = %v, wantService %v", got, tt.wantService)
  541. }
  542. }
  543. })
  544. }
  545. }
  546. func TestAuthority_GetID(t *testing.T) {
  547. type fields struct {
  548. authorityID string
  549. }
  550. tests := []struct {
  551. name string
  552. fields fields
  553. want string
  554. }{
  555. {"ok", fields{""}, "00000000-0000-0000-0000-000000000000"},
  556. {"ok with id", fields{"10b9a431-ed3b-4a5f-abee-ec35119b65e7"}, "10b9a431-ed3b-4a5f-abee-ec35119b65e7"},
  557. }
  558. for _, tt := range tests {
  559. t.Run(tt.name, func(t *testing.T) {
  560. a := &Authority{
  561. config: &config.Config{
  562. AuthorityConfig: &config.AuthConfig{
  563. AuthorityID: tt.fields.authorityID,
  564. },
  565. },
  566. }
  567. if got := a.GetID(); got != tt.want {
  568. t.Errorf("Authority.GetID() = %v, want %v", got, tt.want)
  569. }
  570. })
  571. }
  572. }