Skip to content

Commit 83e32b4

Browse files
committed
feat: hide CIRA in profile when disabled on the server
1 parent d0266d3 commit 83e32b4

2 files changed

Lines changed: 69 additions & 27 deletions

File tree

src/app/profiles/profile-detail/profile-detail.component.html

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@
320320
<mat-error>{{ 'profileDetail.connectionModeRequired.value' | translate }}</mat-error>
321321
</p>
322322
}
323+
@if (ciraEnabled()) {
323324
<fieldset>
324325
<legend>{{ 'profileDetail.internetModeLegend.value' | translate }}</legend>
325326
<p>{{ 'profileDetail.internetModeDescription.value' | translate }}</p>
@@ -337,35 +338,23 @@
337338
</mat-radio-button>
338339
</p>
339340
@if (profileForm.get('connectionMode')?.value === 'CIRA') {
340-
@if (ciraEnabled()) {
341-
<mat-form-field class="flex flex-1">
342-
<mat-label>{{ 'profileDetail.ciraConfiguration.value' | translate }}</mat-label>
343-
<mat-select formControlName="ciraConfigName">
344-
@for (cc of ciraConfigurations(); track cc) {
345-
<mat-option [value]="cc.configName">{{ cc.configName }} </mat-option>
346-
}
347-
</mat-select>
348-
<mat-hint>
349-
@if (profileForm.get('ciraConfigName')?.value === null) {
350-
<span>{{ 'profileDetail.noConfigSelected.value' | translate }}</span>
351-
}
352-
{{ 'profileDetail.ciraConfigHint.value' | translate }}
353-
</mat-hint>
354-
</mat-form-field>
355-
} @else {
356-
<!-- CIRA disabled on this server but the profile still references a CIRA config.
357-
Show it read-only with a warning and let the user switch to TLS/Direct. -->
358-
<p class="error-messages-container">
359-
<mat-icon color="warn">warning</mat-icon>
360-
<span class="error-messages">{{ 'profileDetail.ciraDisabledWarning.value' | translate }}</span>
361-
</p>
362-
<mat-form-field class="flex flex-1">
363-
<mat-label>{{ 'profileDetail.ciraConfiguration.value' | translate }}</mat-label>
364-
<input matInput formControlName="ciraConfigName" readonly />
365-
</mat-form-field>
366-
}
341+
<mat-form-field class="flex flex-1">
342+
<mat-label>{{ 'profileDetail.ciraConfiguration.value' | translate }}</mat-label>
343+
<mat-select formControlName="ciraConfigName">
344+
@for (cc of ciraConfigurations(); track cc) {
345+
<mat-option [value]="cc.configName">{{ cc.configName }} </mat-option>
346+
}
347+
</mat-select>
348+
<mat-hint>
349+
@if (profileForm.get('ciraConfigName')?.value === null) {
350+
<span>{{ 'profileDetail.noConfigSelected.value' | translate }}</span>
351+
}
352+
{{ 'profileDetail.ciraConfigHint.value' | translate }}
353+
</mat-hint>
354+
</mat-form-field>
367355
}
368356
</fieldset>
357+
}
369358
<fieldset>
370359
<legend>{{ 'profileDetail.directConnectLegend.value' | translate }}</legend>
371360
<p>

src/app/profiles/profile-detail/profile-detail.component.spec.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { provideHttpClientTesting } from '@angular/common/http/testing'
2727
import { provideTranslateHttpLoader, TRANSLATE_HTTP_LOADER_CONFIG } from '@ngx-translate/http-loader'
2828

2929
describe('ProfileDetailComponent', () => {
30+
const defaultCloudMode = environment.cloud
3031
let component: ProfileDetailComponent
3132
let fixture: ComponentFixture<ProfileDetailComponent>
3233
let profileSpy: jasmine.Spy
@@ -148,6 +149,7 @@ describe('ProfileDetailComponent', () => {
148149
})
149150

150151
afterEach(() => {
152+
environment.cloud = defaultCloudMode
151153
TestBed.resetTestingModule()
152154
})
153155

@@ -166,6 +168,14 @@ describe('ProfileDetailComponent', () => {
166168
component.getAmtProfile('profile')
167169
}
168170

171+
const recreateComponent = (): void => {
172+
fixture = TestBed.createComponent(ProfileDetailComponent)
173+
component = fixture.componentInstance
174+
translate = TestBed.inject(TranslateService)
175+
translate.setFallbackLang('en')
176+
fixture.detectChanges()
177+
}
178+
169179
it('should create', () => {
170180
expect(component).toBeTruthy()
171181
expect(ciraGetDataSpy).toHaveBeenCalled()
@@ -174,6 +184,49 @@ describe('ProfileDetailComponent', () => {
174184
expect(wirelessGetDataSpy).toHaveBeenCalled()
175185
expect(proxyGetDataSpy).toHaveBeenCalled()
176186
})
187+
188+
it('should hide CIRA option and skip CIRA config fetch when enterprise has CIRA disabled', () => {
189+
environment.cloud = false
190+
serverFeaturesGetFeaturesSpy.and.returnValue(of({ ciraEnabled: false }))
191+
serverFeaturesGetFeaturesSpy.calls.reset()
192+
ciraGetDataSpy.calls.reset()
193+
194+
recreateComponent()
195+
196+
expect(serverFeaturesGetFeaturesSpy).toHaveBeenCalled()
197+
expect(ciraGetDataSpy).not.toHaveBeenCalled()
198+
expect(component.ciraEnabled()).toBeFalse()
199+
expect(fixture.nativeElement.querySelector('[data-cy="radio-cira"]')).toBeNull()
200+
})
201+
202+
it('should show CIRA option and fetch CIRA configs when enterprise has CIRA enabled', () => {
203+
environment.cloud = false
204+
serverFeaturesGetFeaturesSpy.and.returnValue(of({ ciraEnabled: true }))
205+
serverFeaturesGetFeaturesSpy.calls.reset()
206+
ciraGetDataSpy.calls.reset()
207+
208+
recreateComponent()
209+
210+
expect(serverFeaturesGetFeaturesSpy).toHaveBeenCalled()
211+
expect(ciraGetDataSpy).toHaveBeenCalled()
212+
expect(component.ciraEnabled()).toBeTrue()
213+
expect(fixture.nativeElement.querySelector('[data-cy="radio-cira"]')).not.toBeNull()
214+
})
215+
216+
it('should fail open for enterprise CIRA features API errors', () => {
217+
environment.cloud = false
218+
serverFeaturesGetFeaturesSpy.and.returnValue(throwError(() => new Error('features call failed')))
219+
serverFeaturesGetFeaturesSpy.calls.reset()
220+
ciraGetDataSpy.calls.reset()
221+
222+
recreateComponent()
223+
224+
expect(serverFeaturesGetFeaturesSpy).toHaveBeenCalled()
225+
expect(ciraGetDataSpy).toHaveBeenCalled()
226+
expect(component.ciraEnabled()).toBeTrue()
227+
expect(fixture.nativeElement.querySelector('[data-cy="radio-cira"]')).not.toBeNull()
228+
})
229+
177230
it('should set connectionMode to TLS when tlsMode is a TLS mode (1-4)', () => {
178231
const profile: Profile = { tlsMode: 4, ciraConfigName: 'config1' } as any
179232
component.setConnectionMode(profile)

0 commit comments

Comments
 (0)