1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-11-01 19:07:38 +01:00
unleash.unleash/src/test/fixtures/fake-public-signup-store.ts
andreas-unleash 6778d347cd
PublicSignupTokens (#2053)
* PublicSignupTokens

* bug fix

* bug fixes and test

* bug fixes and test

* bug fixes and test

* Add feature flag

* tests

* tests

* Update 20220908093515-add-public-signup-tokens.js

Bug Fix

* task: use swc instead of ts-jest (#2042)

* Add a counter for total number of environments (#1964)

* add groupId to gradual rollout template (#2045)

* add groupId to gradual rollout template

* FMT

* Improve tabs UI on smaller devices (#2014)

* Improve tabs UI on smaller devices

* Improve tabs UI on smaller devices

* bug fix

* add proper scrollable tabs

* removed centered from Tabs (conflicts with scrollable)

* PR comments

* 4.15.0-beta.10

* Fix broken doc links (#2046)

## What

This PR fixes some broken links that have been hanging around in the
docs for what seems like a very long time.

## Why

As discovered by the link check in #1912, there are a fair few broken
links in the docs. Everyone hates broken links because it makes it
harder to understand what they were supposed to be pointing at.

## How

There are 3 types of links that have been fixed:
- Links that should have been internal but were absolute. E.g.
  `https://docs.getunleash.io/path/article` that should have been
  `./article.md`
- External links that have changed, such as Slack's API description
- GitHub links to files that either no longer exist or that have been
  moved. These links generally pointed to `master`/`main`, meaning
  they are subject to change. They have been replaced with permalinks
  pointing to specific commits.

-----

* docs: fix slack api doc link

* docs: update links in migration guide

* docs: fix broken link to ancient feature schema validation

* docs: update links to v3 auth hooks

* docs: update broken link in the go sdk article

* Fix: use permalink for GitHub link

* docs: fix wrong google auth link

* 4.15.0

* 4.15.1

* docs: update link for symfony sdk (#2048)



The doc link appears to have pointed at an address that is no longer reachable. Instead, let's point to the equivalent GitHub link

Relates to and closes #2047

* docs: test broken links in website (#1912)

The action triggers manually as a first step to test this functionality. In the near future, we might schedule it

* Schedule link checker action (#2050)

Runs at 12:30 UTC on Mon, Tue, Wed, Thu and Fri

* fix: add env and project labels to feature updated metrics. (#2043)

* Revert workflow (#2051)

* update snapshot

* PR comments

* Added Events and tests

* Throw error if token not found

Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
Co-authored-by: Gastón Fournier <gaston@getunleash.ai>
Co-authored-by: Ivar Conradi Østhus <ivarconr@gmail.com>
Co-authored-by: sjaanus <sellinjaanus@gmail.com>
2022-09-14 15:29:12 +03:00

86 lines
2.7 KiB
TypeScript

import { IPublicSignupTokenStore } from '../../lib/types/stores/public-signup-token-store';
import { PublicSignupTokenSchema } from '../../lib/openapi/spec/public-signup-token-schema';
import { IPublicSignupTokenCreate } from '../../lib/types/models/public-signup-token';
export default class FakePublicSignupStore implements IPublicSignupTokenStore {
tokens: PublicSignupTokenSchema[] = [];
async addTokenUser(secret: string, userId: number): Promise<void> {
this.get(secret).then((token) => token.users.push({ id: userId }));
return Promise.resolve();
}
async get(secret: string): Promise<PublicSignupTokenSchema> {
const token = this.tokens.find((t) => t.secret === secret);
return Promise.resolve(token);
}
async isValid(secret: string): Promise<boolean> {
const token = this.tokens.find((t) => t.secret === secret);
return Promise.resolve(token && new Date(token.expiresAt) > new Date());
}
async count(): Promise<number> {
return Promise.resolve(0);
}
// eslint-disable-next-line no-unused-vars,@typescript-eslint/no-unused-vars
async delete(secret: string): Promise<void> {
return Promise.resolve(undefined);
}
async getAllActive(): Promise<PublicSignupTokenSchema[]> {
return Promise.resolve(this.tokens);
}
async create(
newToken: IPublicSignupTokenCreate,
): Promise<PublicSignupTokenSchema> {
return this.insert(newToken);
}
async insert(
newToken: IPublicSignupTokenCreate,
): Promise<PublicSignupTokenSchema> {
const token = {
secret: 'some-secret',
expiresAt: newToken.expiresAt.toISOString(),
createdAt: new Date().toISOString(),
users: [],
name: newToken.name,
role: {
name: 'Viewer',
type: '',
id: 1,
},
createdBy: null,
};
this.tokens.push(token);
return Promise.resolve(token);
}
async setExpiry(
secret: string,
expiresAt: Date,
): Promise<PublicSignupTokenSchema> {
const token = await this.get(secret);
token.expiresAt = expiresAt.toISOString();
return Promise.resolve(token);
}
async deleteAll(): Promise<void> {
return Promise.resolve(undefined);
}
destroy(): void {}
async exists(key: string): Promise<boolean> {
return this.tokens.some((t) => t.secret === key);
}
// eslint-disable-next-line no-unused-vars,@typescript-eslint/no-unused-vars
async getAll(query?: Object): Promise<PublicSignupTokenSchema[]> {
return Promise.resolve([]);
}
}