@ -19,21 +19,21 @@ import (
func assertNavbar ( t * testing . T , doc * HTMLDoc ) {
// Only show the account page if users can change their email notifications, delete themselves, or manage credentials
if setting . Admin . UserDisabledFeatures . Contains ( setting . UserFeatureDeletion , setting . UserFeatureManageCredentials ) && ! setting . Service . EnableNotifyMail {
doc . Assert Element( t , ".menu a[href='/user/settings/account']" , false )
Assert HTML Element( t , doc , ".menu a[href='/user/settings/account']" , false )
} else {
doc . Assert Element( t , ".menu a[href='/user/settings/account']" , true )
Assert HTML Element( t , doc , ".menu a[href='/user/settings/account']" , true )
}
if setting . Admin . UserDisabledFeatures . Contains ( setting . UserFeatureManageMFA , setting . UserFeatureManageCredentials ) {
doc . Assert Element( t , ".menu a[href='/user/settings/security']" , false )
Assert HTML Element( t , doc , ".menu a[href='/user/settings/security']" , false )
} else {
doc . Assert Element( t , ".menu a[href='/user/settings/security']" , true )
Assert HTML Element( t , doc , ".menu a[href='/user/settings/security']" , true )
}
if setting . Admin . UserDisabledFeatures . Contains ( setting . UserFeatureManageSSHKeys , setting . UserFeatureManageGPGKeys ) {
doc . Assert Element( t , ".menu a[href='/user/settings/keys']" , false )
Assert HTML Element( t , doc , ".menu a[href='/user/settings/keys']" , false )
} else {
doc . Assert Element( t , ".menu a[href='/user/settings/keys']" , true )
Assert HTML Element( t , doc , ".menu a[href='/user/settings/keys']" , true )
}
}
@ -64,11 +64,11 @@ func TestUserSettingsAccount(t *testing.T) {
doc := NewHTMLParser ( t , resp . Body )
// account navbar should display
doc . Assert Element( t , ".menu a[href='/user/settings/account']" , true )
Assert HTML Element( t , doc , ".menu a[href='/user/settings/account']" , true )
doc . Assert Element( t , "#password" , true )
doc . Assert Element( t , "#email" , true )
doc . Assert Element( t , "#delete-form" , true )
Assert HTML Element( t , doc , "#password" , true )
Assert HTML Element( t , doc , "#email" , true )
Assert HTML Element( t , doc , "#delete-form" , true )
} )
t . Run ( "credentials disabled" , func ( t * testing . T ) {
@ -83,9 +83,9 @@ func TestUserSettingsAccount(t *testing.T) {
assertNavbar ( t , doc )
doc . Assert Element( t , "#password" , false )
doc . Assert Element( t , "#email" , false )
doc . Assert Element( t , "#delete-form" , true )
Assert HTML Element( t , doc , "#password" , false )
Assert HTML Element( t , doc , "#email" , false )
Assert HTML Element( t , doc , "#delete-form" , true )
} )
t . Run ( "deletion disabled" , func ( t * testing . T ) {
@ -100,9 +100,9 @@ func TestUserSettingsAccount(t *testing.T) {
assertNavbar ( t , doc )
doc . Assert Element( t , "#password" , true )
doc . Assert Element( t , "#email" , true )
doc . Assert Element( t , "#delete-form" , false )
Assert HTML Element( t , doc , "#password" , true )
Assert HTML Element( t , doc , "#email" , true )
Assert HTML Element( t , doc , "#delete-form" , false )
} )
t . Run ( "deletion, credentials and email notifications are disabled" , func ( t * testing . T ) {
@ -249,7 +249,7 @@ func TestUserSettingsSecurity(t *testing.T) {
assertNavbar ( t , doc )
doc . Assert Element( t , "#register-webauthn" , true )
Assert HTML Element( t , doc , "#register-webauthn" , true )
} )
t . Run ( "mfa disabled" , func ( t * testing . T ) {
@ -263,7 +263,7 @@ func TestUserSettingsSecurity(t *testing.T) {
assertNavbar ( t , doc )
doc . Assert Element( t , "#register-webauthn" , false )
Assert HTML Element( t , doc , "#register-webauthn" , false )
} )
t . Run ( "credentials and mfa disabled" , func ( t * testing . T ) {
@ -356,8 +356,8 @@ func TestUserSettingsKeys(t *testing.T) {
assertNavbar ( t , doc )
doc . Assert Element( t , "#add-ssh-button" , true )
doc . Assert Element( t , "#add-gpg-key-panel" , true )
Assert HTML Element( t , doc , "#add-ssh-button" , true )
Assert HTML Element( t , doc , "#add-gpg-key-panel" , true )
} )
t . Run ( "ssh keys disabled" , func ( t * testing . T ) {
@ -372,8 +372,8 @@ func TestUserSettingsKeys(t *testing.T) {
assertNavbar ( t , doc )
doc . Assert Element( t , "#add-ssh-button" , false )
doc . Assert Element( t , "#add-gpg-key-panel" , true )
Assert HTML Element( t , doc , "#add-ssh-button" , false )
Assert HTML Element( t , doc , "#add-gpg-key-panel" , true )
} )
t . Run ( "gpg keys disabled" , func ( t * testing . T ) {
@ -388,8 +388,8 @@ func TestUserSettingsKeys(t *testing.T) {
assertNavbar ( t , doc )
doc . Assert Element( t , "#add-ssh-button" , true )
doc . Assert Element( t , "#add-gpg-key-panel" , false )
Assert HTML Element( t , doc , "#add-ssh-button" , true )
Assert HTML Element( t , doc , "#add-gpg-key-panel" , false )
} )
t . Run ( "ssh & gpg keys disabled" , func ( t * testing . T ) {