});
it('should test unmanaged', () => {
- formHelper.setValue('service_type', 'rgw');
+ formHelper.setValue('service_type', 'mgr');
+ formHelper.setValue('service_id', 'svc');
formHelper.setValue('placement', 'label');
formHelper.setValue('label', 'bar');
- formHelper.setValue('rgw_frontend_port', 4567);
formHelper.setValue('unmanaged', true);
component.onSubmit();
expect(cephServiceService.create).toHaveBeenCalledWith({
- service_type: 'rgw',
+ service_type: 'mgr',
+ service_id: 'svc',
placement: {},
unmanaged: true
});
describe('should test service rgw', () => {
beforeEach(() => {
formHelper.setValue('service_type', 'rgw');
+ formHelper.setValue('service_id', 'svc');
});
it('should test rgw valid service id', () => {
- formHelper.setValue('service_id', 'foo.bar');
+ formHelper.setValue('service_id', 'svc.realm.zone');
formHelper.expectValid('service_id');
- formHelper.setValue('service_id', 'foo.bar.bas');
+ formHelper.setValue('service_id', 'svc');
formHelper.expectValid('service_id');
});
it('should test rgw invalid service id', () => {
- formHelper.setValue('service_id', 'foo');
+ formHelper.setValue('service_id', '.');
+ formHelper.expectError('service_id', 'rgwPattern');
+ formHelper.setValue('service_id', 'svc.');
+ formHelper.expectError('service_id', 'rgwPattern');
+ formHelper.setValue('service_id', 'svc.realm');
formHelper.expectError('service_id', 'rgwPattern');
- formHelper.setValue('service_id', 'foo.');
+ formHelper.setValue('service_id', 'svc.realm.');
formHelper.expectError('service_id', 'rgwPattern');
- formHelper.setValue('service_id', 'foo.bar.');
+ formHelper.setValue('service_id', '.svc.realm');
formHelper.expectError('service_id', 'rgwPattern');
- formHelper.setValue('service_id', 'foo.bar.bas.');
+ formHelper.setValue('service_id', 'svc.realm.zone.');
formHelper.expectError('service_id', 'rgwPattern');
});
- it('should submit rgw with port', () => {
+ it('should submit rgw with realm and zone', () => {
+ formHelper.setValue('service_id', 'svc.my-realm.my-zone');
+ component.onSubmit();
+ expect(cephServiceService.create).toHaveBeenCalledWith({
+ service_type: 'rgw',
+ service_id: 'svc',
+ rgw_realm: 'my-realm',
+ rgw_zone: 'my-zone',
+ placement: {},
+ unmanaged: false,
+ ssl: false
+ });
+ });
+
+ it('should submit rgw with port and ssl enabled', () => {
formHelper.setValue('rgw_frontend_port', 1234);
formHelper.setValue('ssl', true);
component.onSubmit();
expect(cephServiceService.create).toHaveBeenCalledWith({
service_type: 'rgw',
+ service_id: 'svc',
placement: {},
unmanaged: false,
rgw_frontend_port: 1234,
component.onSubmit();
expect(cephServiceService.create).toHaveBeenCalledWith({
service_type: 'rgw',
+ service_id: 'svc',
placement: {},
unmanaged: false,
ssl: false
styleUrls: ['./service-form.component.scss']
})
export class ServiceFormComponent extends CdForm implements OnInit {
+ readonly RGW_SVC_ID_PATTERN = /^([^.]+)(\.([^.]+)\.([^.]+))?$/;
@ViewChild(NgbTypeahead, { static: false })
typeahead: NgbTypeahead;
if (_.isEmpty(value)) {
return false;
}
- return !/^[^.]+\.[^.]+(\.[^.]+)?$/.test(value);
+ return !this.RGW_SVC_ID_PATTERN.test(value);
})
]
)
onSubmit() {
const self = this;
const values: object = this.serviceForm.value;
- const serviceId: string = values['service_id'];
const serviceType: string = values['service_type'];
const serviceSpec: object = {
service_type: serviceType,
placement: {},
unmanaged: values['unmanaged']
};
+ let svcId: string;
+ if (serviceType === 'rgw') {
+ const svcIdMatch = values['service_id'].match(this.RGW_SVC_ID_PATTERN);
+ svcId = svcIdMatch[1];
+ if (svcIdMatch[3]) {
+ serviceSpec['rgw_realm'] = svcIdMatch[3];
+ serviceSpec['rgw_zone'] = svcIdMatch[4];
+ }
+ } else {
+ svcId = values['service_id'];
+ }
+ const serviceId: string = svcId;
let serviceName: string = serviceType;
if (_.isString(serviceId) && !_.isEmpty(serviceId)) {
serviceName = `${serviceType}.${serviceId}`;