Skip to content

Commit 77a289e

Browse files
authored
AXON-797: Added E2E test to authenticate with Jira DC (#693)
* AXON-797: Added E2E test to authenticate with Jira DC * AXON-797: Clen up code
1 parent 5646ff3 commit 77a289e

File tree

14 files changed

+185
-3
lines changed

14 files changed

+185
-3
lines changed

e2e/compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ services:
1616
e2e:
1717
aliases:
1818
- mockedteams.atlassian.net
19+
- jira.mockeddomain.com
1920
expose:
2021
- 443
2122

e2e/helpers/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export { updateIssueField } from './update-jira-issue';
22
export { authenticateWithBitbucketDC, authenticateWithBitbucketCloud } from './bitbucket-auth';
33
export { connectRepository } from './bitbucket-connect-repository';
4-
export { authenticateWithJira } from './jira-auth';
4+
export { authenticateWithJira, authenticateWithJiraDC } from './jira-auth';
55
export { getIssueFrame, openAtlassianSettings } from './common';
66
export { cleanupWireMockMapping, setupWireMockMapping, setupSearchMock, setupIssueMock } from './setup-mock';

e2e/helpers/jira-auth.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,47 @@ export const authenticateWithJira = async (
4646
// Wait for authentication to complete and tree items to be visible
4747
await expect(page.getByRole('treeitem', { name: 'BTS-1 - User Interface Bugs' })).toBeVisible();
4848
};
49+
50+
/**
51+
* Helper function to authenticate with Jira DC using the provided credentials
52+
*/
53+
export const authenticateWithJiraDC = async (
54+
page: Page,
55+
baseUrl: string = 'https://jira.mockeddomain.com',
56+
username: string = 'dcUser',
57+
password: string = '12345',
58+
) => {
59+
const settingsFrame = await openAtlassianSettings(page, 'Please login to Jira');
60+
61+
await expect(settingsFrame.getByRole('button', { name: 'Authentication authenticate' })).toBeVisible();
62+
await expect(settingsFrame.getByRole('button', { name: 'Login to Jira' })).toBeVisible();
63+
64+
settingsFrame.getByRole('button', { name: 'Login to Jira' }).click();
65+
await page.waitForTimeout(250);
66+
67+
await settingsFrame.getByRole('textbox', { name: 'Base URL' }).click();
68+
await page.waitForTimeout(250);
69+
70+
await settingsFrame.getByRole('textbox', { name: 'Base URL' }).fill(baseUrl);
71+
await page.waitForTimeout(250);
72+
73+
await settingsFrame.getByRole('textbox', { name: 'Username' }).click();
74+
await page.waitForTimeout(250);
75+
76+
await settingsFrame.getByRole('textbox', { name: 'Username' }).fill(username);
77+
await page.waitForTimeout(250);
78+
79+
await settingsFrame.getByRole('textbox', { name: 'Password' }).click();
80+
await page.waitForTimeout(250);
81+
82+
await settingsFrame.getByRole('textbox', { name: 'Password' }).fill(password);
83+
await page.waitForTimeout(250);
84+
85+
await closeAllNotifications(page);
86+
87+
await settingsFrame.getByRole('button', { name: 'Save Site' }).click();
88+
await page.waitForTimeout(3000);
89+
90+
// Authentication successful - DC auth complete
91+
await expect(page.getByRole('treeitem', { name: 'BTS-1 - User Interface Bugs' })).toBeVisible();
92+
};

e2e/sslcerts/generate-certs.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ openssl genrsa -out rootCA.key 4096
7979
# Creates a self-signed CA certificate valid for 10 years
8080
openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 3650 -out rootCA.crt -subj "/C=US/ST=Washington/L=Bellevue/O=Atlascode/CN=Atlascode CA"
8181

82-
# Generates a certificate for mockedteams.atlassian.net
83-
generate_service_cert "wiremock-mockedteams" "mockedteams.atlassian.net"
82+
# Generates a certificate for both Jira Cloud and DC domains
83+
generate_service_cert "wiremock-mockedteams" "mockedteams.atlassian.net" "jira.mockeddomain.com"
8484

8585
# # Generates a certificate for bitbucket.mockeddomain.com
8686
generate_service_cert "wiremock-bitbucket" "bitbucket.mockeddomain.com"

e2e/tests/jira/authFlowDC.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { test } from '@playwright/test';
2+
import { authenticateWithJiraDC } from 'e2e/helpers';
3+
import { AtlascodeDrawer } from 'e2e/page-objects';
4+
5+
test('Authenticating with Jira DC works', async ({ page }) => {
6+
await authenticateWithJiraDC(page);
7+
8+
// Verify that authentication was successful by checking that an issue is visible
9+
await new AtlascodeDrawer(page).jira.expectIssueExists('BTS-1 - User Interface Bugs');
10+
});

e2e/wiremock-mappings/jira-dc/BTS-1/bts1.json

Lines changed: 18 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"request": {
3+
"method": "GET",
4+
"urlPath": "/rest/api/2/issue/BTS-1/watchers"
5+
},
6+
"response": {
7+
"status": 200,
8+
"body": "{\"self\":\"https://jira.mockeddomain.com/rest/api/2/issue/BTS-1/watchers\",\"isWatching\":true,\"watchCount\":1,\"watchers\":[{\"self\":\"https://jira.mockeddomain.com/rest/api/2/user?accountId=712020%3A13354d79-beaa-49d6-a55f-b9510892e3f4\",\"accountId\":\"712020:13354d79-beaa-49d6-a55f-b9510892e3f4\",\"emailAddress\":\"[email protected]\",\"avatarUrls\":{\"48x48\":\"https://secure.gravatar.com/avatar/3c1286d428ff8f7167844ee661f0aef0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.staging.public.atl-paas.net%2Finitials%2FMM-3.png\",\"24x24\":\"https://secure.gravatar.com/avatar/3c1286d428ff8f7167844ee661f0aef0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.staging.public.atl-paas.net%2Finitials%2FMM-3.png\",\"16x16\":\"https://secure.gravatar.com/avatar/3c1286d428ff8f7167844ee661f0aef0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.staging.public.atl-paas.net%2Finitials%2FMM-3.png\",\"32x32\":\"https://secure.gravatar.com/avatar/3c1286d428ff8f7167844ee661f0aef0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.staging.public.atl-paas.net%2Finitials%2FMM-3.png\"},\"displayName\":\"Mocked McMock\",\"active\":true,\"timeZone\":\"America/Los_Angeles\",\"accountType\":\"atlassian\"}]}",
9+
"headers": {
10+
"Content-Type": "application/json"
11+
}
12+
}
13+
}

