-
Notifications
You must be signed in to change notification settings - Fork 12
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
Experiment/create ephemeral UI test accts #1898
Open
andrewleith
wants to merge
46
commits into
main
Choose a base branch
from
experiment/create-ephemeral-ui-test-accts
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 6 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
225d696
fix: simplify email address names to avoid issues with IMAP
andrewleith c3eb799
fix: modify Login method to accept email alias to check for when conn…
andrewleith be37e0b
fix: new accounts go to /services page since they only belong to one …
andrewleith 7971d88
feat: new plugin to generate a random email alias, then call an endpo…
andrewleith 2f4ade7
fix: update cypress config to expose the create-account plugin, and s…
andrewleith 7dc450d
feat: update the login command to get the ephemeral email account bef…
andrewleith 706be29
feat(create-account): update create account task and pass notify test…
andrewleith d7e7f81
fix(tou_test): success can either be the /accounts page or a /service…
andrewleith db9a550
chore(email-account): refactor and clean up code a bit; ensure connec…
andrewleith fb5bd26
feat(config): simplify config
andrewleith 1d3bd62
fix up ids
andrewleith f199ad4
chore(refactor): refactor login command; add login command for platfo…
andrewleith c987242
task(cypress config): add back SMS template ID
andrewleith ac9019a
fix(tou_prompt test): add assertion to ensure success of agreeing to …
andrewleith b79f8a0
fix(create-account): simplify call to api; remove posting of the pass…
andrewleith 77c143a
chore(email-account): remove debug logging
andrewleith 624da0b
Merge branch 'main' into experiment/create-ephemeral-ui-test-accts
andrewleith 36bfe45
fix: add template category to the test that will be empty for email
andrewleith 213e7e4
fix(create-account): remove pw prop
andrewleith 862a203
Merge branch 'main' into experiment/create-ephemeral-ui-test-accts
andrewleith 689222b
chore: remove debug log
andrewleith b3082b5
fix: dont try to delete emails when there is none
andrewleith 8e06612
fix: update calls to login across tests
andrewleith 9a7d00d
chore: update test and get values from config
andrewleith e871344
Merge branch 'main' into experiment/create-ephemeral-ui-test-accts
andrewleith 6978d52
chore: add README, extra npm script
andrewleith 9c64b3b
chore: formatting
andrewleith b45c710
Merge branch 'main' into experiment/create-ephemeral-ui-test-accts
andrewleith 63a1b92
fix(cypress): update tests to use updated, simplified `cy.login()` co…
andrewleith d3f2d37
chore: formatting
andrewleith becd2ab
chore: update config to use staging
andrewleith 7388a22
Merge branch 'main' into experiment/create-ephemeral-ui-test-accts
andrewleith bbe2bdb
fix(remaining_messages_summary test): add assert to ensure test waits…
andrewleith c314ea8
chore: remove debug code
andrewleith 0183f84
fix(template_filters test): make sure the scenario ends in no results
andrewleith 213c122
fix(cypress login): use cypress auth to get new user
andrewleith b2e0597
Merge branch 'experiment/create-ephemeral-ui-test-accts' of https://g…
andrewleith 47a192b
fix failing tests
andrewleith 17a806d
Merge branch 'experiment/create-ephemeral-ui-test-accts' of https://g…
andrewleith 1548f49
fix(cypress config): add back retries
andrewleith 5f53f67
please [review] me
andrewleith 2cec1b1
Merge branch 'experiment/create-ephemeral-ui-test-accts' of https://g…
andrewleith 62a2536
fix: change secret name for new user password so this wont conflict w…
andrewleith c10d268
chore: README updates
andrewleith 413a870
chore: remove unused import
andrewleith 5aaa300
chore: removed comments
andrewleith 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
const http = require('http'); | ||
const https = require('https'); | ||
|
||
// TODO: This duplicates some code in Notify/NotifyAPI.js and should be consolidated | ||
const Utilities = { | ||
CreateJWT: (username, secret) => { | ||
const jwt = require('jsrsasign'); | ||
const claims = { | ||
'iss': username, | ||
'iat': Math.round(Date.now() / 1000) | ||
} | ||
|
||
const headers = { alg: "HS256", typ: "JWT" }; | ||
return jwt.jws.JWS.sign("HS256", JSON.stringify(headers), JSON.stringify(claims), secret); | ||
}, | ||
GenerateID: (length = 10) => { | ||
const characters = '0123456789abcdefghijklmnopqrstuvwxyz'; | ||
let result = ''; | ||
const charactersLength = characters.length; | ||
for (let i = 0; i < length; i++) { | ||
result += characters.charAt(Math.floor(Math.random() * charactersLength)); | ||
} | ||
return result; | ||
} | ||
}; | ||
|
||
const createAccount = async (baseUrl, username, secret) => { | ||
// return a generated id | ||
const token = Utilities.CreateJWT(username, secret); | ||
const generatedUsername = Utilities.GenerateID(10); | ||
const url = `${baseUrl}/cypress/create_user/${generatedUsername}`; | ||
console.log('generatedUsername', generatedUsername); | ||
|
||
return new Promise((resolve, reject) => { | ||
const options = { | ||
method: 'GET', // or 'POST', depending on your API | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
"Content-Type": 'application/json' | ||
} | ||
}; | ||
|
||
const getHttpModule = (url) => url.startsWith('https://') ? https : http; | ||
|
||
const req = getHttpModule(url).request(url, options, (res) => { | ||
let data = ''; | ||
|
||
res.on('data', (chunk) => { | ||
data += chunk; | ||
}); | ||
|
||
res.on('end', () => { | ||
try { | ||
const parsedData = JSON.parse(data); | ||
resolve(parsedData); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
}); | ||
}); | ||
|
||
req.on('error', (error) => { | ||
reject(error); // Reject the promise on request error | ||
}); | ||
|
||
req.end(); | ||
}); | ||
|
||
}; | ||
|
||
|
||
module.exports = createAccount; |
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
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.
The result of this call is "cached" in the
global
object here, which means only one set of test users is generated for every test run or every time you launch the cypress UI. To get a new user, just quit cypress and launch it again.