-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
872 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
ui/src/app/metadata/domain/attribute/CustomAttributeDefinition.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { CustomAttributeDefinition } from "./CustomAttributeDefinition"; | ||
|
||
|
||
describe('formatter', () => { | ||
it('should format the object passed for the json-schema-form', () => { | ||
expect(CustomAttributeDefinition.formatter(null)).toBeNull(); | ||
|
||
expect(CustomAttributeDefinition.formatter({ | ||
helpText: 'foo', | ||
attributeType: 'SELECTION_LIST', | ||
customAttrListDefinitions: [ | ||
'foo' | ||
], | ||
defaultValue: 'foo' | ||
})).toEqual({ | ||
helpText: 'foo', | ||
attributeType: 'SELECTION_LIST', | ||
customAttrListDefinitions: [ | ||
{ | ||
default: true, | ||
value: 'foo' | ||
} | ||
] | ||
}); | ||
|
||
expect(CustomAttributeDefinition.formatter({ | ||
attributeType: 'BOOLEAN', | ||
defaultValue: 'true' | ||
})).toEqual({ | ||
attributeType: 'BOOLEAN', | ||
defaultValueBoolean: true | ||
}); | ||
|
||
expect(CustomAttributeDefinition.formatter({ | ||
attributeType: 'STRING', | ||
defaultValue: 'true' | ||
})).toEqual({ | ||
attributeType: 'STRING', | ||
defaultValueString: 'true' | ||
}); | ||
}); | ||
}); | ||
|
||
describe('parser', () => { | ||
|
||
it('should parse the object provided to save to the server', () => { | ||
expect(CustomAttributeDefinition.parser(null)).toBeNull(); | ||
|
||
expect(CustomAttributeDefinition.parser({ | ||
attributeType: 'SELECTION_LIST', | ||
customAttrListDefinitions: [ | ||
{ | ||
default: true, | ||
value: 'foo' | ||
} | ||
] | ||
})).toEqual({ | ||
attributeType: 'SELECTION_LIST', | ||
customAttrListDefinitions: [ | ||
'foo' | ||
], | ||
defaultValue: 'foo' | ||
}); | ||
|
||
expect(CustomAttributeDefinition.parser({ | ||
attributeType: 'BOOLEAN', | ||
defaultValueBoolean: true | ||
})).toEqual({ | ||
attributeType: 'BOOLEAN', | ||
defaultValue: true | ||
}); | ||
|
||
expect(CustomAttributeDefinition.parser({ | ||
attributeType: 'STRING', | ||
defaultValueString: 'true' | ||
})).toEqual({ | ||
attributeType: 'STRING', | ||
defaultValue: 'true' | ||
}); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
ui/src/app/metadata/domain/filter/BaseFilterDefinition.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { BaseFilterDefinition } from "./BaseFilterDefinition"; | ||
|
||
describe('formatter', () => { | ||
it('should return the provided object with no changes', () => { | ||
expect(BaseFilterDefinition.formatter({})).toEqual({}); | ||
}) | ||
}); | ||
|
||
describe('parser', () => { | ||
it('should return the provided object with no changes', () => { | ||
expect(BaseFilterDefinition.parser({})).toEqual({}); | ||
}) | ||
}); | ||
|
||
describe('display', () => { | ||
it('should return the provided object with no changes', () => { | ||
expect(BaseFilterDefinition.display({})).toEqual({}); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
ui/src/app/metadata/domain/filter/EntityAttributesFilterDefinition.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import { EntityAttributesFilterWizard } from "./EntityAttributesFilterDefinition"; | ||
const addErrorMockFn = jest.fn(); | ||
|
||
const filters = [ | ||
{ | ||
resourceId: 1, | ||
name: 'foo' | ||
}, | ||
{ | ||
resourceId: 2, | ||
name: 'baz' | ||
} | ||
]; | ||
|
||
const e = { | ||
name: { addError: addErrorMockFn }, | ||
entityAttributesFilterTarget: { | ||
addError: addErrorMockFn, | ||
entityAttributesFilterTargetType: { | ||
addError: addErrorMockFn | ||
}, | ||
value: { | ||
addError: addErrorMockFn | ||
} | ||
} | ||
}; | ||
|
||
describe('validator function', () => { | ||
it('should validate against the provider names', () => { | ||
const validator = EntityAttributesFilterWizard.validator(filters, 2); | ||
const errors = validator({ | ||
name: 'foo' | ||
}, e); | ||
|
||
expect(addErrorMockFn).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('should validate against the provider names 2', () => { | ||
const validator = EntityAttributesFilterWizard.validator(filters); | ||
const errors = validator({ | ||
name: 'bar' | ||
}, e); | ||
|
||
expect(addErrorMockFn).toHaveBeenCalledTimes(0); | ||
}); | ||
|
||
it('should validate the regex target', () => { | ||
const validator = EntityAttributesFilterWizard.validator(filters, 2); | ||
const errors = validator({ | ||
name: 'baz2', | ||
entityAttributesFilterTarget: { | ||
entityAttributesFilterTargetType: 'REGEX', | ||
value: '()((*()*)(**' | ||
} | ||
}, e); | ||
|
||
expect(addErrorMockFn).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('should validate the regex target 2', () => { | ||
const validator = EntityAttributesFilterWizard.validator(filters, 2); | ||
const errors = validator({ | ||
name: 'baz2', | ||
entityAttributesFilterTarget: { | ||
entityAttributesFilterTargetType: 'REGEX', | ||
value: 'test' | ||
} | ||
}, e); | ||
|
||
expect(addErrorMockFn).toHaveBeenCalledTimes(0); | ||
}); | ||
}); | ||
|
||
describe('formatter', () => { | ||
it('should return the provided object with no changes', () => { | ||
expect(EntityAttributesFilterWizard.formatter({})).toEqual({ '@type': 'EntityAttributes' }); | ||
}) | ||
}); | ||
|
||
describe('parser', () => { | ||
it('should return the provided object with no changes', () => { | ||
expect(EntityAttributesFilterWizard.parser({})).toEqual({ | ||
relyingPartyOverrides: {} | ||
}); | ||
|
||
expect(EntityAttributesFilterWizard.parser({ | ||
relyingPartyOverrides: { | ||
foo: null | ||
} | ||
})).toEqual({ | ||
relyingPartyOverrides: {} | ||
}); | ||
}) | ||
}); | ||
|
||
describe('warnings', () => { | ||
it('should return warnings based on provided data', () => { | ||
expect(EntityAttributesFilterWizard.warnings({ | ||
relyingPartyOverrides: { | ||
signAssertion: false, | ||
dontSignResponse: true | ||
} | ||
})).toEqual({ | ||
'options': [ | ||
'message.invalid-signing' | ||
] | ||
}); | ||
}) | ||
|
||
it('should return no warnings', () => { | ||
expect(EntityAttributesFilterWizard.warnings({ | ||
relyingPartyOverrides: { | ||
signAssertion: true, | ||
dontSignResponse: true | ||
} | ||
})).toEqual({}); | ||
}) | ||
}); | ||
|
||
describe('display', () => { | ||
it('should return the provided object with no changes', () => { | ||
expect(EntityAttributesFilterWizard.display({})).toEqual({}); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.