mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 02:19:58 -03:30
Merge pull request #8877 from jakemcdermott/ws-proto
Support ws or wss proto Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
commit
3ae6ea9cdc
@ -44,7 +44,7 @@ describe('useWsJobs hook', () => {
|
||||
|
||||
test('should establish websocket connection', async () => {
|
||||
global.document.cookie = 'csrftoken=abc123';
|
||||
const mockServer = new WS('wss://localhost/websocket/');
|
||||
const mockServer = new WS('ws://localhost/websocket/');
|
||||
|
||||
const jobs = [{ id: 1 }];
|
||||
await act(async () => {
|
||||
@ -67,7 +67,7 @@ describe('useWsJobs hook', () => {
|
||||
|
||||
test('should update job status', async () => {
|
||||
global.document.cookie = 'csrftoken=abc123';
|
||||
const mockServer = new WS('wss://localhost/websocket/');
|
||||
const mockServer = new WS('ws://localhost/websocket/');
|
||||
|
||||
const jobs = [{ id: 1, status: 'running' }];
|
||||
await act(async () => {
|
||||
@ -105,7 +105,7 @@ describe('useWsJobs hook', () => {
|
||||
|
||||
test('should fetch new job', async () => {
|
||||
global.document.cookie = 'csrftoken=abc123';
|
||||
const mockServer = new WS('wss://localhost/websocket/');
|
||||
const mockServer = new WS('ws://localhost/websocket/');
|
||||
const jobs = [{ id: 1 }];
|
||||
const fetch = jest.fn(() => []);
|
||||
await act(async () => {
|
||||
|
||||
@ -59,7 +59,7 @@ describe('useWsInventories hook', () => {
|
||||
|
||||
test('should establish websocket connection', async () => {
|
||||
global.document.cookie = 'csrftoken=abc123';
|
||||
const mockServer = new WS('wss://localhost/websocket/');
|
||||
const mockServer = new WS('ws://localhost/websocket/');
|
||||
|
||||
const inventories = [{ id: 1 }];
|
||||
await act(async () => {
|
||||
@ -83,7 +83,7 @@ describe('useWsInventories hook', () => {
|
||||
|
||||
test('should update inventory sync status', async () => {
|
||||
global.document.cookie = 'csrftoken=abc123';
|
||||
const mockServer = new WS('wss://localhost/websocket/');
|
||||
const mockServer = new WS('ws://localhost/websocket/');
|
||||
|
||||
const inventories = [{ id: 1 }];
|
||||
await act(async () => {
|
||||
@ -121,7 +121,7 @@ describe('useWsInventories hook', () => {
|
||||
|
||||
test('should fetch fresh inventory after sync runs', async () => {
|
||||
global.document.cookie = 'csrftoken=abc123';
|
||||
const mockServer = new WS('wss://localhost/websocket/');
|
||||
const mockServer = new WS('ws://localhost/websocket/');
|
||||
const inventories = [{ id: 1 }];
|
||||
const fetchInventories = jest.fn(() => []);
|
||||
const fetchInventoriesById = jest.fn(() => []);
|
||||
@ -152,7 +152,7 @@ describe('useWsInventories hook', () => {
|
||||
|
||||
test('should update inventory pending_deletion', async () => {
|
||||
global.document.cookie = 'csrftoken=abc123';
|
||||
const mockServer = new WS('wss://localhost/websocket/');
|
||||
const mockServer = new WS('ws://localhost/websocket/');
|
||||
|
||||
const inventories = [{ id: 1, pending_deletion: false }];
|
||||
await act(async () => {
|
||||
@ -190,7 +190,7 @@ describe('useWsInventories hook', () => {
|
||||
|
||||
test('should refetch inventories after an inventory is deleted', async () => {
|
||||
global.document.cookie = 'csrftoken=abc123';
|
||||
const mockServer = new WS('wss://localhost/websocket/');
|
||||
const mockServer = new WS('ws://localhost/websocket/');
|
||||
const inventories = [{ id: 1 }, { id: 2 }];
|
||||
const fetchInventories = jest.fn(() => []);
|
||||
const fetchInventoriesById = jest.fn(() => []);
|
||||
|
||||
@ -43,7 +43,7 @@ describe('useWsInventorySources hook', () => {
|
||||
|
||||
test('should establish websocket connection', async () => {
|
||||
global.document.cookie = 'csrftoken=abc123';
|
||||
const mockServer = new WS('wss://localhost/websocket/');
|
||||
const mockServer = new WS('ws://localhost/websocket/');
|
||||
|
||||
const sources = [{ id: 1 }];
|
||||
await act(async () => {
|
||||
@ -65,7 +65,7 @@ describe('useWsInventorySources hook', () => {
|
||||
|
||||
test('should update last job status', async () => {
|
||||
global.document.cookie = 'csrftoken=abc123';
|
||||
const mockServer = new WS('wss://localhost/websocket/');
|
||||
const mockServer = new WS('ws://localhost/websocket/');
|
||||
|
||||
const sources = [
|
||||
{
|
||||
|
||||
@ -170,7 +170,11 @@ const OutputFooter = styled.div`
|
||||
|
||||
let ws;
|
||||
function connectJobSocket({ type, id }, onMessage) {
|
||||
ws = new WebSocket(`wss://${window.location.host}/websocket/`);
|
||||
ws = new WebSocket(
|
||||
`${window.location.protocol === 'http:' ? 'ws:' : 'wss:'}//${
|
||||
window.location.host
|
||||
}/websocket/`
|
||||
);
|
||||
|
||||
ws.onopen = () => {
|
||||
const xrftoken = `; ${document.cookie}`
|
||||
|
||||
@ -36,7 +36,7 @@ describe('useWsProjects', () => {
|
||||
|
||||
test('should establish websocket connection', async () => {
|
||||
global.document.cookie = 'csrftoken=abc123';
|
||||
const mockServer = new WS('wss://localhost/websocket/');
|
||||
const mockServer = new WS('ws://localhost/websocket/');
|
||||
|
||||
const projects = [{ id: 1 }];
|
||||
await act(async () => {
|
||||
@ -58,7 +58,7 @@ describe('useWsProjects', () => {
|
||||
|
||||
test('should update project status', async () => {
|
||||
global.document.cookie = 'csrftoken=abc123';
|
||||
const mockServer = new WS('wss://localhost/websocket/');
|
||||
const mockServer = new WS('ws://localhost/websocket/');
|
||||
|
||||
const projects = [
|
||||
{
|
||||
|
||||
@ -53,7 +53,7 @@ describe('useWsWorkflowApprovals hook', () => {
|
||||
|
||||
test('should establish websocket connection', async () => {
|
||||
global.document.cookie = 'csrftoken=abc123';
|
||||
const mockServer = new WS('wss://localhost/websocket/');
|
||||
const mockServer = new WS('ws://localhost/websocket/');
|
||||
|
||||
const workflowApprovals = [{ id: 1, status: 'successful' }];
|
||||
await act(async () => {
|
||||
@ -79,7 +79,7 @@ describe('useWsWorkflowApprovals hook', () => {
|
||||
|
||||
test('should refetch after new approval job is created', async () => {
|
||||
global.document.cookie = 'csrftoken=abc123';
|
||||
const mockServer = new WS('wss://localhost/websocket/');
|
||||
const mockServer = new WS('ws://localhost/websocket/');
|
||||
const workflowApprovals = [{ id: 1, status: 'successful' }];
|
||||
const fetchWorkflowApprovals = jest.fn(() => []);
|
||||
await act(async () => {
|
||||
@ -107,7 +107,7 @@ describe('useWsWorkflowApprovals hook', () => {
|
||||
|
||||
test('should refetch after approval job in current list is updated', async () => {
|
||||
global.document.cookie = 'csrftoken=abc123';
|
||||
const mockServer = new WS('wss://localhost/websocket/');
|
||||
const mockServer = new WS('ws://localhost/websocket/');
|
||||
const workflowApprovals = [{ id: 1, status: 'pending' }];
|
||||
const fetchWorkflowApprovals = jest.fn(() => []);
|
||||
await act(async () => {
|
||||
@ -135,7 +135,7 @@ describe('useWsWorkflowApprovals hook', () => {
|
||||
|
||||
test('should not refetch when message is not workflow approval', async () => {
|
||||
global.document.cookie = 'csrftoken=abc123';
|
||||
const mockServer = new WS('wss://localhost/websocket/');
|
||||
const mockServer = new WS('ws://localhost/websocket/');
|
||||
const workflowApprovals = [{ id: 1, status: 'successful' }];
|
||||
const fetchWorkflowApprovals = jest.fn(() => []);
|
||||
await act(async () => {
|
||||
|
||||
@ -5,7 +5,11 @@ export default function useWebsocket(subscribeGroups) {
|
||||
const ws = useRef(null);
|
||||
|
||||
useEffect(function setupSocket() {
|
||||
ws.current = new WebSocket(`wss://${window.location.host}/websocket/`);
|
||||
ws.current = new WebSocket(
|
||||
`${window.location.protocol === 'http:' ? 'ws:' : 'wss:'}//${
|
||||
window.location.host
|
||||
}/websocket/`
|
||||
);
|
||||
|
||||
const connect = () => {
|
||||
const xrftoken = `; ${document.cookie}`
|
||||
|
||||
@ -43,7 +43,7 @@ describe('useWsTemplates hook', () => {
|
||||
|
||||
test('should establish websocket connection', async () => {
|
||||
global.document.cookie = 'csrftoken=abc123';
|
||||
const mockServer = new WS('wss://localhost/websocket/');
|
||||
const mockServer = new WS('ws://localhost/websocket/');
|
||||
|
||||
const templates = [{ id: 1 }];
|
||||
await act(async () => {
|
||||
@ -65,7 +65,7 @@ describe('useWsTemplates hook', () => {
|
||||
|
||||
test('should update recent job status', async () => {
|
||||
global.document.cookie = 'csrftoken=abc123';
|
||||
const mockServer = new WS('wss://localhost/websocket/');
|
||||
const mockServer = new WS('ws://localhost/websocket/');
|
||||
|
||||
const templates = [
|
||||
{
|
||||
@ -125,7 +125,7 @@ describe('useWsTemplates hook', () => {
|
||||
|
||||
test('should add new job status', async () => {
|
||||
global.document.cookie = 'csrftoken=abc123';
|
||||
const mockServer = new WS('wss://localhost/websocket/');
|
||||
const mockServer = new WS('ws://localhost/websocket/');
|
||||
|
||||
const templates = [
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user