Skip to content
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

T#2490/primevue oauth #2591

Merged
merged 8 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .github/workflows/build-and-test-oauth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ on:
schedule:
- cron: '0 6 * * *'
workflow_dispatch:
push:
# pull_request:
# paths-ignore:
# - 'README.md'
Expand All @@ -38,7 +39,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: '14'
node-version: '20.11.0'

- uses: actions/setup-java@v3
with:
Expand Down Expand Up @@ -114,7 +115,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: '14'
node-version: '20.11.0'

- uses: actions/setup-java@v3
with:
Expand All @@ -140,7 +141,7 @@ jobs:
- name: Check running containers
run: docker ps -a

- name: Caputre Hydra Oauth Service logs
- name: Capture Hydra Oauth Service logs
run: |
mkdir -p ./e2e-tests/logs
docker logs hydra > ./e2e-tests/logs/hydra.out &
Expand All @@ -162,15 +163,13 @@ jobs:
- name: Start services for Cypress tests
run: |
cd e2e-tests
npm install
npm run backend:dropAllDBTables
npm run cyServices:start:skills-service:oauth
npm run cyServices:start:client-display:oauth
cd ..

- name: Run Cypress tests
run: |
cd e2e-tests
npm install
../.github/scripts/runSubsetOfCypressTests.sh -t 20 -c ${{ matrix.container }}
cd ..
env:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ on:
- 'README.md'
- '.github/workflows/build-and-test-postgres.yml'
- '.github/workflows/publish-image-snapshot.yml'
- '.gitlab-ci.yml'

jobs:
build-skills-service-for-ui-tests:
Expand Down
2 changes: 1 addition & 1 deletion dashboard-prime/src/components/access/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ onBeforeMount(() => {
}
})
const oAuth2Login = (registrationId) => {
// this.$store.dispatch('oAuth2Login', registrationId);
authState.oAuth2Login(registrationId)
}
</script>

