forked from notaryproject/notation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support username and password prompt in login (notaryproject#566)
notaryproject#503 Added e2e tests. The current unit tests don't have RunE() testing code. Adding the unit test could lead to lots of refactoring. I'm happy to help the refactoring and start the unit tests of RunE() but I think it is better to be in a separated PR. Adding lots of unit test refactoring could mess up this PR. TODO: Seems login requires credential helper. Need to install credential helper as a test step. Signed-off-by: Ziwen Ning <[email protected]>
- Loading branch information
Showing
9 changed files
with
126 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package command | ||
|
||
import ( | ||
"fmt" | ||
|
||
. "github.com/notaryproject/notation/test/e2e/internal/notation" | ||
"github.com/notaryproject/notation/test/e2e/internal/utils" | ||
. "github.com/notaryproject/notation/test/e2e/suite/common" | ||
. "github.com/onsi/ginkgo/v2" | ||
"github.com/onsi/gomega/gbytes" | ||
) | ||
|
||
var _ = Describe("notation login", func() { | ||
BeforeEach(func() { | ||
Skip("The login tests require setting up credential helper running in host and it is not available in Github runner. Issue to remove this skip: https://github.com/notaryproject/notation/issues/587") | ||
}) | ||
It("should sign an image after successfully logging in the registry by prompt with a correct credential", func() { | ||
Host(TestLoginOptions(), func(notation *utils.ExecOpts, artifact *Artifact, vhost *utils.VirtualHost) { | ||
notation.WithInput(gbytes.BufferWithBytes([]byte(fmt.Sprintf("%s\n%s\n", TestRegistry.Username, TestRegistry.Password)))). | ||
Exec("login", artifact.Host). | ||
MatchKeyWords(LoginSuccessfully) | ||
notation.Exec("sign", artifact.ReferenceWithDigest()). | ||
MatchKeyWords(SignSuccessfully) | ||
notation.Exec("logout", artifact.Host). | ||
MatchKeyWords(LogoutSuccessfully) | ||
}) | ||
}) | ||
|
||
It("should fail to sign an image after failing to log in the registry with a wrong credential", func() { | ||
Host(TestLoginOptions(), func(notation *utils.ExecOpts, artifact *Artifact, vhost *utils.VirtualHost) { | ||
notation.WithInput(gbytes.BufferWithBytes([]byte(fmt.Sprintf("%s\n%s\n", "invalidUser", "invalidPassword")))). | ||
ExpectFailure(). | ||
Exec("login", artifact.Host). | ||
MatchErrKeyWords("unauthorized") | ||
notation.ExpectFailure(). | ||
Exec("sign", artifact.ReferenceWithDigest()). | ||
MatchErrKeyWords("credential required for basic auth") | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test/e2e/testdata/config/configjsons/pass_credential_helper_config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"credsStore": "pass" | ||
} |