test: Implement initial tests for SamlAuthProvider model
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`SamlAuthProvider model > jsonSchema should have the correct schema 1`] = `
|
||||
{
|
||||
"properties": {
|
||||
"active": {
|
||||
"type": "boolean",
|
||||
},
|
||||
"certificate": {
|
||||
"minLength": 1,
|
||||
"type": "string",
|
||||
},
|
||||
"defaultRoleId": {
|
||||
"format": "uuid",
|
||||
"type": "string",
|
||||
},
|
||||
"emailAttributeName": {
|
||||
"minLength": 1,
|
||||
"type": "string",
|
||||
},
|
||||
"entryPoint": {
|
||||
"minLength": 1,
|
||||
"type": "string",
|
||||
},
|
||||
"firstnameAttributeName": {
|
||||
"minLength": 1,
|
||||
"type": "string",
|
||||
},
|
||||
"id": {
|
||||
"format": "uuid",
|
||||
"type": "string",
|
||||
},
|
||||
"issuer": {
|
||||
"minLength": 1,
|
||||
"type": "string",
|
||||
},
|
||||
"name": {
|
||||
"minLength": 1,
|
||||
"type": "string",
|
||||
},
|
||||
"roleAttributeName": {
|
||||
"minLength": 1,
|
||||
"type": "string",
|
||||
},
|
||||
"signatureAlgorithm": {
|
||||
"enum": [
|
||||
"sha1",
|
||||
"sha256",
|
||||
"sha512",
|
||||
],
|
||||
"type": "string",
|
||||
},
|
||||
"surnameAttributeName": {
|
||||
"minLength": 1,
|
||||
"type": "string",
|
||||
},
|
||||
},
|
||||
"required": [
|
||||
"name",
|
||||
"certificate",
|
||||
"signatureAlgorithm",
|
||||
"entryPoint",
|
||||
"issuer",
|
||||
"firstnameAttributeName",
|
||||
"surnameAttributeName",
|
||||
"emailAttributeName",
|
||||
"roleAttributeName",
|
||||
"defaultRoleId",
|
||||
],
|
||||
"type": "object",
|
||||
}
|
||||
`;
|
48
packages/backend/src/models/saml-auth-provider.ee.test.js
Normal file
48
packages/backend/src/models/saml-auth-provider.ee.test.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import SamlAuthProvider from '../models/saml-auth-provider.ee';
|
||||
import SamlAuthProvidersRoleMapping from '../models/saml-auth-providers-role-mapping.ee';
|
||||
import Identity from './identity.ee';
|
||||
import Base from './base';
|
||||
|
||||
describe('SamlAuthProvider model', () => {
|
||||
it('tableName should return correct name', () => {
|
||||
expect(SamlAuthProvider.tableName).toBe('saml_auth_providers');
|
||||
});
|
||||
|
||||
it('jsonSchema should have the correct schema', () => {
|
||||
expect(SamlAuthProvider.jsonSchema).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('relationMappings should return correct associations', () => {
|
||||
const relationMappings = SamlAuthProvider.relationMappings();
|
||||
|
||||
const expectedRelations = {
|
||||
identities: {
|
||||
relation: Base.HasOneRelation,
|
||||
modelClass: Identity,
|
||||
join: {
|
||||
from: 'identities.provider_id',
|
||||
to: 'saml_auth_providers.id',
|
||||
},
|
||||
},
|
||||
samlAuthProvidersRoleMappings: {
|
||||
relation: Base.HasManyRelation,
|
||||
modelClass: SamlAuthProvidersRoleMapping,
|
||||
join: {
|
||||
from: 'saml_auth_providers.id',
|
||||
to: 'saml_auth_providers_role_mappings.saml_auth_provider_id',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
expect(relationMappings).toStrictEqual(expectedRelations);
|
||||
});
|
||||
|
||||
it('virtualAttributes should return correct attributes', () => {
|
||||
const virtualAttributes = SamlAuthProvider.virtualAttributes;
|
||||
|
||||
const expectedAttributes = ['loginUrl', 'remoteLogoutUrl'];
|
||||
|
||||
expect(virtualAttributes).toStrictEqual(expectedAttributes);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user