Skip to content

Commit

Permalink
update frontend unit tests.
Browse files Browse the repository at this point in the history
fixes made to files where bugs found.
changed a param substitution name in resource files.

Signed-off-by: Jason Sherman <[email protected]>
  • Loading branch information
usingtechnology committed Jan 26, 2024
1 parent 77db78b commit 22a4377
Show file tree
Hide file tree
Showing 27 changed files with 205 additions and 51 deletions.
4 changes: 0 additions & 4 deletions app/frontend/src/components/base/BaseSecure.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ export default {
type: Boolean,
default: false,
},
idp: {
type: Array,
default: undefined,
},
permission: {
type: String,
default: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
"401NotAuthorized": "401: غير مصرح به. :",
"401ErrorMsg": "لم يتم إعداد حسابك بشكل صحيح.<br /> الرجاء التواصل",
"403Forbidden": "403 ممنوع. :",
"403ErrorMsg": "تتطلب هذه الصفحة مصادقة {idp}.",
"403ErrorMsg": "تتطلب هذه الصفحة مصادقة {permission}.",
"401UnAuthorized": "401: غير مصرح به. :",
"401UnAuthorizedErrMsg": "ليس لديك الصلاحية لدخول هذه الصفحة."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
"401NotAuthorized": "401: nicht autorisiert. :",
"401ErrorMsg": "Ihr Konto ist nicht richtig eingerichtet.<br /> Kontaktieren Sie bitte",
"403Forbidden": "403 Verboten. :",
"403ErrorMsg": "Diese Seite erfordert eine {idp}-Authentifizierung.",
"403ErrorMsg": "Diese Seite erfordert eine {permission}-Authentifizierung.",
"401UnAuthorized": "401 nicht Autorisiert. :",
"401UnAuthorizedErrMsg": "Sie haben keine Berechtigung, auf diese Seite zuzugreifen."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@
"401NotAuthorized": "401: not authorized. :(",
"401ErrorMsg": "Your account is not set up correctly.<br />Please contact",
"403Forbidden": "403: Forbidden. :(",
"403ErrorMsg": "This page requires {idp} authentication.",
"403ErrorMsg": "This page requires {permission} permission.",
"401UnAuthorized": "401: Unauthorized. :(",
"401UnAuthorizedErrMsg": "You do not have permission to access this page."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
"401NotAuthorized": "401: no autorizado. :",
"401ErrorMsg": "Su cuenta no está configurada correctamente.<br /> Por favor contactar",
"403Forbidden": "403: Prohibido. :",
"403ErrorMsg": "Esta página requiere autenticación {idp}.",
"403ErrorMsg": "Esta página requiere autenticación {permission}.",
"401UnAuthorized": "401: No autorizado. :",
"401UnAuthorizedErrMsg": "Usted no tiene permiso para acceder a esta página."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
"401NotAuthorized": "401: مجاز نیست. :",
"401ErrorMsg": "حساب شما به درستی تنظیم نشده است.<br /> لطفا تماس بگیرید",
"403Forbidden": "403: ممنوع. :",
"403ErrorMsg": "این صفحه به احراز هویت {idp} نیاز دارد.",
"403ErrorMsg": "این صفحه به احراز هویت {permission} نیاز دارد.",
"401UnAuthorized": "401: غیر مجاز. :",
"401UnAuthorizedErrMsg": "شما اجازه دسترسی به این صفحه را ندارید."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
"401NotAuthorized": "401 : non autorisé. :",
"401ErrorMsg": "Votre compte n&#39;est pas configuré correctement.<br /> S&#39;il vous plaît contactez",
"403Forbidden": "403 : Interdit. :",
"403ErrorMsg": "Cette page nécessite une authentification {idp}.",
"403ErrorMsg": "Cette page nécessite une authentification {permission}.",
"401UnAuthorized": "401 : non autorisé. :",
"401UnAuthorizedErrMsg": "Vous n'avez pas la permission d'accéder à cette page."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
"401NotAuthorized": "401: अधिकृत नहीं. :",
"401ErrorMsg": "आपका खाता ठीक से सेट नहीं है.<br /> कृपया संपर्क करें",
"403Forbidden": "403 निषिद्ध। :",
"403ErrorMsg": "इस पृष्ठ को {idp} प्रमाणीकरण की आवश्यकता है।",
"403ErrorMsg": "इस पृष्ठ को {permission} प्रमाणीकरण की आवश्यकता है।",
"401UnAuthorized": "अनधिकृत 401। :",
"401UnAuthorizedErrMsg": "आपको इस पेज को एक्सेस करने की अनुमति नहीं है।"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
"401NotAuthorized": "401: non autorizzato. :",
"401ErrorMsg": "Il tuo account non è impostato correttamente.<br /> Si prega di contattare",
"403Forbidden": "403: Proibito. :",
"403ErrorMsg": "Questa pagina richiede l'autenticazione {idp}.",
"403ErrorMsg": "Questa pagina richiede l'autenticazione {permission}.",
"401UnAuthorized": "401: non autorizzato. :",
"401UnAuthorizedErrMsg": "Non sei autorizzato ad accedere a questa pagina."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
"401NotAuthorized": "401: 権限がありません。 :",
"401ErrorMsg": "アカウントが正しく設定されていません。<br />お問い合わせください",
"403Forbidden": "403禁止します。 :",
"403ErrorMsg": "このページには {idp} 認証が必要です。",
"403ErrorMsg": "このページには {permission} 認証が必要です。",
"401UnAuthorized": "401: 不正です。 :",
"401UnAuthorizedErrMsg": "このページにアクセスする権限がありません。"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
"401NotAuthorized": "401: 권한이 없습니다. :",
"401ErrorMsg": "귀하의 계정이 올바르게 설정되지 않았습니다.<br /> 연락주세요",
"403Forbidden": "403 금지. :",
"403ErrorMsg": "이 페이지는 {idp} 인증이 필요합니다.",
"403ErrorMsg": "이 페이지는 {permission} 인증이 필요합니다.",
"401UnAuthorized": "401: 권한이 없습니다. :",
"401UnAuthorizedErrMsg": "이 페이지에 액세스할 수 있는 권한이 없습니다."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
"401NotAuthorized": "401: ਅਧਿਕਾਰਤ ਨਹੀਂ। :",
"401ErrorMsg": "ਤੁਹਾਡਾ ਖਾਤਾ ਸਹੀ ਢੰਗ ਨਾਲ ਸੈੱਟਅੱਪ ਨਹੀਂ ਕੀਤਾ ਗਿਆ ਹੈ।<br /> ਕਿਰਪਾ ਕਰਕੇ ਸੰਪਰਕ ਕਰੋ",
"403Forbidden": "403: ਵਰਜਿਤ। :",
"403ErrorMsg": "ਇਸ ਪੰਨੇ ਨੂੰ {idp} ਪ੍ਰਮਾਣੀਕਰਨ ਦੀ ਲੋੜ ਹੈ।",
"403ErrorMsg": "ਇਸ ਪੰਨੇ ਨੂੰ {permission} ਪ੍ਰਮਾਣੀਕਰਨ ਦੀ ਲੋੜ ਹੈ।",
"401UnAuthorized": "401: ਅਣਅਧਿਕਾਰਤ। :",
"401UnAuthorizedErrMsg": "ਤੁਹਾਨੂੰ ਇਸ ਪੰਨੇ ਤੱਕ ਪਹੁੰਚ ਕਰਨ ਦੀ ਇਜਾਜ਼ਤ ਨਹੀਂ ਹੈ।"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
"401NotAuthorized": "401: não autorizado. :",
"401ErrorMsg": "Sua conta não está configurada corretamente.<br /> Por favor entre em contato",
"403Forbidden": "403: Proibido. :",
"403ErrorMsg": "Esta página requer autenticação {idp}.",
"403ErrorMsg": "Esta página requer autenticação {permission}.",
"401UnAuthorized": "401 não autorizado. :",
"401UnAuthorizedErrMsg": "Você não tem permissão para acessar esta página."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
"401NotAuthorized": "401: не авторизован:",
"401ErrorMsg": "Ваша учетная запись настроена неправильно.<br /> Пожалуйста свяжитесь с нами",
"403Forbidden": "403: Запрещено:",
"403ErrorMsg": "Для этой страницы требуется аутентификация {idp}.",
"403ErrorMsg": "Для этой страницы требуется аутентификация {permission}.",
"401UnAuthorized": "401: Неавторизованный. :",
"401UnAuthorizedErrMsg": "Вы не имеете доступа к этой странице."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
"401NotAuthorized": "401: hindi awtorisado. :",
"401ErrorMsg": "Ang iyong account ay hindi na-set up nang tama.<br /> Mangyaring makipag-ugnayan",
"403Forbidden": "403 Ipinagbabawal. :",
"403ErrorMsg": "Nangangailangan ang page na ito ng {idp} authentication.",
"403ErrorMsg": "Nangangailangan ang page na ito ng {permission} authentication.",
"401UnAuthorized": "401: Hindi awtorisado. :",
"401UnAuthorizedErrMsg": "Wala kang pahintulot na i-access ang pahinang ito."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
"401NotAuthorized": "401: не авторизовано. :",
"401ErrorMsg": "Ваш обліковий запис налаштовано неправильно.<br /> Будь ласка зв&#39;яжіться",
"403Forbidden": "403 Заборонено. :",
"403ErrorMsg": "Для цієї сторінки потрібна автентифікація {idp}.",
"403ErrorMsg": "Для цієї сторінки потрібна автентифікація {permission}.",
"401UnAuthorized": "401: неавторизовано. :",
"401UnAuthorizedErrMsg": "Ви не маєте дозволу на доступ до цієї сторінки."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
"401NotAuthorized": "401: không được ủy quyền. :",
"401ErrorMsg": "Tài khoản của bạn không được thiết lập chính xác.<br /> Vui lòng liên hệ",
"403Forbidden": "403: Cấm. :",
"403ErrorMsg": "Trang này yêu cầu xác thực {idp}.",
"403ErrorMsg": "Trang này yêu cầu xác thực {permission}.",
"401UnAuthorized": "401: Trái phép. :",
"401UnAuthorizedErrMsg": "Bạn không có quyền truy cập trang này."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
"401NotAuthorized": "401:未授权。 :",
"401ErrorMsg": "您的帐户设置不正确。<br />请联系",
"403Forbidden": "403:禁止。 :",
"403ErrorMsg": "此页面需要 {idp} 身份验证。",
"403ErrorMsg": "此页面需要 {permission} 身份验证。",
"401UnAuthorized": "401:未经授权。 :",
"401UnAuthorizedErrMsg": "您没有权限访问此页面。"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
"401NotAuthorized": "401:未授權。 :",
"401ErrorMsg": "您的帳戶設置不正確。<br />請聯繫",
"403Forbidden": "403:禁止。 :",
"403ErrorMsg": "此頁面需要 {idp} 身份驗證。",
"403ErrorMsg": "此頁面需要 {permission} 身份驗證。",
"401UnAuthorized": "401:未經授權。 :",
"401UnAuthorizedErrMsg": "您沒有權限訪問此頁面。"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ import { vi } from 'vitest';
import getRouter from '~/router';
import BaseAuthButton from '~/components/base/BaseAuthButton.vue';
import { useAuthStore } from '~/store/auth';
import { useIdpStore } from '~/store/identityProviders';

describe('BaseAuthButton.vue', () => {
const pinia = createPinia();
setActivePinia(pinia);
const authStore = useAuthStore();
const idpStore = useIdpStore();
const router = getRouter();
const windowReplaceSpy = vi.spyOn(window.location, 'replace');
idpStore.providers = require('../../fixtures/identityProviders.json');

beforeEach(async () => {
windowReplaceSpy.mockReset();
Expand Down Expand Up @@ -95,7 +98,7 @@ describe('BaseAuthButton.vue', () => {
expect(replace).toHaveBeenCalledTimes(1);
expect(replace).toHaveBeenCalledWith({
name: 'Login',
query: { idpHint: ['idir', 'bceid-business', 'bceid-basic'] },
query: { idpHint: idpStore.loginIdpHints },
});
});

Expand Down
15 changes: 14 additions & 1 deletion app/frontend/tests/unit/components/base/BaseSecure.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { expect, vi } from 'vitest';
import getRouter from '~/router';
import BaseSecure from '~/components/base/BaseSecure.vue';
import { useAuthStore } from '~/store/auth';
import { useIdpStore } from '~/store/identityProviders';
import { AppPermissions } from '~/utils/constants';

describe('BaseSecure.vue', () => {
const pinia = createPinia();
Expand All @@ -19,6 +21,12 @@ describe('BaseSecure.vue', () => {

setActivePinia(pinia);
const authStore = useAuthStore();
const idpStore = useIdpStore();

idpStore.providers = require('../../fixtures/identityProviders.json');
const nonPrimaryIdp = idpStore.providers.find(
(x) => x.active && x.login && !x.primary
);

it('renders nothing if authenticated, user', () => {
authStore.authenticated = true;
Expand All @@ -30,6 +38,7 @@ describe('BaseSecure.vue', () => {
roles: ['user'],
},
},
identity_provider: nonPrimaryIdp.code,
},
};
const wrapper = mount(BaseSecure, {
Expand All @@ -51,6 +60,7 @@ describe('BaseSecure.vue', () => {
roles: [],
},
},
identity_provider: nonPrimaryIdp.code,
},
};
const wrapper = mount(BaseSecure, {
Expand All @@ -71,6 +81,7 @@ describe('BaseSecure.vue', () => {
chefs: {
roles: ['user'],
},
identity_provider: nonPrimaryIdp.code,
},
},
};
Expand All @@ -96,6 +107,7 @@ describe('BaseSecure.vue', () => {
roles: ['user'],
},
},
identity_provider: nonPrimaryIdp.code,
},
};
const wrapper = mount(BaseSecure, {
Expand Down Expand Up @@ -170,13 +182,14 @@ describe('BaseSecure.vue', () => {
chefs: {
roles: ['user'],
},
identity_provider: nonPrimaryIdp.code,
},
},
};
const wrapper = mount(BaseSecure, {
props: {
admin: false,
idp: ['IDIR'],
permission: AppPermissions.VIEWS_ADMIN,
},
global: {
plugins: [router, pinia],
Expand Down
9 changes: 7 additions & 2 deletions app/frontend/tests/unit/components/bcgov/BCGovNavBar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { VApp } from 'vuetify/components';
import BCGovNavBar from '~/components/bcgov/BCGovNavBar.vue';
import getRouter from '~/router';
import { useAuthStore } from '~/store/auth';
import { useIdpStore } from '~/store/identityProviders';

describe('BCGovNavBar.vue', () => {
const pinia = createPinia();
Expand All @@ -17,12 +18,16 @@ describe('BCGovNavBar.vue', () => {
history: createWebHistory(),
routes: getRouter().getRoutes(),
});
const idpStore = useIdpStore();

idpStore.providers = require('../../fixtures/identityProviders');
const primaryIdp = idpStore.primaryIdp;

it('renders as non-admin', async () => {
const authStore = useAuthStore();
authStore.keycloak = {
tokenParsed: {
identity_provider: 'idir',
identity_provider: primaryIdp.code,
resource_access: {
chefs: {
roles: [],
Expand Down Expand Up @@ -64,7 +69,7 @@ describe('BCGovNavBar.vue', () => {
const authStore = useAuthStore();
authStore.keycloak = {
tokenParsed: {
identity_provider: 'idir',
identity_provider: primaryIdp.code,
resource_access: {
chefs: {
roles: ['admin'],
Expand Down
Loading

0 comments on commit 22a4377

Please sign in to comment.