Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REST amDigestAuthenticated doesn't work with framework modules #49

Open
Naktibalda opened this issue Nov 1, 2015 · 4 comments
Open
Assignees

Comments

@Naktibalda
Copy link
Member

REST amDigestAuthenticated method doesn't work with framework modules.

https://github.com/Codeception/Codeception/blob/6f30eeb1032cff54ffcf99a87b01d8d6c839450b/src/Codeception/Module/REST.php#L263

public function amDigestAuthenticated($username, $password)
{
    $this->client->setAuth($username, $password, CURLAUTH_DIGEST);
}

Only Guzzle connectors have setAuth method.

@Naktibalda Naktibalda self-assigned this Nov 1, 2015
@doctorx
Copy link

doctorx commented Jul 15, 2016

Index: src/Codeception/Lib/Connector/Guzzle.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/Codeception/Lib/Connector/Guzzle.php    (revision 2e51a84355f69b8b091abdac497a21a2ebc5621c)
+++ src/Codeception/Lib/Connector/Guzzle.php    (revision f057e640435466d64a929faa69a4a9cafb8a4da5)
@@ -79,13 +79,18 @@
         unset($this->requestOptions['headers'][$name]);
     }

-    public function setAuth($username, $password)
+    /**
+     * @param string $username
+     * @param string $password
+     * @param string $type  Default: 'basic'
+     */
+    public function setAuth($username, $password, $type='basic')
     {
         if (!$username) {
             unset($this->requestOptions['auth']);
             return;
         }
-        $this->requestOptions['auth'] = [$username, $password];
+        $this->requestOptions['auth'] = [$username, $password, $type];
     }

     /**
Index: src/Codeception/Lib/Connector/Guzzle6.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/Codeception/Lib/Connector/Guzzle6.php   (revision 2e51a84355f69b8b091abdac497a21a2ebc5621c)
+++ src/Codeception/Lib/Connector/Guzzle6.php   (revision f057e640435466d64a929faa69a4a9cafb8a4da5)
@@ -82,13 +82,18 @@
         unset($this->requestOptions['headers'][$name]);
     }

-    public function setAuth($username, $password)
+    /**
+     * @param string $username
+     * @param string $password
+     * @param string $type  Default: 'basic'
+     */
+    public function setAuth($username, $password, $type='basic')
     {
         if (!$username) {
             unset($this->requestOptions['auth']);
             return;
         }
-        $this->requestOptions['auth'] = [$username, $password];
+        $this->requestOptions['auth'] = [$username, $password, $type];
     }

     /**
Index: src/Codeception/Module/REST.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/Codeception/Module/REST.php (revision 2e51a84355f69b8b091abdac497a21a2ebc5621c)
+++ src/Codeception/Module/REST.php (revision f057e640435466d64a929faa69a4a9cafb8a4da5)
@@ -295,7 +295,7 @@
      */
     public function amDigestAuthenticated($username, $password)
     {
-        $this->client->setAuth($username, $password, CURLAUTH_DIGEST);
+        $this->client->setAuth($username, $password, 'digest');
     }

     /**

@Naktibalda
Copy link
Member Author

Oh, great, it doesn't work with any module.

@Naktibalda
Copy link
Member Author

@doctorx Please make a pull request

Naktibalda referenced this issue in Naktibalda/Codeception Aug 6, 2016
DavertMik referenced this issue in Codeception/Codeception Aug 10, 2016
* Fix REST.php amDigestAuthenticated and Guzzle (#2509)

* Fix Styles (#2509)
@Naktibalda Naktibalda reopened this Oct 16, 2017
@Naktibalda
Copy link
Member Author

This issue is still valid, the fix which closed this issue was for Guzzle connectors.

@eXorus eXorus transferred this issue from Codeception/Codeception Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants