Skip to content

Commit

Permalink
fix: tos uri tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alnr committed Feb 20, 2025
1 parent fc80a5b commit 2713ccf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions client/sdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func createTestClient(prefix string) hydra.OAuth2Client {
Owner: pointerx.Ptr(prefix + "an-owner"),
PolicyUri: pointerx.Ptr(prefix + "policy-uri"),
Scope: pointerx.Ptr(prefix + "foo bar baz"),
TosUri: pointerx.Ptr(prefix + "tos-uri"),
TosUri: pointerx.Ptr("https://example.org/" + prefix + "tos"),
ResponseTypes: []string{prefix + "id_token", prefix + "code"},
RedirectUris: []string{"https://" + prefix + "redirect-url", "https://" + prefix + "redirect-uri"},
ClientSecretExpiresAt: pointerx.Ptr[int64](0),
Expand Down Expand Up @@ -95,12 +95,15 @@ func TestClientSDK(t *testing.T) {
// createClient.SecretExpiresAt = 10

// returned client is correct on Create
result, _, err := c.OAuth2API.CreateOAuth2Client(ctx).OAuth2Client(createClient).Execute()
require.NoError(t, err)
result, res, err := c.OAuth2API.CreateOAuth2Client(ctx).OAuth2Client(createClient).Execute()
if !assert.NoError(t, err) {
t.Fatalf("error: %s", ioutilx.MustReadAll(res.Body))
}
assert.NotEmpty(t, result.UpdatedAt)
assert.NotEmpty(t, result.CreatedAt)
assert.NotEmpty(t, result.RegistrationAccessToken)
assert.NotEmpty(t, result.RegistrationClientUri)
assert.NotEmpty(t, *result.TosUri)
assert.NotEmpty(t, result.ClientId)
createClient.ClientId = result.ClientId

Expand Down
4 changes: 4 additions & 0 deletions client/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ func TestValidate(t *testing.T) {
assert.Equal(t, []string{"https://foo/"}, []string(c.PostLogoutRedirectURIs))
},
},
{
in: &Client{ID: "foo", TermsOfServiceURI: "https://example.org"},
assertErr: assert.NoError,
},
{
in: &Client{ID: "foo", TermsOfServiceURI: "javascript:alert('XSS')"},
assertErr: assert.Error,
Expand Down

0 comments on commit 2713ccf

Please sign in to comment.