-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
311 additions
and
143 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
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,36 @@ | ||
import { createCognitoClient } from "../src/services/cognitoClient"; | ||
import { CreateDataStore, createDataStore } from "../src/services/dataStore"; | ||
import { createUserPoolClient } from "../src/services/userPoolClient"; | ||
import fs from "fs"; | ||
import { promisify } from "util"; | ||
|
||
const mkdtemp = promisify(fs.mkdtemp); | ||
const rmdir = promisify(fs.rmdir); | ||
|
||
describe("Cognito Client", () => { | ||
let path: string; | ||
let tmpCreateDataStore: CreateDataStore; | ||
beforeEach(async () => { | ||
path = await mkdtemp("/tmp/cognito-local:"); | ||
tmpCreateDataStore = (id, defaults) => createDataStore(id, defaults, path); | ||
}); | ||
|
||
afterEach(() => | ||
rmdir(path, { | ||
recursive: true, | ||
}) | ||
); | ||
|
||
it("creates a clients database", async () => { | ||
await createCognitoClient( | ||
{ | ||
Id: "local", | ||
UsernameAttributes: [], | ||
}, | ||
tmpCreateDataStore, | ||
createUserPoolClient | ||
); | ||
|
||
expect(fs.existsSync(`${path}/clients.json`)).toBe(true); | ||
}); | ||
}); |
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,15 @@ | ||
import shortUUID from "short-uuid"; | ||
|
||
export interface AppClient { | ||
UserPoolId: string; | ||
ClientName: string; | ||
ClientId: string; | ||
LastModifiedDate: number; | ||
CreationDate: number; | ||
RefreshTokenValidity: number; | ||
AllowedOAuthFlowsUserPoolClient: boolean; | ||
} | ||
|
||
const generator = shortUUID("0123456789abcdefghijklmnopqrstuvwxyz"); | ||
|
||
export const newId = generator.new; |
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
Oops, something went wrong.