repair ack, refactor e2e tests
This commit is contained in:
1 parent
9e5357eaa8
commit
88a0b5f1b9
42 files changed
+1732
-792
No files matched your search
+13
-7
@@ -267,10 +267,10 @@ func newRequestID() string {
|
||||
return fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:16])
|
||||
}
|
||||
|
||||
func RefreshAccessToken(client *http.Client, cookieHeader, deviceID string) (string, error) {
|
||||
func RefreshAccessToken(client *http.Client, cookieHeader, deviceID string) (string, map[string]string, error) {
|
||||
req, err := http.NewRequest(http.MethodPost, "https://auth-stream.wb.ru/v2/auth/slide-v3", bytes.NewReader(nil))
|
||||
if err != nil {
|
||||
return "", err
|
||||
return "", nil, err
|
||||
}
|
||||
if deviceID == "" {
|
||||
deviceID = newRequestID()
|
||||
@@ -289,21 +289,27 @@ func RefreshAccessToken(client *http.Client, cookieHeader, deviceID string) (str
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return "", nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
rotated := make(map[string]string)
|
||||
for _, ck := range resp.Cookies() {
|
||||
if ck.Value != "" {
|
||||
rotated[ck.Name] = ck.Value
|
||||
}
|
||||
}
|
||||
raw, _ := io.ReadAll(resp.Body)
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return "", fmt.Errorf("slide-v3: status %d: %s", resp.StatusCode, string(raw))
|
||||
return "", nil, fmt.Errorf("slide-v3: status %d: %s", resp.StatusCode, string(raw))
|
||||
}
|
||||
var r slideV3Response
|
||||
if err := json.Unmarshal(raw, &r); err != nil {
|
||||
return "", fmt.Errorf("slide-v3 decode: %w", err)
|
||||
return "", nil, fmt.Errorf("slide-v3 decode: %w", err)
|
||||
}
|
||||
if r.Payload.AccessToken == "" {
|
||||
return "", fmt.Errorf("slide-v3: empty access_token in response: %s", string(raw))
|
||||
return "", nil, fmt.Errorf("slide-v3: empty access_token in response: %s", string(raw))
|
||||
}
|
||||
return r.Payload.AccessToken, nil
|
||||
return r.Payload.AccessToken, rotated, nil
|
||||
}
|
||||
|
||||
func joinAndGetDetails(client *http.Client, accessToken, roomID, displayName string) (string, string, string, string, error) {
|
||||
|
||||
Reference in new issue
Block a user