This file contains hidden or 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
| class UserTest extends DrupalWebTestCase { | |
| public static function getInfo() { | |
| return array( | |
| 'name' => 'Administrator user', 'description' => 'an administrator needs to be able to access the admin menu.', | |
| 'group' => 'Drucumber', | |
| ); | |
| } public function setUp() { | |
| parent::setUp(); | |
| $user = $this->drupalCreateUser(array('administer site',)); | |
| $this->drupalLogin($user); |
This file contains hidden or 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
| func get(path string, cookie *http.Cookie) *http.Response { | |
| req, err := http.NewRequest("GET", BASE_PATH + path, nil) | |
| if err != nil { | |
| log.Fatal(err) | |
| } | |
| req.AddCookie(cookie) | |
| resp, err := http.DefaultClient.Do(req) | |
| if err != nil { |
This file contains hidden or 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
| type LoginResponse struct { | |
| SessionID string `json:"sessid"` | |
| SessionName string `json:"session_name"` | |
| } |
This file contains hidden or 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
| func login(username, password string) *http.Cookie { | |
| resp := post("user/login", fmt.Sprintf("username=%s&password=%s", url.QueryEscape(username), url.QueryEscape(password)), nil) | |
| if resp.StatusCode != http.StatusCodeOK { | |
| log.Fatal(resp.Status) | |
| } | |
| jsondata := getBody(resp) | |
| var lr LoginResponse | |
| if err := json.Unmarshal(jsondata, &lr); err != nil { | |
| log.Fatal(err) |
This file contains hidden or 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
| func getBody(resp *http.Response) []bytes { | |
| respbody, _ := ioutil.ReadAll(resp.Body) | |
| defer resp.Body.Close() | |
| return respbody | |
| } |
This file contains hidden or 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
| type BodyField struct { | |
| Format string | |
| Value string | |
| } | |
| type Node struct { | |
| Title string | |
| Body map[string][]BodyField | |
| Language string | |
| } |
This file contains hidden or 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
| func getNode(nid string, cookie *http.Cookie) (title String, body BodyField) { | |
| resp := get("node/" + nid, cookie) | |
| rawbody := getBody(resp) | |
| var node Node | |
| if err := json.Unmarshal(rawbody, &node); err != nil { | |
| log.Fatal(err) | |
| } | |
| if len(node.Body[node.Language]) > 0 { | |
| return node.Title, node.Body[node.Language][0] |
This file contains hidden or 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
| func editBody(original string) string { | |
| tmpfile, err := ioutil.TempFile(os.TempDir(), "myapp") | |
| if err != nil { | |
| log.Fatal(err) | |
| } | |
| name := tmpfile.Name() | |
| tmpfile.WriteString(msg) | |
| tmpfile.Sync() | |
| tmpfile.Close() |
This file contains hidden or 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
| func updateNode(nid string, title string, body BodyField, cookie *http.Cookie) { | |
| body.value = editBody(body.value) | |
| postdata := fmt.Sprintf("title=%s&body[und][0][summary]=&body[und][0][value]=%s&body[und][0][format]=%s", url.QueryEscape(title), url.QueryEscape(body.Value), url.QueryEscape(body.Format)) | |
| resp := post("node/" + nid, postdata, cookie, "PUT") | |
| if resp.StatusCode != http.StatusOK { | |
| log.Fatal(resp.Status) | |
| } | |
| } |
This file contains hidden or 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
| <?php | |
| define('KEXT_DELIMITER', " \t\n"); | |
| class KEXT { | |
| public $index; | |
| public $refs; | |
| public $size; | |
| public $wired; | |
| public $name; |