diff --git a/.chronus/changes/fix-password-flow-2024-3-19-16-22-3.md b/.chronus/changes/fix-password-flow-2024-3-19-16-22-3.md new file mode 100644 index 0000000000..435e17e523 --- /dev/null +++ b/.chronus/changes/fix-password-flow-2024-3-19-16-22-3.md @@ -0,0 +1,8 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: fix +packages: + - "@typespec/http" +--- + +Fix password flow defining `authorizationUrl` instead of `tokenUrl` diff --git a/docs/libraries/http/reference/data-types.md b/docs/libraries/http/reference/data-types.md index 35dfc10b30..109a8f8373 100644 --- a/docs/libraries/http/reference/data-types.md +++ b/docs/libraries/http/reference/data-types.md @@ -416,12 +416,12 @@ model TypeSpec.Http.PasswordFlow #### Properties -| Name | Type | Description | -| ---------------- | --------------------------------------- | --------------------------------- | -| type | `TypeSpec.Http.OAuth2FlowType.password` | password flow | -| authorizationUrl | `string` | the authorization URL | -| refreshUrl? | `string` | the refresh URL | -| scopes? | `string[]` | list of scopes for the credential | +| Name | Type | Description | +| ----------- | --------------------------------------- | --------------------------------- | +| type | `TypeSpec.Http.OAuth2FlowType.password` | password flow | +| tokenUrl | `string` | the token URL | +| refreshUrl? | `string` | the refresh URL | +| scopes? | `string[]` | list of scopes for the credential | ### `PlainData` {#TypeSpec.Http.PlainData} diff --git a/eng/common/pipelines/ci.yml b/eng/common/pipelines/ci.yml index 91b0e00ed7..9a23ebe667 100644 --- a/eng/common/pipelines/ci.yml +++ b/eng/common/pipelines/ci.yml @@ -1,9 +1,12 @@ -trigger: none +trigger: + branches: + include: + - gh-readonly-queue/* + pr: branches: include: - main - - gh-readonly-queue/* extends: template: /eng/common/pipelines/templates/1es-redirect.yml @@ -19,6 +22,9 @@ extends: - job: InitJob displayName: Initialize steps: + - script: node $(Build.SourcesDirectory)/eng/common/scripts/resolve-target-branch.js + displayName: Resolve target branch + - task: PowerShell@2 displayName: "Analyze PR changes" name: InitStep @@ -26,7 +32,7 @@ extends: pwsh: true filePath: $(Build.SourcesDirectory)/eng/common/scripts/Analyze-Changes.ps1 arguments: > - -TargetBranch $(System.PullRequest.TargetBranch) + -TargetBranch $(TARGET_BRANCH) workingDirectory: $(Build.SourcesDirectory) # Run csharp stages if RunCSharp == true diff --git a/eng/common/scripts/resolve-target-branch.js b/eng/common/scripts/resolve-target-branch.js new file mode 100644 index 0000000000..271876df1d --- /dev/null +++ b/eng/common/scripts/resolve-target-branch.js @@ -0,0 +1,23 @@ +// @ts-check +const prTargetBranch = process.env["SYSTEM_PULLREQUEST_TARGETBRANCHNAME"]; +const currentBranch = process.env["BUILD_SOURCEBRANCH"]; + +console.log("Branches:", { + prTargetBranch, + currentBranch, +}); + +if (prTargetBranch !== undefined) { + console.log("Target branch is", prTargetBranch); + console.log(`##vso[task.setvariable variable=TARGET_BRANCH]${prTargetBranch}`); +} else if (currentBranch) { + const match = currentBranch.match(/refs\/heads\/gh-readonly-queue\/(.*)\/pr-.*/); + if (match !== null) { + const targetBranch = match[1]; + console.log("Target branch is", targetBranch); + console.log(`##vso[task.setvariable variable=TARGET_BRANCH]${targetBranch}`); + } +} else { + console.log("Failed to resolve target branch."); + process.exit(1); +} diff --git a/packages/http/lib/auth.tsp b/packages/http/lib/auth.tsp index ec4a39ba4f..2fdc29f843 100644 --- a/packages/http/lib/auth.tsp +++ b/packages/http/lib/auth.tsp @@ -177,8 +177,8 @@ model PasswordFlow { @doc("password flow") type: OAuth2FlowType.password; - @doc("the authorization URL") - authorizationUrl: string; + @doc("the token URL") + tokenUrl: string; @doc("the refresh URL") refreshUrl?: string;