-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: adding apikey+owner auth model to verify that subscriptions wh…
…ere owner is undefined work
- Loading branch information
1 parent
c0d92c7
commit a8d1550
Showing
14 changed files
with
326 additions
and
150 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
client-test-apps/js/api-model-relationship-app/cypress/e2e/auth-modes.cy.ts
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,41 @@ | ||
/// <reference types='cypress' /> | ||
|
||
|
||
const uuid = () => Cypress._.random(0, 1e6) | ||
|
||
const TEST_ID = `${uuid()}`; | ||
const PAGE_ROUTE = 'http://localhost:3000/auth-modes'; | ||
const SUCCESS_MARK = '✅'; | ||
const FAILURE_MARK = '❌'; | ||
const PAGE_TITLE = 'Multiauth Controls'; | ||
|
||
/** | ||
* It's not great practice, but these tests rely on being in-order for now. | ||
*/ | ||
describe('auth-mode interactions', () => { | ||
before(() => { | ||
cy.visit(PAGE_ROUTE) | ||
}); | ||
|
||
describe('page state is stable', () => { | ||
it('loads', () => { | ||
cy.contains(PAGE_TITLE); | ||
}) | ||
|
||
/** | ||
* Non-owner based subscriptions work for models which also have owner-based auth attached. | ||
*/ | ||
it('initializes subscriptions when owner auth is not selected, despite existing on the model', () => { | ||
cy.get('#subscription-state').contains(SUCCESS_MARK); | ||
}) | ||
}); | ||
|
||
describe('simple create model emits an event', () => { | ||
it('creates a record and sees the result in the observable', () => { | ||
cy.get('#MultiAuth-id-input').clear().type(TEST_ID); | ||
cy.get('#MultiAuth-create').click(); | ||
cy.get('#MultiAuth-is-created').within(() => { cy.contains(SUCCESS_MARK) }); | ||
cy.get('#created-MultiAuths-subscription').within(() => { cy.contains(TEST_ID) }); | ||
}); | ||
}); | ||
}); |
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
31 changes: 31 additions & 0 deletions
31
client-test-apps/js/api-model-relationship-app/src/components/AuthModePicker.tsx
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,31 @@ | ||
import { RadioGroupField, Radio } from "@aws-amplify/ui-react"; | ||
import { useState, SetStateAction, useEffect } from "react"; | ||
import { AuthMode } from "./HarnessContext"; | ||
|
||
type OverrideAuthMode = AuthMode | 'unset'; | ||
|
||
type AuthModePickerProps = { | ||
initialAuthMode?: OverrideAuthMode; | ||
onAuthModeUpdates: (updatedAuthMode?: AuthMode) => void; | ||
}; | ||
|
||
export const AuthModePicker = ({ initialAuthMode, onAuthModeUpdates }: AuthModePickerProps) => { | ||
const [overrideAuthMode, setOverrideAuthMode] = useState<OverrideAuthMode>(initialAuthMode ?? 'unset'); | ||
|
||
useEffect(() => { | ||
onAuthModeUpdates(overrideAuthMode === 'unset' ? undefined : overrideAuthMode); | ||
}, [overrideAuthMode, onAuthModeUpdates]); | ||
|
||
return ( | ||
<RadioGroupField | ||
label="Auth Type Override" | ||
name="authTypeOverride" | ||
value={overrideAuthMode} | ||
onChange={(e) => setOverrideAuthMode(e.target.value as unknown as SetStateAction<OverrideAuthMode>)} | ||
> | ||
<Radio value='unset'>Not Set</Radio> | ||
<Radio value='API_KEY'>API Key</Radio> | ||
<Radio value='AMAZON_COGNITO_USER_POOLS'>User Pool</Radio> | ||
</RadioGroupField> | ||
); | ||
}; |
Oops, something went wrong.