Skip to content

Commit

Permalink
Merge branch 'azdo-pipelines' of https://github.com/jananivMS/azure-s…
Browse files Browse the repository at this point in the history
…ervice-operator into azdo-pipelines
  • Loading branch information
jananivMS committed May 14, 2020
2 parents 80eb224 + f550047 commit 394a63c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test-integration-controllers: generate fmt vet manifests
test-integration-managers: generate fmt vet manifests
TEST_USE_EXISTING_CLUSTER=true TEST_CONTROLLER_WITH_MOCKS=false REQUEUE_AFTER=20 \
go test -v -coverprofile=reports/integration-managers-coverage-ouput.txt -coverpkg=./... -covermode count -parallel 4 -timeout 45m \
./api/... \
./api/... \
./pkg/resourcemanager/eventhubs/... \
./pkg/resourcemanager/resourcegroups/... \
./pkg/resourcemanager/storages/... \
Expand Down
57 changes: 57 additions & 0 deletions pkg/helpers/helpers_strings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,60 @@ func TestDecodingFromBase64EncodedString(t *testing.T) {
t.Errorf("Test output string '%s' is not as expected: '%s'.", testOutput2, expectedOutput2)
}
}

func TestNewPasswordLengthCheck(t *testing.T) {
expectedOutput := passwordLength
testOutput := len(NewPassword())

if testOutput != expectedOutput {
t.Errorf("Test output password length %d is not as expected: %d. ", testOutput, expectedOutput)
}
}

func TestNewPasswordGenerateRule(t *testing.T) {
// To verify the generated password must contain at least one caracter from
// upperAlpha, lowerAlpha and number
expectedOutput1 := 1
expectedOutput2 := 1
expectedOutput3 := 1

testOutput1 := 0
testOutput2 := 0
testOutput3 := 0
testPassword := NewPassword()

for _, p := range testPassword {

switch {
case unicode.IsLower(p):
testOutput1++
case unicode.IsUpper(p):
testOutput2++
case unicode.IsNumber(p):
testOutput3++

}
}

if testOutput1 < expectedOutput1 {
t.Errorf("Test password '%s' doesnot contain any lower alphabet! ", testPassword)
}

if testOutput2 < expectedOutput2 {
t.Errorf("Test password '%s' doesnot contain any upper alphabet! ", testPassword)
}

if testOutput3 < expectedOutput3 {
t.Errorf("Test password '%s' doesnot contain any number! ", testPassword)
}

}

func TestNewPasswordCheckRandom(t *testing.T) {
testPassword1 := NewPassword()
testPassword2 := NewPassword()

if testPassword1 == testPassword2 {
t.Errorf("The two random passwords '%s' and '%s' are the same!", testPassword1, testPassword2)
}
}

0 comments on commit 394a63c

Please sign in to comment.