Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 77 additions & 2 deletions cypress/e2e/integration/profile/create-static-cira.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,83 @@ describe('Test Profile Page', () => {
profileFixtures.happyPathStaticCIRARandomPassword.solEnabled
)
cy.get('button[type=submit]').click()
cy.get('button').contains('Continue').click()
cy.wait(300)

cy.get('button[data-cy="static-cira-alert-ok"]').click()
cy.get('button[data-cy="random-pass-ok"]').click()

// Wait for requests to finish and check them their responses
cy.wait('@post-profile').then((req) => {
cy.wrap(req)
.its('response.statusCode')
.should('eq', httpCodes.CREATED)

// Check that the config was successful
cy.get('mat-cell').contains(profileFixtures.happyPathStaticCIRARandomPassword.profileName)
cy.get('mat-cell').contains(profileFixtures.check.network.static.toString())
cy.get('mat-cell').contains(profileFixtures.check.mode.ccm)
})

// TODO: check the response to make sure that it is correct
// this is currently difficult because of the format of the response
cy.wait('@get-profiles2')
.its('response.statusCode')
.should('eq', httpCodes.SUCCESS)

// Check that the config was successful
cy.get('mat-cell').contains(profileFixtures.happyPathStaticCIRARandomPassword.profileName)
cy.get('mat-cell').contains(profileFixtures.check.network.static.toString())
cy.get('mat-cell').contains(profileFixtures.check.mode.ccm)
})

it('creates the default profile with static+cira and only random mebx password and ccm', () => {
// Stub the get and post requests
cy.myIntercept('GET', 'ciraconfigs?$count=true', {
statusCode: httpCodes.SUCCESS,
body: apiResponses.ciraConfigs.getAll.forProfile.response
}).as('get-configs')

cy.myIntercept('GET', 'wirelessconfigs?$count=true', {
statusCode: httpCodes.SUCCESS,
body: apiResponses.wirelessConfigs.getAll.forProfile.response
}).as('get-wirelessConfigs')

cy.myIntercept('POST', 'profiles', {
statusCode: httpCodes.CREATED,
body: apiResponses.profiles.create.success.response
}).as('post-profile')

cy.myIntercept('GET', 'profiles?$top=25&$skip=0&$count=true', {
statusCode: httpCodes.SUCCESS,
body: apiResponses.profiles.getAll.empty.response
}).as('get-profiles')

cy.goToPage('Profiles')
cy.wait('@get-profiles')

// change api response
cy.myIntercept('GET', 'profiles?$top=25&$skip=0&$count=true', {
statusCode: httpCodes.SUCCESS,
body: apiResponses.profiles.getAll.success.response
}).as('get-profiles2')

// Fill out the profile
cy.get('button').contains('Add New').click()
cy.wait('@get-configs')
cy.wait('@get-wirelessConfigs')
cy.enterProfileInfo(
profileFixtures.happyPathStaticCIRARandomPassword.profileName,
profileFixtures.happyPathStaticCIRARandomPassword.activation,
false,
true,
profileFixtures.happyPathStaticCIRARandomPassword.dhcpEnabled,
profileFixtures.happyPathStaticCIRARandomPassword.connectionMode,
profileFixtures.happyPathStaticCIRARandomPassword.ciraConfig,
profileFixtures.happyPathStaticCIRARandomPassword.userConsent,
profileFixtures.happyPathStaticCIRARandomPassword.iderEnabled,
profileFixtures.happyPathStaticCIRARandomPassword.kvmEnabled,
profileFixtures.happyPathStaticCIRARandomPassword.solEnabled
)
cy.get('button[type=submit]').click()
cy.get('button').contains('Continue').click()

// Wait for requests to finish and check them their responses
Expand Down
42 changes: 42 additions & 0 deletions cypress/e2e/integration/profile/create.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,46 @@ describe('Test Profile Page', () => {
cy.get('mat-cell').contains(profileFixtures.happyPath.ciraConfig)
cy.get('mat-cell').contains(profileFixtures.check.mode.ccm)
})

it('creates the default profile with only random mebx password and ccm', () => {
cy.enterProfileInfo(
profileFixtures.happyPath.profileName,
profileFixtures.happyPath.activation,
false,
true,
profileFixtures.happyPath.dhcpEnabled,
profileFixtures.happyPath.connectionMode,
profileFixtures.happyPath.ciraConfig,
profileFixtures.happyPath.userConsent,
profileFixtures.happyPath.iderEnabled,
profileFixtures.happyPath.kvmEnabled,
profileFixtures.happyPath.solEnabled
)
cy.get('button[type=submit]').click()

// Wait for requests to finish and check them their responses
cy.wait('@post-profile').then((req) => {
cy.wrap(req)
.its('response.statusCode')
.should('eq', httpCodes.CREATED)

// Check that the config was successful
cy.get('mat-cell').contains(profileFixtures.happyPath.profileName)
cy.get('mat-cell').contains(profileFixtures.check.network.dhcp.toString())
cy.get('mat-cell').contains(profileFixtures.happyPath.ciraConfig)
cy.get('mat-cell').contains(profileFixtures.check.mode.ccm)
})

// TODO: check the response to make sure that it is correct
// this is currently difficult because of the format of the response
cy.wait('@get-profiles2')
.its('response.statusCode')
.should('eq', httpCodes.SUCCESS)

// Check that the config was successful
cy.get('mat-cell').contains(profileFixtures.happyPath.profileName)
cy.get('mat-cell').contains(profileFixtures.check.network.dhcp.toString())
cy.get('mat-cell').contains(profileFixtures.happyPath.ciraConfig)
cy.get('mat-cell').contains(profileFixtures.check.mode.ccm)
})
})
4 changes: 2 additions & 2 deletions src/app/profiles/profile-detail/profile-detail.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<input [type]="amtInputType" formControlName="amtPassword" matInput name="amtPassword"
placeholder="Static AMT Password" required minlength=8 maxlength="32">
<mat-error i18n>This field is required and must be between 8 and 32 characters</mat-error>
<mat-hint>The AMT Password is used for remote access of a device.</mat-hint>
<mat-hint>The AMT Password is used for remote access of a device. It is also required for reconfiguring/deactivating the device.</mat-hint>
<button mat-icon-button matSuffix type="button" matTooltip="Show / Hide Password"
(click)="toggleAMTPassVisibility()" [disabled]='profileForm.controls.amtPassword.disabled'>
<mat-icon [fxHide]="amtInputType === 'text'">visibility</mat-icon>
Expand All @@ -82,7 +82,7 @@
<input [type]="mebxInputType" matInput formControlName="mebxPassword" placeholder="Static MEBX Password"
required minlength=8 maxlength="32">
<mat-error i18n>This field is required and must be between 8 and 32 characters</mat-error>
<mat-hint>The MEBX Password is used for protecting the BIOS access when a user is present with a device
<mat-hint>The MEBX Password is used for protecting the BIOS access when a user is present with a device. It can only be set when the activation mode is set to Admin Control Mode.
</mat-hint>
<button mat-icon-button matSuffix type="button" matTooltip="Show / Hide Password"
(click)="toggleMEBXPassVisibility()" [disabled]='profileForm.controls.mebxPassword.disabled'>
Expand Down
84 changes: 78 additions & 6 deletions src/app/profiles/profile-detail/profile-detail.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ describe('ProfileDetailComponent', () => {
// Add check for wifi config disabled or selected wifi config is 0
})

