mirror of https://github.com/docker/compose.git
Explicit message telling the user they are not logged in and need `docker login azure` first
This commit is contained in:
parent
8eb380a5a4
commit
82171eec19
|
@ -181,13 +181,17 @@ func toOAuthToken(token azureToken) oauth2.Token {
|
||||||
|
|
||||||
// NewAuthorizerFromLogin creates an authorizer based on login access token
|
// NewAuthorizerFromLogin creates an authorizer based on login access token
|
||||||
func NewAuthorizerFromLogin() (autorest.Authorizer, error) {
|
func NewAuthorizerFromLogin() (autorest.Authorizer, error) {
|
||||||
login, err := NewAzureLoginService()
|
return newAuthorizerFromLoginStorePath(getTokenStorePath())
|
||||||
|
}
|
||||||
|
|
||||||
|
func newAuthorizerFromLoginStorePath(storeTokenPath string) (autorest.Authorizer, error) {
|
||||||
|
login, err := newAzureLoginServiceFromPath(storeTokenPath, azureAPIHelper{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
oauthToken, err := login.GetValidToken()
|
oauthToken, err := login.GetValidToken()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, errors.Wrap(err, "not logged in to azure, you need to run \"docker login azure\" first")
|
||||||
}
|
}
|
||||||
|
|
||||||
token := adal.Token{
|
token := adal.Token{
|
||||||
|
|
|
@ -91,6 +91,11 @@ func (suite *LoginSuite) TestRefreshInValidToken() {
|
||||||
Expect(storedToken.Token.Expiry).To(BeTemporally(">", time.Now().Add(3500*time.Second)))
|
Expect(storedToken.Token.Expiry).To(BeTemporally(">", time.Now().Add(3500*time.Second)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *LoginSuite) TestClearErrorMessageIfNotAlreadyLoggedIn() {
|
||||||
|
_, err := newAuthorizerFromLoginStorePath(filepath.Join(suite.dir, tokenStoreFilename))
|
||||||
|
Expect(err.Error()).To(ContainSubstring("not logged in to azure, you need to run \"docker login azure\" first"))
|
||||||
|
}
|
||||||
|
|
||||||
func (suite *LoginSuite) TestDoesNotRefreshValidToken() {
|
func (suite *LoginSuite) TestDoesNotRefreshValidToken() {
|
||||||
expiryDate := time.Now().Add(1 * time.Hour)
|
expiryDate := time.Now().Add(1 * time.Hour)
|
||||||
err := suite.azureLogin.tokenStore.writeLoginInfo(TokenInfo{
|
err := suite.azureLogin.tokenStore.writeLoginInfo(TokenInfo{
|
||||||
|
|
Loading…
Reference in New Issue