Expand Down
8 changes: 5 additions & 3 deletions dashboard-prime/src/stores/UseAuthState.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { computed, ref } from 'vue'
import { useRouter } from 'vue-router'
import { useRoute, useRouter } from 'vue-router'
import { defineStore } from 'pinia'
import axios from 'axios'
import { SkillsConfiguration } from '@skilltree/skills-client-js'
Expand All @@ -17,6 +17,7 @@ export const useAuthState = defineStore('authState', () => {
const oAuthAuth = ref(false)

const router = useRouter()
const route = useRoute()
const appConfig = useAppConfig()
const appInfoState = useAppInfoState()

Expand Down Expand Up @@ -95,8 +96,9 @@ export const useAuthState = defineStore('authState', () => {
}
const oAuth2Login = (oAuthId) => {
setOauth2AuthUser()
const { redirect } = router.currentRoute.query
window.location = `/oauth2/authorization/${encodeURIComponent(oAuthId)}${redirect ? `?skillsRedirectUri=${redirect}` : ''}`
const redirect = route.query.redirect
const newLocation = `/oauth2/authorization/${encodeURIComponent(oAuthId)}${redirect ? `?skillsRedirectUri=${redirect}` : ''}`
window.location = newLocation
}
const restoreSessionIfAvailable = () => {
setRestoringSession(true)
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/cypress/e2e/approver/approver_conf_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('Approver Config Tests', () => {

cy.get(`[data-cy="workloadCell_${user1}"] [data-cy="editApprovalBtn"]`).click()
cy.get(`[data-cy="expandedChild_${user1}"] [data-cy="userIdInput"]`).click();
cy.selectItem(`[data-cy="expandedChild_${user1}"] [data-cy="userIdInput"] #existingUserInput`, 'userA', true, true);
cy.selectItem(`[data-cy="expandedChild_${user1}"] [data-cy="userIdInput"] #existingUserInput`, 'userb', true, true);
// cy.get(`[data-cy="expandedChild_${user1}"] [data-cy="userIdInput"] .vs__dropdown-option`).contains('userA').click({force: true});
cy.get(`[data-cy="expandedChild_${user1}"] [data-cy="addUserConfBtn"]`).click()
cy.get(`[data-cy="workloadCell_${user1}"]`).contains('1 Specific User')
Expand Down
30 changes: 19 additions & 11 deletions e2e-tests/cypress/e2e/approver/approver_conf_users_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('Approver Config Users Tests', () => {
cy.get(`[data-cy="expandedChild_${user1}"] [data-cy="addUserConfBtn"]`).should('be.disabled')

// cy.get(`[data-cy="expandedChild_${user1}"] [data-cy="userIdInput"]`).click();
cy.selectItem(`[data-cy="expandedChild_${user1}"] [data-cy="userIdInput"] #existingUserInput`, 'userA', true, true);
cy.selectItem(`[data-cy="expandedChild_${user1}"] [data-cy="userIdInput"] #existingUserInput`, 'usera', true, true);
// cy.get(`[data-cy="expandedChild_${user1}"] [data-cy="userIdInput"] .p-dropdown-option`).contains('userA').click();
cy.get(`[data-cy="expandedChild_${user1}"] [data-cy="addUserConfBtn"]`).should('be.enabled')

Expand All @@ -79,7 +79,7 @@ describe('Approver Config Users Tests', () => {
cy.get(`[data-cy="workloadCell_${user1}"]`).contains('1 Specific User')

// cy.get(`[data-cy="expandedChild_${user1}"] [data-cy="userIdInput"]`).click();
cy.selectItem(`[data-cy="expandedChild_${user1}"] [data-cy="userIdInput"] #existingUserInput`, 'userB', true, true);
cy.selectItem(`[data-cy="expandedChild_${user1}"] [data-cy="userIdInput"] #existingUserInput`, 'userb', true, true);
// cy.get(`[data-cy="expandedChild_${user1}"] [data-cy="userIdInput"] .p-dropdown-option`).contains('userB').click();
cy.get(`[data-cy="expandedChild_${user1}"] [data-cy="addUserConfBtn"]`).should('be.enabled')
cy.get(`[data-cy="expandedChild_${user1}"] [data-cy="addUserConfBtn"]`).click()
Expand Down Expand Up @@ -200,15 +200,23 @@ describe('Approver Config Users Tests', () => {
const headerSelector = `${tableSelector} thead tr th`;
cy.get(headerSelector).contains('User').click();

cy.selectItem(`[data-cy="expandedChild_${user1}"] [data-cy="userIdInput"] #existingUserInput`, 'userE', true, true);
cy.get(`[data-cy="expandedChild_${user1}"] [data-cy="addUserConfBtn"]`).click()

cy.validateTable(tableSelector, [
[{ colIndex: 0, value: 'userA' }],
[{ colIndex: 0, value: 'userB' }],
[{ colIndex: 0, value: 'userC' }],
[{ colIndex: 0, value: 'userD' }],
[{ colIndex: 0, value: 'userE' }],
], 4);
cy.fixture('vars.json').then((vars) => {
const defaultUser = Cypress.env('oauthMode') ? 'foo' : vars.defaultUser
cy.selectItem(`[data-cy="expandedChild_${user1}"] [data-cy="userIdInput"] #existingUserInput`, defaultUser, true, true);
cy.get(`[data-cy="expandedChild_${user1}"] [data-cy="addUserConfBtn"]`).click()

const compare = (a, b) => {
return a[0].value?.localeCompare(b[0].value)
}
const expected = [
[{ colIndex: 0, value: 'userA' }],
[{ colIndex: 0, value: 'userB' }],
[{ colIndex: 0, value: 'userC' }],
[{ colIndex: 0, value: 'userD' }],
[{ colIndex: 0, value: defaultUser }],
].sort(compare)
cy.validateTable(tableSelector, expected, 4);
})
})
});
2 changes: 1 addition & 1 deletion e2e-tests/cypress/e2e/inception/inception_skills_specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ describe('Inception Skills Tests', () => {
cy.get(`[data-cy="expandedChild_${user1}"] [data-cy="noUserConf"]`).should('exist')

cy.get(`[data-cy="expandedChild_${user1}"] [data-cy="userIdInput"]`).click();
cy.selectItem(`[data-cy="expandedChild_${user1}"] [data-cy="userIdInput"] #existingUserInput`, 'userA', true, true);
cy.selectItem(`[data-cy="expandedChild_${user1}"] [data-cy="userIdInput"] #existingUserInput`, 'usera', true, true);
cy.get(`[data-cy="expandedChild_${user1}"] [data-cy="addUserConfBtn"]`).should('be.enabled')

cy.assertInceptionPoints('Skills', 'ConfigureSelfApprovalWorkload', 0, false)
Expand Down
6 changes: 5 additions & 1 deletion e2e-tests/cypress/e2e/projects_admin_management_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,14 @@ describe('Projects Admin Management Tests', () => {
cy.get('[data-pc-section="panel"] [data-pc-section="itemlabel"]').contains('Administrator').click();
cy.wait('@addAdmin')
cy.get(`${tableSelector} thead th`).contains('User').click();

const compare = (a, b) => {
return a[0].value?.localeCompare(b[0].value)
}
cy.validateTable(tableSelector, [
[{ colIndex: 0, value: 'root@' }, { colIndex: 1, value: 'Administrator' }],
[{ colIndex: 0, value: expectedUserName }, { colIndex: 1, value: 'Administrator' }],
], 5, true, null, false);
].sort(compare), 5, true, null, false);
});

it('Existing users are not suggested', () => {
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"backend:start:verifyEmail:ci": "mkdir -p ./logs && npm run backend:start:verifyEmail > ./logs/skills-service.out &",
"backend:start:oauth:ci": "mkdir -p ./logs && npm run backend:start:oauth > ./logs/skills-service.out &",
"backend:start:rabbitmq:ci": "mkdir -p ./logs && npm run backend:start:rabbitmq > ./logs/skills-service.out &",
"backend:waitToStart": "npx wait-on -t 160000 http://localhost:8080",
"backend:waitToStart": "echo \"Started waiting for skills-service at [$(date)]\" && npx wait-on -t 160000 http://localhost:8080",
"backend:resetDb": "export PGPASSWORD=skillsPassword && psql -U postgres -h $npm_package_config_dbHost -d $npm_package_config_dbName -f ./cypress/db/reset.sql",
"backend:clearDb": "export PGPASSWORD=skillsPassword && psql -U postgres -h $npm_package_config_dbHost -d $npm_package_config_dbName -f ./cypress/db/clear.sql",
"backend:setupInviteOnly": "export PGPASSWORD=skillsPassword && psql -U postgres -h $npm_package_config_dbHost -d $npm_package_config_dbName -f ./cypress/db/createInviteOnlyProject.sql",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ interface UserAttrsRepo extends CrudRepository<UserAttrs, Integer> {
@Query(value='''select attrs.email from user_attrs attrs where attrs.user_id = ?1''', nativeQuery = true)
String findEmailByUserId(String userId)

@Query("SELECT DISTINCT(ua.userIdForDisplay) from UserAttrs ua where lower(ua.userIdForDisplay) LIKE %?1% order by ua.userIdForDisplay asc" )
@Query("SELECT DISTINCT(ua.userId) from UserAttrs ua where lower(ua.userId) LIKE %?1% order by ua.userId asc" )
List<String> findDistinctUserIdForDisplay(String userUserIdForDisplayQuery, Pageable pageable)

}
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,11 @@ class SuggestUsersSpecs extends DefaultIntSpec {
// user by registering with dashboard
createService(users[1])

String user1UserIdForDisplay = userAttrsRepo.findByUserIdIgnoreCase(users[1].toLowerCase()).userIdForDisplay

when:
def allUsers = skillsService.suggestClientUsers("user")

then:
allUsers.userId == [users[0], user1UserIdForDisplay]
allUsers.userId == [users[0], users[1]].collect { it.toLowerCase() }.sort()
}
}
Loading