-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
UI: Move useOpenApi and getHelpUrl methods to util #27764
Changes from all commits
bf8aec2
195c915
f826de8
3571fac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import authPage from 'vault/tests/pages/auth'; | |
import { deleteAuthCmd, deleteEngineCmd, mountAuthCmd, mountEngineCmd, runCmd } from '../helpers/commands'; | ||
import expectedSecretAttrs from 'vault/tests/helpers/openapi/expected-secret-attrs'; | ||
import expectedAuthAttrs from 'vault/tests/helpers/openapi/expected-auth-attrs'; | ||
import { getHelpUrlForModel } from 'vault/utils/openapi-helpers'; | ||
|
||
/** | ||
* This set of tests is for ensuring that backend changes to the OpenAPI spec | ||
|
@@ -72,8 +73,7 @@ function secretEngineHelper(test, secretEngine) { | |
// A given secret engine might have multiple models that are openApi driven | ||
modelNames.forEach((modelName) => { | ||
test(`${modelName} model getProps returns correct attributes`, async function (assert) { | ||
const model = this.store.createRecord(modelName, {}); | ||
const helpUrl = model.getHelpUrl(this.backend); | ||
const helpUrl = getHelpUrlForModel(modelName, this.backend); | ||
const result = await this.pathHelp.getProps(helpUrl, this.backend); | ||
const expected = engineData[modelName]; | ||
// Expected values should be updated to match "actual" (result) | ||
|
@@ -98,8 +98,7 @@ function authEngineHelper(test, authBackend) { | |
if (itemName.startsWith('auth-config/')) { | ||
// Config test doesn't need to instantiate a new model | ||
test(`${itemName} model`, async function (assert) { | ||
const model = this.store.createRecord(itemName, {}); | ||
const helpUrl = model.getHelpUrl(this.mount); | ||
const helpUrl = getHelpUrlForModel(itemName, this.mount); | ||
const result = await this.pathHelp.getProps(helpUrl, this.mount); | ||
const expected = authData[itemName]; | ||
assert.deepEqual( | ||
|
@@ -116,9 +115,8 @@ function authEngineHelper(test, authBackend) { | |
const modelName = `generated-${itemName}-${authBackend}`; | ||
// Generated items need to instantiate the model first via getNewModel | ||
await this.pathHelp.getNewModel(modelName, this.mount, `auth/${this.mount}/`, itemName); | ||
const model = this.store.createRecord(modelName, {}); | ||
// Generated items don't have this method -- helpUrl is calculated in path-help.js line 101 | ||
const helpUrl = model.getHelpUrl(this.mount); | ||
// Generated items don't have helpUrl method -- helpUrl is calculated in path-help.js line 101 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thank you for this comment! do we have test coverage that assures removing the From what I gather it seems like all non-generated items have paths defined in the new helper, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question! I removed the
even if Otherwise your comment is true -- if we have the base model for it, the helpUrl should be defined in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, this is a skipped test -- I just didn't want any instances of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great thinking! nice to keep up with tech debt while we have context. awesome! that all makes sense, thanks for explaining. |
||
const helpUrl = `/v1/auth/${this.mount}?help=1`; | ||
const result = await this.pathHelp.getProps(helpUrl, this.mount); | ||
const expected = authData[modelName]; | ||
assert.deepEqual(result, expected, `getProps returns expected attributes for ${modelName}`); | ||
|
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.
do we need both keyof and typeof here?
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.
Yup, because
OPENAPI_POWERED_MODELS
is a const not an interface, so we need typeof so typescript is happy