mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-04 13:44:24 +00:00
e28e79a648
Co-authored-by: techknowlogick <164197+techknowlogick@users.noreply.github.com>
35 lines
927 B
Go
35 lines
927 B
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.dev/modules/setting"
|
|
"gitea.dev/modules/test"
|
|
|
|
"github.com/mholt/acmez/v3/acme"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestAcmeExternalAccountBinding(t *testing.T) {
|
|
t.Cleanup(test.MockVariableValue(&setting.AcmeEABKID, ""))
|
|
t.Cleanup(test.MockVariableValue(&setting.AcmeEABHMAC, ""))
|
|
|
|
binding, configured, err := acmeExternalAccountBinding()
|
|
assert.NoError(t, err)
|
|
assert.False(t, configured)
|
|
assert.Empty(t, binding)
|
|
|
|
setting.AcmeEABKID = "kid"
|
|
_, _, err = acmeExternalAccountBinding()
|
|
assert.ErrorContains(t, err, "both ACME_EAB_KID and ACME_EAB_HMAC must be set")
|
|
|
|
setting.AcmeEABHMAC = "hmac"
|
|
binding, configured, err = acmeExternalAccountBinding()
|
|
assert.NoError(t, err)
|
|
assert.True(t, configured)
|
|
assert.Equal(t, acme.EAB{KeyID: "kid", MACKey: "hmac"}, binding)
|
|
}
|