- for (let i = 0; i < 14; i++) {
- await userLogin(server, user, 400)
+ for (let i = 0; i < 19; i++) {
+ await server.login.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ }
+
+ await server.login.login({ user, expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
+ })
+
+ it('Should rate limit signup', async function () {
+ for (let i = 0; i < 10; i++) {
+ try {
+ await server.users.register({ username: 'test' + i })
+ } catch {
+ // empty
+ }
+ }
+
+ await server.users.register({ username: 'test42', expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
+ })
+
+ it('Should not rate limit failed signup', async function () {
+ this.timeout(30000)
+
+ await wait(7000)
+
+ for (let i = 0; i < 3; i++) {
+ await server.users.register({ username: 'test' + i, expectedStatus: HttpStatusCode.CONFLICT_409 })
+ }
+
+ await server.users.register({ username: 'test43', expectedStatus: HttpStatusCode.NO_CONTENT_204 })
+
+ })
+
+ it('Should rate limit API calls', async function () {
+ this.timeout(30000)
+
+ await wait(7000)
+
+ for (let i = 0; i < 100; i++) {
+ try {
+ await server.videos.get({ id: videoId })
+ } catch {
+ // don't care if it fails
+ }