Repository navigation
Normalize GitHub Enterprise authentication endpoints to HTTPS #493
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
Merged
Sheng Chen (jdneo)
merged 5 commits into
main
from
copilot/fix-authentication-redirect-issue
Oct 21, 2026
+165
−2
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ff9219e
Initial plan
Copilot ae81fe4
Validate enterprise authentication endpoints require HTTPS
Copilot de9cc33
Use native hints for the enterprise endpoint preference
jdneo 1f285dc
Normalize GitHub Enterprise authentication endpoints to HTTPS
jdneo 230456d
Revert enterprise endpoint normalization commit
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
137 changes: 137 additions & 0 deletions
137
....ui.test/src/com/microsoft/copilot/eclipse/ui/preferences/GeneralPreferencesPageTest.java
This file contains hidden or 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,137 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| package com.microsoft.copilot.eclipse.ui.preferences; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertFalse; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
| import static org.junit.jupiter.api.Assertions.assertNull; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| import org.eclipse.jface.preference.FieldEditor; | ||
| import org.eclipse.jface.preference.PreferenceStore; | ||
| import org.eclipse.jface.preference.StringFieldEditor; | ||
| import org.eclipse.swt.widgets.Composite; | ||
| import org.eclipse.swt.widgets.Control; | ||
| import org.eclipse.swt.widgets.Display; | ||
| import org.eclipse.swt.widgets.Shell; | ||
| import org.eclipse.swt.widgets.Text; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.ValueSource; | ||
|
|
||
| import com.microsoft.copilot.eclipse.core.Constants; | ||
| import com.microsoft.copilot.eclipse.ui.utils.SwtUtils; | ||
|
|
||
| class GeneralPreferencesPageTest { | ||
|
|
||
| private Shell shell; | ||
| private TestPreferencesPage page; | ||
|
|
||
| @AfterEach | ||
| void tearDown() { | ||
| SwtUtils.invokeOnDisplayThread(() -> { | ||
| if (page != null) { | ||
| page.dispose(); | ||
| } | ||
| if (shell != null && !shell.isDisposed()) { | ||
| shell.dispose(); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| @ParameterizedTest | ||
| @ValueSource(strings = {"", "https://company.ghe.com", "https://company.ghe.com/", | ||
| "https://github.company.example:8443", "HTTPS://company.ghe.com", "HtTpS://company.ghe.com"}) | ||
| void testEnterpriseEndpoint_validStoredValue_pageIsValid(String endpoint) { | ||
| SwtUtils.invokeOnDisplayThread(() -> { | ||
| createPage(endpoint); | ||
| assertTrue(page.isValid()); | ||
| assertNull(page.getErrorMessage()); | ||
| }); | ||
| } | ||
|
|
||
| @ParameterizedTest | ||
| @ValueSource(strings = {"http://company.ghe.com/", "company.ghe.com", "ftp://company.ghe.com", | ||
| "https://", "https:///company.ghe.com", "https://company ghe.com", "https://company.ghe.com/%", | ||
| " ", " https://company.ghe.com", "https://company.ghe.com "}) | ||
| void testEnterpriseEndpoint_invalidStoredValue_pageShowsError(String endpoint) { | ||
| SwtUtils.invokeOnDisplayThread(() -> { | ||
| createPage(endpoint); | ||
| assertFalse(page.isValid()); | ||
| assertEquals(Messages.preferences_page_github_enterprise_validation_error, page.getErrorMessage()); | ||
| }); | ||
| } | ||
|
|
||
| @ParameterizedTest | ||
| @ValueSource(strings = {"", "https://company.ghe.com"}) | ||
| void testEnterpriseEndpoint_nativeHints_preserveValue(String endpoint) { | ||
| SwtUtils.invokeOnDisplayThread(() -> { | ||
| createPage(endpoint); | ||
| Text endpointText = findTextControl((Composite) page.getControl()); | ||
| assertNotNull(endpointText); | ||
| assertEquals(Messages.preferences_page_github_enterprise_placeholder, endpointText.getMessage()); | ||
| assertEquals(Messages.preferences_page_github_enterprise_tooltip, endpointText.getToolTipText()); | ||
| assertEquals(endpoint, endpointText.getText()); | ||
|
|
||
| page.endpointField.store(); | ||
| assertEquals(endpoint, page.getPreferenceStore().getString(Constants.GITHUB_ENTERPRISE)); | ||
| }); | ||
| } | ||
|
|
||
| @Test | ||
| void testEnterpriseEndpoint_editValue_validationUpdatesImmediately() { | ||
| SwtUtils.invokeOnDisplayThread(() -> { | ||
| createPage(""); | ||
| page.endpointField.setStringValue("http://company.ghe.com/"); | ||
| assertFalse(page.isValid()); | ||
| assertEquals(Messages.preferences_page_github_enterprise_validation_error, page.getErrorMessage()); | ||
|
|
||
| page.endpointField.setStringValue("https://company.ghe.com/"); | ||
| assertTrue(page.isValid()); | ||
| assertNull(page.getErrorMessage()); | ||
|
|
||
| page.endpointField.setStringValue(""); | ||
| assertTrue(page.isValid()); | ||
| assertNull(page.getErrorMessage()); | ||
| }); | ||
| } | ||
|
|
||
| private void createPage(String endpoint) { | ||
| shell = new Shell(Display.getDefault()); | ||
| PreferenceStore store = new PreferenceStore(); | ||
| store.setValue(Constants.GITHUB_ENTERPRISE, endpoint); | ||
| page = new TestPreferencesPage(); | ||
| page.setPreferenceStore(store); | ||
| page.createControl(shell); | ||
| } | ||
|
|
||
| private Text findTextControl(Composite parent) { | ||
| for (Control child : parent.getChildren()) { | ||
| if (child instanceof Text text) { | ||
| return text; | ||
| } | ||
| if (child instanceof Composite composite) { | ||
| Text text = findTextControl(composite); | ||
| if (text != null) { | ||
| return text; | ||
| } | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| private static class TestPreferencesPage extends GeneralPreferencesPage { | ||
| private StringFieldEditor endpointField; | ||
|
|
||
| @Override | ||
| protected void addField(FieldEditor editor) { | ||
| super.addField(editor); | ||
| if (Constants.GITHUB_ENTERPRISE.equals(editor.getPreferenceName())) { | ||
| endpointField = (StringFieldEditor) editor; | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.