-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle email verification for pods without notification support (#8)
When notification subscription fails, we verify the email, but we inform user that email notifications won't arrive
- Loading branch information
Showing
4 changed files
with
158 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^6.0.0/components/context.jsonld", | ||
"import": [ | ||
"css:config/app/main/default.json", | ||
"css:config/app/init/initialize-prefilled-root.json", | ||
"css:config/app/setup/optional.json", | ||
"css:config/app/variables/default.json", | ||
"css:config/http/handler/default.json", | ||
"css:config/http/middleware/default.json", | ||
"css:config/http/notifications/disabled.json", | ||
"css:config/http/server-factory/http.json", | ||
"css:config/http/static/default.json", | ||
"css:config/identity/access/public.json", | ||
"css:config/identity/email/default.json", | ||
"css:config/identity/handler/default.json", | ||
"css:config/identity/ownership/token.json", | ||
"css:config/identity/pod/static.json", | ||
"css:config/identity/registration/enabled.json", | ||
"css:config/ldp/authentication/dpop-bearer.json", | ||
"css:config/ldp/authorization/webacl.json", | ||
"css:config/ldp/handler/default.json", | ||
"css:config/ldp/metadata-parser/default.json", | ||
"css:config/ldp/metadata-writer/default.json", | ||
"css:config/ldp/modes/default.json", | ||
"css:config/storage/backend/memory.json", | ||
"css:config/storage/key-value/resource-store.json", | ||
"css:config/storage/middleware/default.json", | ||
"css:config/util/auxiliary/acl.json", | ||
"css:config/util/identifiers/suffix.json", | ||
"css:config/util/index/default.json", | ||
"css:config/util/logging/winston.json", | ||
"css:config/util/representation-conversion/default.json", | ||
"css:config/util/resource-locker/memory.json", | ||
"css:config/util/variables/default.json" | ||
], | ||
"@graph": [ | ||
{ | ||
"comment": "A Solid server that stores its resources in memory and uses WAC for authorization." | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,12 @@ import Mail from 'nodemailer/lib/mailer' | |
import { SinonSandbox, SinonSpy, createSandbox } from 'sinon' | ||
import { baseUrl } from '../config' | ||
import * as mailerService from '../services/mailerService' | ||
import { authenticatedFetch, person } from './testSetup.spec' | ||
import { | ||
authenticatedFetch, | ||
authenticatedFetchNoNotifications, | ||
person, | ||
personNoNotifications, | ||
} from './testSetup.spec' | ||
|
||
describe('email verification via /verify-email?id=webId&token=base64Token', () => { | ||
let sendMailSpy: SinonSpy<[options: Mail.Options], Promise<void>> | ||
|
@@ -85,4 +90,39 @@ describe('email verification via /verify-email?id=webId&token=base64Token', () = | |
}) | ||
|
||
it('when we send out multiple verification emails, the last link should work') | ||
|
||
context("server doesn't support webhook notifications", () => { | ||
beforeEach(async () => { | ||
// initialize the integration | ||
const initResponse = await authenticatedFetchNoNotifications( | ||
`${baseUrl}/inbox`, | ||
{ | ||
method: 'post', | ||
headers: { | ||
'content-type': | ||
'application/ld+json;profile="https://www.w3.org/ns/activitystreams"', | ||
}, | ||
body: JSON.stringify({ | ||
'@context': 'https://www.w3.org/ns/activitystreams', | ||
'@id': '', | ||
'@type': 'Add', | ||
actor: personNoNotifications.webId, | ||
object: personNoNotifications.podUrl + 'profile/card', | ||
target: '[email protected]', | ||
}), | ||
}, | ||
) | ||
|
||
expect(initResponse.status).to.equal(200) | ||
// email was sent | ||
const emailMessage = sendMailSpy.secondCall.firstArg.html | ||
const $ = cheerio.load(emailMessage) | ||
verificationLink = $('a').first().attr('href') as string | ||
expect(verificationLink).to.not.be.null | ||
}) | ||
it("should verify email, but inform user that notifications aren't supported", async () => { | ||
const response = await fetch(verificationLink) | ||
expect(response.status).to.equal(200) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters