Skip to content

Commit

Permalink
e2etests
Browse files Browse the repository at this point in the history
  • Loading branch information
woutslakhorst committed Sep 24, 2024
1 parent 64861c2 commit 8555a24
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func Test_UserAccessToken_EmployeeCredential(t *testing.T) {
func setupNode(t testing.TB, ctx context.Context, config core.ClientConfig) (string, did.DID, OpenID4VP) {
subject, didDoc, err := createDID(config)
require.NoError(t, err)
err = browser.IssueOrganizationCredential(didDoc, fmt.Sprintf("%s Organization", didDoc.ID.String()), "Testland", config)
err = browser.IssueOrganizationCredential(subject, didDoc, fmt.Sprintf("%s Organization", didDoc.ID.String()), "Testland", config)
require.NoError(t, err)

iamClientB, err := iamAPI.NewClient(config.GetAddress())
Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/browser/rfc019_selfsigned/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ func Test_LoginWithSelfSignedMeans(t *testing.T) {
require.NoError(t, err)
err = registerCompoundService(verifyingOrganization.ID, purposeOfUse)
require.NoError(t, err)
err = browser.IssueOrganizationCredential(verifyingOrganization, "Verifying Organization", "Testland", apps.NodeClientConfig)
err = browser.IssueOrganizationCredential("", verifyingOrganization, "Verifying Organization", "Testland", apps.NodeClientConfig)
require.NoError(t, err)

issuingOrganization, err := createDID()
require.NoError(t, err)
err = registerCompoundService(issuingOrganization.ID, purposeOfUse)
require.NoError(t, err)
err = browser.IssueOrganizationCredential(issuingOrganization, "Issuing Organization", "Testland", apps.NodeClientConfig)
err = browser.IssueOrganizationCredential("", issuingOrganization, "Issuing Organization", "Testland", apps.NodeClientConfig)
require.NoError(t, err)

selfSigned := apps.SelfSigned{
Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/browser/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
vcrAPI "github.com/nuts-foundation/nuts-node/vcr/api/vcr/v2"
)

func IssueOrganizationCredential(organization *did.Document, name, city string, clientConfig core.ClientConfig) error {
func IssueOrganizationCredential(subject string, organization *did.Document, name, city string, clientConfig core.ClientConfig) error {
vcrClient := vcrAPI.HTTPClient{ClientConfig: clientConfig}
request := vcrAPI.IssueVCRequest{
Issuer: organization.ID.String(),
Expand Down Expand Up @@ -56,7 +56,7 @@ func IssueOrganizationCredential(organization *did.Document, name, city string,
}
if organization.ID.Method == "web" {
// Need to load it into tbe wallet
return vcrClient.LoadVC(organization.ID, *issuedCredential)
return vcrClient.LoadVC(subject, *issuedCredential)
}
return nil
}
2 changes: 1 addition & 1 deletion e2e-tests/discovery/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ else
exitWithDockerLogs 1
fi

RESPONSE=$(echo $RESPONSE | curl --insecure -s -X POST --data-binary @- http://localhost:28081/internal/vcr/v2/holder/${DID}/vc -H "Content-Type:application/json")
RESPONSE=$(echo $RESPONSE | curl --insecure -s -X POST --data-binary @- http://localhost:28081/internal/vcr/v2/holder/${SUBJECT}/vc -H "Content-Type:application/json")
if [[ $RESPONSE -eq "" ]]; then
echo "VC stored in wallet"
else
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/oauth-flow/openid4vp/do-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ else
exitWithDockerLogs 1
fi

RESPONSE=$(echo $RESPONSE | curl -X POST --data-binary @- http://localhost:28081/internal/vcr/v2/holder/${PARTY_B_DID}/vc -H "Content-Type:application/json")
RESPONSE=$(echo $RESPONSE | curl -X POST --data-binary @- http://localhost:28081/internal/vcr/v2/holder/subjectB/vc -H "Content-Type:application/json")
if echo $RESPONSE == ""; then
echo "VC stored in wallet"
else
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/oauth-flow/rfc021/do-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ else
exitWithDockerLogs 1
fi

RESPONSE=$(echo $RESPONSE | curl -X POST --data-binary @- http://localhost:28081/internal/vcr/v2/holder/${VENDOR_B_DID}/vc -H "Content-Type:application/json")
RESPONSE=$(echo $RESPONSE | curl -X POST --data-binary @- http://localhost:28081/internal/vcr/v2/holder/vendorB/vc -H "Content-Type:application/json")
if echo $RESPONSE == ""; then
echo "VC stored in wallet"
else
Expand Down
5 changes: 2 additions & 3 deletions vcr/api/vcr/v2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/nuts-foundation/go-did/did"
"github.com/nuts-foundation/go-did/vc"
"github.com/nuts-foundation/nuts-node/core"
"io"
Expand Down Expand Up @@ -93,10 +92,10 @@ func (hb HTTPClient) Untrusted(credentialType string) ([]string, error) {
}

// LoadVC loads the given Verifiable Credential into the holder's wallet.
func (hb HTTPClient) LoadVC(holder did.DID, credential vc.VerifiableCredential) error {
func (hb HTTPClient) LoadVC(holderSubjectID string, credential vc.VerifiableCredential) error {
ctx := context.Background()

httpResponse, err := hb.client().LoadVC(ctx, holder.String(), credential)
httpResponse, err := hb.client().LoadVC(ctx, holderSubjectID, credential)
if err != nil {
return err
} else if err := core.TestResponseCode(http.StatusNoContent, httpResponse); err != nil {
Expand Down

0 comments on commit 8555a24

Please sign in to comment.