-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Instagram verification #19
Open
anthonygraignic
wants to merge
10
commits into
ceramicstudio:main
Choose a base branch
from
anthonygraignic:master
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9bd2b30
[WIP] Instagram verification
anthonygraignic b613207
Add hex lib to generateKeyPair in utils/scripts
anthonygraignic 2763c88
Update verify method to POST
anthonygraignic 3a6cf0f
Add documentation about Instagram verification
anthonygraignic bd1a349
Add HTTP redirection for request-insstagram
anthonygraignic e74ce63
Fix test for instagram verification
anthonygraignic 9e1f948
Minor fixes
anthonygraignic 29ca6d5
Skip test in api_handler for request_instagram (HTTP GET)
anthonygraignic ebc2888
Merge remote-tracking branch 'upstream/master'
anthonygraignic de018cc
Fix request instagram test & add useful commands in package.json
anthonygraignic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
94 changes: 94 additions & 0 deletions
94
packages/server/src/api/__tests__/instagram-request.test.js
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,94 @@ | ||
const InstagramRequestHandler = require('../instagram-request') | ||
|
||
describe('InstagramRequestHandler', () => { | ||
let sut | ||
let instagramMgrMock = { | ||
generateRedirectionUrl: jest.fn(), | ||
saveRequest: jest.fn() | ||
} | ||
let claimMgrMock = { issue: jest.fn() } | ||
let analyticsMock = { trackRequestInstagram: jest.fn() } | ||
|
||
beforeAll(() => { | ||
sut = new InstagramRequestHandler( | ||
instagramMgrMock, | ||
claimMgrMock, | ||
analyticsMock | ||
) | ||
}) | ||
|
||
test('empty constructor', () => { | ||
expect(sut).not.toBeUndefined() | ||
}) | ||
|
||
test('no did nor username', done => { | ||
sut.handle({}, {}, (err, res) => { | ||
expect(err).not.toBeNull() | ||
expect(err.code).toEqual(400) | ||
expect(err.message).toEqual('no did nor username') | ||
done() | ||
}) | ||
}) | ||
|
||
test('no did', done => { | ||
sut.handle( | ||
{ queryStringParameters: { username: 'anthony' } }, | ||
{}, | ||
(err, res) => { | ||
expect(err).not.toBeNull() | ||
expect(err.code).toEqual(403) | ||
expect(err.message).toEqual('no did') | ||
done() | ||
} | ||
) | ||
}) | ||
|
||
test('no username', done => { | ||
sut.handle( | ||
{ | ||
queryStringParameters: { did: 'did:123' } | ||
}, | ||
{}, | ||
(err, res) => { | ||
expect(err).not.toBeNull() | ||
expect(err.code).toEqual(400) | ||
expect(err.message).toEqual('no username') | ||
done() | ||
} | ||
) | ||
}) | ||
|
||
test('happy path', done => { | ||
instagramMgrMock.generateRedirectionUrl.mockReturnValue( | ||
'http://some.valid.url' | ||
) | ||
sut.handle( | ||
{ | ||
queryStringParameters: { username: 'wallkanda', did: 'did:123' } | ||
}, | ||
{}, | ||
(_err, res) => { | ||
expect(res).not.toBeNull() | ||
// console.log(res) | ||
expect(res.statusCode).toEqual(307) | ||
expect(res.headers.Location).not.toBeNull() | ||
done() | ||
} | ||
) | ||
}) | ||
|
||
// test('happy path with HTTP redirect', done => { | ||
// sut.handle( | ||
// { | ||
// queryStringParameters: { username: 'wallkanda', did: 'did:123' } | ||
// }, | ||
// {}, | ||
// (_err, res) => { | ||
// expect(res).not.toBeNull() | ||
// expect(res.status).toEqual(307) | ||
// expect(res.headers.get('Location')).not.toBeNull() | ||
// done() | ||
// } | ||
// ) | ||
// }) | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess discourse should be here as well 😅