Skip to content

Commit

Permalink
Missing rfc021 e2e tests changes (#2623)
Browse files Browse the repository at this point in the history
  • Loading branch information
woutslakhorst authored Nov 29, 2023
1 parent c0ec338 commit 8e828c5
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 21 deletions.
6 changes: 3 additions & 3 deletions auth/services/oauth/relying_party.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ func (s *relyingParty) RequestRFC021AccessToken(ctx context.Context, requester d
func determineFormat(formats map[string]map[string][]string) (string, error) {
for format := range formats {
switch format {
case openid4vc.VerifiablePresentationJWTFormat:
return format, nil
case openid4vc.VerifiablePresentationJSONLDFormat:
return format, nil
case openid4vc.VerifiablePresentationJWTFormat:
fallthrough
case "jwt_vp_json":
return openid4vc.VerifiablePresentationJSONLDFormat, nil
return openid4vc.VerifiablePresentationJWTFormat, nil
default:
continue
}
Expand Down
35 changes: 35 additions & 0 deletions auth/services/oauth/relying_party_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,41 @@ func TestRelyingParty_RequestRFC021AccessToken(t *testing.T) {
})
}

func Test_determineFormat(t *testing.T) {
t.Run("ok", func(t *testing.T) {
formats := map[string]map[string][]string{
"jwt_vp": {
"alg": {"ES256K"},
},
}

format, err := determineFormat(formats)

assert.NoError(t, err)
assert.Equal(t, "jwt_vp", format)
})
t.Run("error - no supported format", func(t *testing.T) {
formats := map[string]map[string][]string{}

format, err := determineFormat(formats)

assert.EqualError(t, err, "authorization server metadata does not contain any supported VP formats")
assert.Empty(t, format)
})
t.Run(" jwt_vp_json returns jwt_vp", func(t *testing.T) {
formats := map[string]map[string][]string{
"jwt_vp_json": {
"alg": {"ES256K"},
},
}

format, err := determineFormat(formats)

assert.NoError(t, err)
assert.Equal(t, "jwt_vp", format)
})
}

func TestService_CreateJwtBearerToken(t *testing.T) {
usi := vc.VerifiablePresentation{}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,5 @@ http {
proxy_set_header X-Ssl-Client-Cert $ssl_client_escaped_cert;
proxy_pass http://nodeA-backend;
}

location /ping {
auth_request /delegated;
auth_request_set $auth_status $upstream_status;
}

location = /delegated {
internal;
proxy_pass http://nodeA-backend/internal/auth/v1/accesstoken/verify;
proxy_method HEAD;
proxy_pass_request_body off;
proxy_set_header X-Ssl-Client-Cert $ssl_client_escaped_cert;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ else
fi

echo "---------------------------------------"
echo "Perform OAuth 2.0 OpenID4VP-s2s flow..."
echo "Perform OAuth 2.0 rfc021 flow..."
echo "---------------------------------------"
# Request access token
# Create DID for A with :nuts: replaced with :web:
Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/oauth-flow/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ pushd rfc002
popd

echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "!! Running test: OAuth flow (OpenID4VP-s2s) !!"
echo "!! Running test: OAuth flow (rfc021) !!"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
pushd openid4vp
pushd rfc021
./run-test.sh
popd

0 comments on commit 8e828c5

Please sign in to comment.