@@ -37,7 +37,8 @@ function renderComponent(
3737 grpcDefaultPort = 4317 ,
3838 httpDefaultPort = 4318 ,
3939 initialGrpcEnabled = true ,
40- initialHttpEnabled = false
40+ initialHttpEnabled = false ,
41+ mayCreatePassword = true
4142) {
4243 const grpcEnabled = ref < boolean > ( initialGrpcEnabled )
4344 const httpEnabled = ref < boolean > ( initialHttpEnabled )
@@ -89,9 +90,10 @@ function renderComponent(
8990 encryptionAllowed,
9091 eventConsoleAllowed,
9192 grpcDefaultPort,
92- httpDefaultPort
93+ httpDefaultPort,
94+ mayCreatePassword
9395 } ) ,
94- template : `<ConfigureCollector ref="compRef" :no-auth-allowed="noAuthAllowed" :endpoint-config-allowed="endpointConfigAllowed" :encryption-allowed="encryptionAllowed" :event-console-allowed="eventConsoleAllowed" :grpc-default-port="grpcDefaultPort" :http-default-port="httpDefaultPort" v-model:grpc-enabled="grpcEnabled" v-model:http-enabled="httpEnabled" v-model:grpc-auth="grpcAuth" v-model:http-auth="httpAuth" v-model:grpc-endpoint="grpcEndpoint" v-model:http-endpoint="httpEndpoint" v-model:grpc-encryption="grpcEncryption" v-model:http-encryption="httpEncryption" v-model:grpc-event-console="grpcEventConsole" v-model:http-event-console="httpEventConsole" v-model:pending-passwords="pendingPasswords" v-model:available-passwords="availablePasswords" />`
96+ template : `<ConfigureCollector ref="compRef" :no-auth-allowed="noAuthAllowed" :endpoint-config-allowed="endpointConfigAllowed" :encryption-allowed="encryptionAllowed" :event-console-allowed="eventConsoleAllowed" :may-create-password="mayCreatePassword" : grpc-default-port="grpcDefaultPort" :http-default-port="httpDefaultPort" v-model:grpc-enabled="grpcEnabled" v-model:http-enabled="httpEnabled" v-model:grpc-auth="grpcAuth" v-model:http-auth="httpAuth" v-model:grpc-endpoint="grpcEndpoint" v-model:http-endpoint="httpEndpoint" v-model:grpc-encryption="grpcEncryption" v-model:http-encryption="httpEncryption" v-model:grpc-event-console="grpcEventConsole" v-model:http-event-console="httpEventConsole" v-model:pending-passwords="pendingPasswords" v-model:available-passwords="availablePasswords" />`
9597 } )
9698 )
9799
@@ -766,6 +768,29 @@ describe('ConfigureCollector', () => {
766768 } )
767769 } )
768770
771+ describe ( 'password creation permission' , ( ) => {
772+ test ( 'Create button is enabled and no hint is shown when password creation is allowed' , async ( ) => {
773+ mockPasswordsResponse ( )
774+ // noAuthAllowed=false makes basicauth the default, so the Create button is rendered
775+ renderComponent ( false , true , true , true , 4317 , 4318 , true , false , true )
776+
777+ const createButton = await screen . findByRole ( 'button' , { name : 'Create' } )
778+ expect ( createButton ) . toBeEnabled ( )
779+ expect (
780+ screen . queryByLabelText ( 'Why is creating a password unavailable?' )
781+ ) . not . toBeInTheDocument ( )
782+ } )
783+
784+ test ( 'Create button is disabled and a hint is shown when password creation is not allowed' , async ( ) => {
785+ mockPasswordsResponse ( )
786+ renderComponent ( false , true , true , true , 4317 , 4318 , true , false , false )
787+
788+ const createButton = await screen . findByRole ( 'button' , { name : 'Create' } )
789+ expect ( createButton ) . toBeDisabled ( )
790+ expect ( screen . getByLabelText ( 'Why is creating a password unavailable?' ) ) . toBeInTheDocument ( )
791+ } )
792+ } )
793+
769794 describe ( 'enabled/disabled tab behaviour' , ( ) => {
770795 test ( 'validate() returns false when both tabs are disabled' , async ( ) => {
771796 mockPasswordsResponse ( )
0 commit comments