mirror of
https://github.com/smallstep/certificates.git
synced 2024-10-31 03:20:16 +00:00
Add verification of provisionerName
in test
This commit is contained in:
parent
de45d66cdb
commit
e815864ed8
@ -22,9 +22,10 @@ func Test_challengeValidationController_Validate(t *testing.T) {
|
|||||||
Raw: []byte{1},
|
Raw: []byte{1},
|
||||||
}
|
}
|
||||||
type request struct {
|
type request struct {
|
||||||
Request *webhook.X509CertificateRequest `json:"x509CertificateRequest,omitempty"`
|
ProvisionerName string `json:"provisionerName,omitempty"`
|
||||||
Challenge string `json:"scepChallenge"`
|
Request *webhook.X509CertificateRequest `json:"x509CertificateRequest,omitempty"`
|
||||||
TransactionID string `json:"scepTransactionID"`
|
Challenge string `json:"scepChallenge"`
|
||||||
|
TransactionID string `json:"scepTransactionID"`
|
||||||
}
|
}
|
||||||
type response struct {
|
type response struct {
|
||||||
Allow bool `json:"allow"`
|
Allow bool `json:"allow"`
|
||||||
@ -33,6 +34,7 @@ func Test_challengeValidationController_Validate(t *testing.T) {
|
|||||||
req := &request{}
|
req := &request{}
|
||||||
err := json.NewDecoder(r.Body).Decode(req)
|
err := json.NewDecoder(r.Body).Decode(req)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, "my-scep-provisioner", req.ProvisionerName)
|
||||||
assert.Equal(t, "not-allowed", req.Challenge)
|
assert.Equal(t, "not-allowed", req.Challenge)
|
||||||
assert.Equal(t, "transaction-1", req.TransactionID)
|
assert.Equal(t, "transaction-1", req.TransactionID)
|
||||||
b, err := json.Marshal(response{Allow: false})
|
b, err := json.Marshal(response{Allow: false})
|
||||||
@ -44,6 +46,7 @@ func Test_challengeValidationController_Validate(t *testing.T) {
|
|||||||
req := &request{}
|
req := &request{}
|
||||||
err := json.NewDecoder(r.Body).Decode(req)
|
err := json.NewDecoder(r.Body).Decode(req)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, "my-scep-provisioner", req.ProvisionerName)
|
||||||
assert.Equal(t, "challenge", req.Challenge)
|
assert.Equal(t, "challenge", req.Challenge)
|
||||||
assert.Equal(t, "transaction-1", req.TransactionID)
|
assert.Equal(t, "transaction-1", req.TransactionID)
|
||||||
if assert.NotNil(t, req.Request) {
|
if assert.NotNil(t, req.Request) {
|
||||||
|
Loading…
Reference in New Issue
Block a user