it('should submit if cira config and static network are simultaneously selected', () => {
it('should submit if cira config and static network are simultaneously selected and user confirms', () => {
const routerSpy = spyOn(component.router, 'navigate')
const dialogRefSpyObj = jasmine.createSpyObj({ afterClosed: of(true), close: null })
const dialogSpy = spyOn(TestBed.get(MatDialog), 'open').and.returnValue(dialogRefSpyObj)
Expand Down Expand Up @@ -237,7 +237,7 @@ describe('ProfileDetailComponent', () => {
expect(routerSpy).toHaveBeenCalled()
})

it('should cancel submit if cira config and static network are simultaneously selected', () => {
it('should cancel submit if cira config and static network are simultaneously selected and user cancels', () => {
const routerSpy = spyOn(component.router, 'navigate')
const dialogRefSpyObj = jasmine.createSpyObj({ afterClosed: of(false), close: null })
const dialogSpy = spyOn(TestBed.get(MatDialog), 'open').and.returnValue(dialogRefSpyObj)
Expand All @@ -262,7 +262,7 @@ describe('ProfileDetailComponent', () => {
expect(routerSpy).not.toHaveBeenCalled()
})

it('should submit if cira config and static network are simultaneously selected + randomly generated password', () => {
it('should submit if cira config and static network are simultaneously selected + randomly generated password and user confirms', () => {
const routerSpy = spyOn(component.router, 'navigate')
const dialogRefSpyObj = jasmine.createSpyObj({ afterClosed: of(true), close: null })
const dialogSpy = spyOn(TestBed.get(MatDialog), 'open').and.returnValue(dialogRefSpyObj)
Expand All @@ -287,7 +287,7 @@ describe('ProfileDetailComponent', () => {
expect(routerSpy).toHaveBeenCalled()
})

it('should cancel submit if cira config and static network are simultaneously selected + randomly generated password', () => {
it('should cancel submit if cira config and static network are simultaneously selected + randomly generated password and user cancels dialog', () => {
const routerSpy = spyOn(component.router, 'navigate')
const dialogRefSpyObj = jasmine.createSpyObj({ afterClosed: of(false), close: null })
const dialogSpy = spyOn(TestBed.get(MatDialog), 'open').and.returnValue(dialogRefSpyObj)
Expand All @@ -312,6 +312,78 @@ describe('ProfileDetailComponent', () => {
expect(routerSpy).not.toHaveBeenCalled()
})

it('should submit when valid with only random mebx password + ccm activation', () => {
const routerSpy = spyOn(component.router, 'navigate')
const dialogRefSpyObj = jasmine.createSpyObj({ afterClosed: of(true), close: null })
const dialogSpy = spyOn(TestBed.get(MatDialog), 'open').and.returnValue(dialogRefSpyObj)
component.isEdit = false
component.profileForm.patchValue({
profileName: 'profile',
activation: 'ccmactivate',
amtPassword: 'Password123',
generateRandomPassword: false,
generateRandomMEBxPassword: true,
mebxPassword: '',
dhcpEnabled: true,
ciraConfigName: null
})
component.confirm()
expect(dialogSpy).toHaveBeenCalled()
expect(dialogRefSpyObj.afterClosed).toHaveBeenCalled()
expect(profileCreateSpy).toHaveBeenCalled()
expect(routerSpy).toHaveBeenCalled()
})

it('should submit if cira config and static network are simultaneously selected + only random mebx password + ccm activation', () => {
const routerSpy = spyOn(component.router, 'navigate')
const dialogRefSpyObj = jasmine.createSpyObj({ afterClosed: of(true), close: null })
const dialogSpy = spyOn(TestBed.get(MatDialog), 'open').and.returnValue(dialogRefSpyObj)

component.isEdit = false
component.profileForm.patchValue({
profileName: 'profile',
activation: 'ccmactivate',
amtPassword: 'Password123',
generateRandomPassword: false,
generateRandomMEBxPassword: true,
mebxPassword: '',
dhcpEnabled: false,
ciraConfigName: 'config1',
tlsConfigName: null
})
component.confirm()

expect(dialogSpy).toHaveBeenCalled()
expect(dialogRefSpyObj.afterClosed).toHaveBeenCalled()
expect(profileCreateSpy).toHaveBeenCalled()
expect(routerSpy).toHaveBeenCalled()
})

it('should cancel submit if cira config and static network are simultaneously selected + only random mebx password + ccm activation', () => {
const routerSpy = spyOn(component.router, 'navigate')
const dialogRefSpyObj = jasmine.createSpyObj({ afterClosed: of(false), close: null })
const dialogSpy = spyOn(TestBed.get(MatDialog), 'open').and.returnValue(dialogRefSpyObj)

component.isEdit = false
component.profileForm.patchValue({
profileName: 'profile',
activation: 'ccmactivate',
amtPassword: 'Password123',
generateRandomPassword: false,
generateRandomMEBxPassword: true,
mebxPassword: '',
dhcpEnabled: false,
ciraConfigName: 'config1',
tlsConfigName: null
})
component.confirm()

expect(dialogSpy).toHaveBeenCalled()
expect(dialogRefSpyObj.afterClosed).toHaveBeenCalled()
expect(profileCreateSpy).not.toHaveBeenCalled()
expect(routerSpy).not.toHaveBeenCalled()
})

it('should update the selected wifi configs on selecting a wifi profile', () => {
component.selectedWifiConfigs = [{ priority: 1, profileName: 'home' }]
const option: any = {
Expand All @@ -336,11 +408,11 @@ describe('ProfileDetailComponent', () => {

it('should adjust related fields on selecting activation mode', () => {
component.activationChange(Constants.CCMActivate)
expect(component.profileForm.controls.mebxPassword.disabled).toBe(true)
expect(component.profileForm.controls.generateRandomMEBxPassword.disabled).toBe(true)
expect(component.profileForm.controls.userConsent.disabled).toBe(true)
expect(component.profileForm.controls.userConsent.value).toEqual(Constants.UserConsent_All)
component.activationChange(Constants.ACMActivate)
expect(component.profileForm.controls.mebxPassword.disabled).toBe(false)
expect(component.profileForm.controls.generateRandomMEBxPassword.disabled).toBe(false)
expect(component.profileForm.controls.userConsent.disabled).toBe(false)
})

Expand Down
Loading