-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1121 from Giveth/f_3021_update_totalReceived_of_p…
…roject_owners_correctly Update totalReceived of project owners correctly after verifying donations
- Loading branch information
Showing
3 changed files
with
26 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ import { assert } from 'chai'; | |
import { | ||
generateRandomEtheriumAddress, | ||
generateTestAccessToken, | ||
saveUserDirectlyToDb, | ||
} from '../../test/testUtils'; | ||
import { User } from '../entities/user'; | ||
import Axios from 'axios'; | ||
|
@@ -20,31 +21,16 @@ const origin = 'https://serve.giveth.io'; | |
|
||
function authorizationHandlerTestCases() { | ||
it('should decode user jwt with current impact graph authorization', async () => { | ||
const userData = { | ||
firstName: 'firstName', | ||
lastName: 'lastName', | ||
email: `${new Date().getTime()}[email protected]`, | ||
url: 'website url', | ||
loginType: 'wallet', | ||
walletAddress: generateRandomEtheriumAddress(), | ||
}; | ||
const user = await User.create(userData).save(); | ||
const user = await saveUserDirectlyToDb(generateRandomEtheriumAddress()); | ||
const accessToken = await generateTestAccessToken(user.id); | ||
const jwtUser = await authorizationHandler('1', accessToken); | ||
assert.equal(jwtUser.userId, user.id); | ||
}); | ||
it('should decode user jwt with the auth microservice', async () => { | ||
const privateKey = process.env.PRIVATE_ETHERS_TEST_KEY as string; | ||
const publicKey = process.env.PUBLIC_ETHERS_TEST_KEY as string; | ||
const userData = { | ||
firstName: 'firstName', | ||
lastName: 'lastName', | ||
email: `${new Date().getTime()}[email protected]`, | ||
url: 'website url', | ||
loginType: 'wallet', | ||
walletAddress: publicKey, | ||
}; | ||
const user = await User.create(userData).save(); | ||
|
||
const user = await saveUserDirectlyToDb(publicKey); | ||
const nonceRoute = config.get('AUTH_MICROSERVICE_NONCE_URL') as string; | ||
const nonceResult = await Axios.get(nonceRoute); | ||
const wallet = new ethers.Wallet(privateKey); | ||
|
@@ -73,6 +59,7 @@ function authorizationHandlerTestCases() { | |
const accessToken = authenticationResult.data.jwt; | ||
const jwtUser = await authorizationHandler('2', accessToken); | ||
assert.equal(jwtUser.userId, user.id); | ||
await User.delete(user.id); | ||
}); | ||
it('should decode jwt and create user if it is nonexistent', async () => { | ||
const privateKey = process.env.PRIVATE_ETHERS_SECONDARY_TEST_KEY as string; | ||
|
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