metal3-io / baremetal-operator

Bare metal host provisioning integration for Kubernetes
Apache License 2.0
570 stars 253 forks source link

🌱 Add unit test for LoadAuth funciton in auth.go #1774

Closed babugeet closed 4 months ago

babugeet commented 4 months ago

What this PR does / why we need it:

This PR adds unit test for LoadAuth funciton, mentioned in the issue https://github.com/metal3-io/baremetal-operator/issues/1574

Which issue(s) this PR fixes: Fixes # https://github.com/metal3-io/baremetal-operator/issues/1574

The provided test cases cover the following scenarios for the LoadAuth function:

No Authentication Directory Exists:
    Test Case: NoAuthDirectory
    Description: Tests the scenario where the ironic authentication directory does not exist. The function should return NoAuth as the authentication type without any errors.

Valid Authentication Credentials:
    Test Case: ValidAuth
    Description: Tests the scenario where the ironic directory exists with valid username and password files. The function should return HTTPBasicAuth with the correct username and password.

Empty Username File:
    Test Case: EmptyUsername
    Description: Tests the scenario where the username file is present but empty. The function should return an error indicating that the HTTP Basic Auth username is empty.

Empty Password File:
    Test Case: EmptyPassword
    Description: Tests the scenario where the password file is present but empty. The function should return an error indicating that the HTTP Basic Auth password is empty.
babugeet commented 4 months ago

/cc @lentzi90 @kashifest

metal3-io-bot commented 4 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lentzi90

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/metal3-io/baremetal-operator/blob/main/OWNERS)~~ [lentzi90] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
babugeet commented 4 months ago

@lentzi90 : commits are squashed. Pls check

kashifest commented 4 months ago

/ok-to-test @babugeet you need to fix DCO complain as well, just sign the commit with -S, check this section for reference.

babugeet commented 4 months ago

@kashifest : the DCO and the lint issues are solved. Lint issue fix have added one more commit, do i need to squash that commit

lentzi90 commented 4 months ago

Yes please squash always

kashifest commented 4 months ago

@kashifest : the DCO and the lint issues are solved. Lint issue fix have added one more commit, do i need to squash that commit

Thanks. ideally yes squashed with a proper commit message would be helpful

babugeet commented 4 months ago

@lentzi90 , @kashifest : addressed all comments. Pls check

kashifest commented 4 months ago

/hold cancel