e2e/wiremock-mappings/jira-dc/autocompletedata.json

Lines changed: 13 additions & 0 deletions
Large diffs are not rendered by default.

e2e/wiremock-mappings/jira-dc/field.json

Lines changed: 13 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"request": {
3+
"method": "GET",
4+
"urlPath": "/rest/api/2/issueLinkType"
5+
},
6+
"response": {
7+
"status": 200,
8+
"body": "{\"issueLinkTypes\":[{\"id\":\"10000\",\"name\":\"Blocks\",\"inward\":\"is blocked by\",\"outward\":\"blocks\",\"self\":\"https://jira.mockeddomain.com/rest/api/2/issueLinkType/10000\"},{\"id\":\"10001\",\"name\":\"Cloners\",\"inward\":\"is cloned by\",\"outward\":\"clones\",\"self\":\"https://jira.mockeddomain.com/rest/api/2/issueLinkType/10001\"},{\"id\":\"10002\",\"name\":\"Duplicate\",\"inward\":\"is duplicated by\",\"outward\":\"duplicates\",\"self\":\"https://jira.mockeddomain.com/rest/api/2/issueLinkType/10002\"},{\"id\":\"10003\",\"name\":\"Relates\",\"inward\":\"relates to\",\"outward\":\"relates to\",\"self\":\"https://jira.mockeddomain.com/rest/api/2/issueLinkType/10003\"}]}",
9+
"headers": {
10+
"Content-Type": "application/json"
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)