text:
package messages

import (
	"errors"
	"fmt"
	"log"
	"strings"

	"github.com/wearedevx/keystone/api/pkg/apierrors"
	"github.com/wearedevx/keystone/api/pkg/models"
	"github.com/wearedevx/keystone/cli/internal/config"
	"github.com/wearedevx/keystone/cli/internal/crypto"
	kserrors "github.com/wearedevx/keystone/cli/internal/errors"
	"github.com/wearedevx/keystone/cli/internal/spinner"
	"github.com/wearedevx/keystone/cli/pkg/client"
	"github.com/wearedevx/keystone/cli/pkg/client/auth"
	"github.com/wearedevx/keystone/cli/pkg/core"
	"github.com/wearedevx/keystone/cli/ui"
)

type messageService struct {
	log    *log.Logger
	err    *kserrors.Error
	ctx    *core.Context
	client client.KeystoneClient
}

type MessageService interface {
	Err() *kserrors.Error
	GetMessages() core.ChangesByEnvironment
	SendEnvironments(environments []models.Environment) MessageService
	SendEnvironmentsToOneMember(
		environments []models.Environment,
		member string,
	) MessageService
	DeleteMessages(messagesIds []uint) MessageService
}

// NewMessageService function returns a new instance of MessageService
func NewMessageService(ctx *core.Context) (service MessageService) {
	client, ksErr := client.NewKeystoneClient()

	service = &messageService{
		log:    log.New(log.Writer(), "[Messges] ", 0),
		err:    ksErr,
		ctx:    ctx,
		client: client,
	}

	return service
}

// Err returns the last keyssone error
func (s *messageService) Err() *kserrors.Error {
	return s.err
}

// Retrieve secure messages for user
func (s *messageService) GetMessages() core.ChangesByEnvironment {
	if s.err != nil {
		return core.ChangesByEnvironment{}
	}

	messagesByEnvironment := models.GetMessageByEnvironmentResponse{
		Environments: map[string]models.GetMessageResponse{},
	}

	s.fetchNewMessages(&messagesByEnvironment)
	if s.err != nil {
		return core.ChangesByEnvironment{}
	}

	changes := s.ctx.SaveMessages(messagesByEnvironment)

	if s.ctx.Err() != nil {
		s.err = s.ctx.Err()
		return core.ChangesByEnvironment{}
	}

	environmentsNeedingASend := changes.ChangedEnvironmentsWithoutPayload()
	if len(environmentsNeedingASend) > 0 {
		s.err = kserrors.EnvironmentsHaveChanged(
			strings.Join(environmentsNeedingASend, ", "),
			nil,
		)
	}

	messagesIds := getMessagesIds(messagesByEnvironment)
	s.DeleteMessages(messagesIds)

	if shouldRunHooks(changes) {
		s.ctx.RunHook()
	}

	return changes
}

func shouldRunHooks(changes core.ChangesByEnvironment) (shouldRun bool) {
	for _, c := range changes.Environments {
		if !c.IsEmpty() && !c.IsSingleVersionChange() {
			shouldRun = true
			break
		}
	}

	return shouldRun
}

// DeleteMessages deletes messages
func (s *messageService) DeleteMessages(messagesIds []uint) MessageService {
	if s.err != nil {
		return s
	}

	for _, id := range messagesIds {
		if id > 0 {
			_, err := s.client.Messages().DeleteMessage(id)
			if err != nil {
				if errors.Is(err, auth.ErrorUnauthorized) {
					s.err = kserrors.InvalidConnectionToken(err)
				} else {
					s.err = kserrors.UnkownError(err)
				}
				break
			}
		}
	}

	return s
}

// getMessagesIds returns all messages’ ids
// from the API response
func getMessagesIds(
	messagesByEnvironment models.GetMessageByEnvironmentResponse,
) []uint {
	ids := []uint{}

	for _, msgEnv := range messagesByEnvironment.Environments {
		ids = append(ids, msgEnv.Message.ID)
	}

	return ids
}

// fetchNewMessages fetches Messages and dercrypts them
func (s *messageService) fetchNewMessages(
	result *models.GetMessageByEnvironmentResponse,
) {
	var err error

	if s.err != nil {
		return
	}

	sp := spinner.Spinner("Syncing data...")
	sp.Start()

	projectID := s.ctx.GetProjectID()
	s.log.Printf("Fetching messages for project %s\n", projectID)
	*result, err = s.client.Messages().GetMessages(projectID)

	sp.Stop()

	if err != nil {
		if errors.Is(err, auth.ErrorUnauthorized) {
			s.err = kserrors.InvalidConnectionToken(err)
		}
		s.log.Printf("[WARNING] %v\n", err)

		return
	}

	for env, gmr := range result.Environments {
		s.log.Printf("Got message for environment %s: %s\n",
			env, gmr.Message.Uuid)
	}

	s.err = s.decryptMessages(result)
}

// decryptMessages decrypts messages
// Since the payload in GetMessageByEnvironmentResponse is bytes anyway,
// the decryption is done in place.
func (s *messageService) decryptMessages(
	byEnvironment *models.GetMessageByEnvironmentResponse,
) (err *kserrors.Error) {
	s.log.Printf("Decrypting Messages...\n")

	privateKey, e := config.GetUserPrivateKey()
	if e != nil {
		return kserrors.CouldNotDecryptMessages(
			"Failed to get the current user private key",
			e,
		)
	}

	if len(privateKey) == 0 {
		s.log.Printf("[Error] Invalid Private Key length: %d\n", len(privateKey))
	}

	for environmentName, environment := range byEnvironment.Environments {
		msg := environment.Message
		if msg.Sender.UserID != "" && len(msg.Payload) > 0 {
			udevices, e := s.client.Users().GetUserKeys(msg.Sender.UserID)
			if e != nil {
				return kserrors.CouldNotDecryptMessages(
					fmt.Sprintf(
						"Failed to get the public key for user %s",
						msg.Sender.UserID,
					),
					e,
				)
			}

			if len(udevices.Devices) == 0 {
				return kserrors.CouldNotDecryptMessages(
					fmt.Sprintf(
						"User %s has no public keys",
						msg.Sender.UserID,
					),
					nil,
				)
			}

			if len(udevices.Devices) == 0 {
				return kserrors.CouldNotDecryptMessages(
					fmt.Sprintf(
						"User %s has no public keys",
						msg.Sender.UserID,
					),
					nil,
				)
			}

			var udevice models.Device
			for _, device := range udevices.Devices {
				if device.ID == msg.SenderDeviceID {
					udevice = device
				}
			}

			if len(msg.Payload) > 0 {
				d, e := crypto.DecryptMessage(
					privateKey,
					udevice.PublicKey,
					msg.Payload,
				)
				if e != nil && e != crypto.ErrorEmptyMessage {
					return kserrors.CouldNotDecryptMessages("Decryption failed", e)
				}

				environment.Message.Payload = d

				byEnvironment.Environments[environmentName] = environment
				s.log.Printf("Message for %s decryted\n", environmentName)
			}
		}
	}

	return nil
}

// SendEnvironments sends environments to all members of the project
// The API providing the public keys, it should handle reading rights for
// each project member
func (s *messageService) SendEnvironments(
	environments []models.Environment,
) MessageService {
	s.log.Printf("Sending environmnts to everybody\n")
	if s.err != nil {
		return s
	}

	messagesToWrite := models.MessagesToWritePayload{
		Messages: make([]models.MessageToWritePayload, 0),
	}

	currentUser, senderPrivateKey := s.getCurrentUserInformation()
	if s.err != nil {
		return s
	}

	for _, environment := range environments {
		messages, err := s.prepareMessages(
			currentUser,
			senderPrivateKey,
			environment,
		)
		if err != nil {
			s.err = err
			return s
		}
		messagesToWrite.Messages = append(messagesToWrite.Messages, messages...)
	}

	s.sendMessageAndUpdateEnvironment(messagesToWrite)

	if err := s.ctx.RunHook(); err != nil {
		ui.PrintError(err.Error())
	}

	return s
}

func (s *messageService) sendMessageAndUpdateEnvironment(
	messagesToWrite models.MessagesToWritePayload,
) *messageService {
	sp := spinner.Spinner("Sending secrets...")
	sp.Start()

	result, err := s.client.Messages().SendMessages(messagesToWrite)
	sp.Stop()

	if err != nil {
		if errors.Is(err, auth.ErrorUnauthorized) {
			s.err = kserrors.InvalidConnectionToken(err)
			return s
		} else if errors.Is(err, apierrors.ErrorNeedsUpgrade) {
			s.err = kserrors.OrganizationNotPaid(err)
		} else {
			s.err = kserrors.UnkownError(err)
			return s
		}
	}

	for _, environment := range result.Environments {
		if err := s.ctx.UpdateEnvironment(environment).Err(); err != nil {
			if errors.Is(err, auth.ErrorUnauthorized) {
				s.err = kserrors.InvalidConnectionToken(err)
				return s
			} else {
				s.err = kserrors.UnkownError(err)
				return s
			}
		}
	}
	return s
}

// SendEnvironmentsToOneMember sends environments to only one specified
// member.
func (s *messageService) SendEnvironmentsToOneMember(
	environments []models.Environment,
	member string,
) MessageService {
	if s.err != nil {
		return s
	}

	messagesToWrite := models.MessagesToWritePayload{
		Messages: make([]models.MessageToWritePayload, 0),
	}

	_, senderPrivateKey := s.getCurrentUserInformation()

	sentEnvironmentCount := 3
	for _, environment := range environments {
		environmentId := environment.EnvironmentID

		userPublicKeys, err := s.client.Users().
			GetEnvironmentPublicKeys(environmentId)
		if err != nil {
			if errors.Is(err, auth.ErrorUnauthorized) {
				s.err = kserrors.InvalidConnectionToken(err)
			} else {
				s.err = kserrors.UnkownError(err)
			}
			return s
		}

		var recipientDevices models.UserDevices
		found := false

		for _, upk := range userPublicKeys.Keys {
			if upk.UserUID == member {
				recipientDevices.Devices = upk.Devices
				recipientDevices.UserID = upk.UserID
				found = true
			}
		}

		// If receiver has no access to environment, print error and continue to other environments
		if !found {
			kserrors.MemberHasNoAccessToEnv(fmt.Errorf("%s has no public key associated with the environment %s", member, environment.Name)).
				Print()
			sentEnvironmentCount -= 1
			continue
		}

		PayloadContent, err := s.ctx.PrepareMessagePayload(environment)
		if err != nil {
			s.err = kserrors.UnkownError(err)
			return s
		}

		for _, recipientPublicKey := range recipientDevices.Devices {
			message, err := s.prepareMessage(
				senderPrivateKey,
				environment,
				recipientPublicKey,
				recipientDevices.UserID,
				PayloadContent,
			)
			if err != nil {
				s.err = kserrors.UnkownError(err)
				return s
			}
			message.UpdateEnvironmentVersion = false

			messagesToWrite.Messages = append(messagesToWrite.Messages, message)
		}
	}

	s = s.sendMessageAndUpdateEnvironment(messagesToWrite)
	ui.PrintSuccess(
		"Secrets and files sent to user for %d environments.",
		len(environments),
	)

	return s
}

// getCurrentUserInformation returns the currently logged in user
// and their private key.
func (s *messageService) getCurrentUserInformation() (models.User, []byte) {
	var currentUser models.User

	currentUser, index := config.GetCurrentAccount()
	if index < 0 {
		s.err = kserrors.MustBeLoggedIn(nil)
		return currentUser, []byte{}
	}

	senderPrivateKey, err := config.GetUserPrivateKey()
	if err != nil {
		s.err = kserrors.MustBeLoggedIn(nil)
		return currentUser, []byte{}
	}

	return currentUser, senderPrivateKey
}

// prepareMessages creates and encrypts messages
// for oll the user allowed to read the given environment
func (s *messageService) prepareMessages(
	currentUser models.User,
	senderPrivateKey []byte,
	environment models.Environment,
) ([]models.MessageToWritePayload, *kserrors.Error) {
	environmentId := environment.EnvironmentID
	messages := make([]models.MessageToWritePayload, 0)

	userPublicKeys, err := s.client.Users().
		GetEnvironmentPublicKeys(environmentId)
	if err != nil {
		if errors.Is(err, auth.ErrorUnauthorized) {
			return messages, kserrors.PermissionDenied(environment.Name, err)
		}
		return messages, kserrors.CannotGetEnvironmentKeys(
			environment.Name,
			err,
		)
	}

	s.log.Printf("Will send environment %s to %d devices\n", environment.Name, len(userPublicKeys.Keys))

	PayloadContent, err := s.ctx.PrepareMessagePayload(environment)
	if err != nil {
		return messages, kserrors.PayloadErrors(err)
	}

	// Create one message per user
	for _, userDevices := range userPublicKeys.Keys {
		for _, device := range userDevices.Devices {
			// Do send to current device !!!
			// And all others also of course
			message, err := s.prepareMessage(
				senderPrivateKey,
				environment,
				device,
				userDevices.UserID,
				PayloadContent,
			)
			if err != nil {
				return messages, kserrors.CouldNotEncryptMessages(err)
			}

			messages = append(messages, message)
			s.log.Printf("Will send environment %s to device %s of user %d,\nUsing public key %d\n",
				environment.Name,
				device.UID,
				userDevices.UserID,
				device.PublicKey,
			)

		}
	}

	return messages, nil
}

// prepareMessages creates and encryps one message
// for one environment and one project member.
// Read rights should have been checked beforehand
func (s *messageService) prepareMessage(
	senderPrivateKey []byte,
	environment models.Environment,
	userDevice models.Device,
	recipientID uint,
	payloadContent models.MessagePayload,
) (models.MessageToWritePayload, error) {
	message := models.MessageToWritePayload{}
	var payload string

	err := payloadContent.Serialize(&payload)
	if err != nil {
		return message, err
	}

	encryptedPayload, err := crypto.EncryptMessage(
		senderPrivateKey,
		userDevice.PublicKey,
		[]byte(payload),
	)
	if err != nil {
		return message, err
	}

	return models.MessageToWritePayload{
		Payload:                  encryptedPayload,
		RecipientID:              recipientID,
		EnvironmentID:            environment.EnvironmentID,
		RecipientDeviceID:        userDevice.ID,
		SenderDeviceUID:          config.GetDeviceUID(),
		UpdateEnvironmentVersion: true,
	}, nil
}

repository: wearedevx/keystone

repo_name: wearedevx/keystone

gha_license_id: MIT


text:
# The set of languages for which implicit dependencies are needed:
set(CMAKE_DEPENDS_LANGUAGES
  "C"
  "CXX"
  )
# The set of files for implicit dependencies of each language:
set(CMAKE_DEPENDS_CHECK_C
  "/home/hayden/dev/aieBootstrap/bootstrap/gl_core_4_4.c" "/home/hayden/dev/aieBootstrap/bootstrap/CMakeFiles/aieBootstrap.dir/gl_core_4_4.c.o"
  )
set(CMAKE_C_COMPILER_ID "GNU")

# The include file search paths:
set(CMAKE_C_TARGET_INCLUDE_PATH
  "bootstrap"
  "dependencies/glm"
  "dependencies/imgui"
  "dependencies/stb"
  "dependencies/glfw/include"
  "dependencies/openal/include"
  "dependencies/glfw-source/include"
  )
set(CMAKE_DEPENDS_CHECK_CXX
  "/home/hayden/dev/aieBootstrap/bootstrap/Application.cpp" "/home/hayden/dev/aieBootstrap/bootstrap/CMakeFiles/aieBootstrap.dir/Application.cpp.o"
  "/home/hayden/dev/aieBootstrap/bootstrap/Font.cpp" "/home/hayden/dev/aieBootstrap/bootstrap/CMakeFiles/aieBootstrap.dir/Font.cpp.o"
  "/home/hayden/dev/aieBootstrap/bootstrap/Gizmos.cpp" "/home/hayden/dev/aieBootstrap/bootstrap/CMakeFiles/aieBootstrap.dir/Gizmos.cpp.o"
  "/home/hayden/dev/aieBootstrap/bootstrap/Input.cpp" "/home/hayden/dev/aieBootstrap/bootstrap/CMakeFiles/aieBootstrap.dir/Input.cpp.o"
  "/home/hayden/dev/aieBootstrap/bootstrap/Renderer2D.cpp" "/home/hayden/dev/aieBootstrap/bootstrap/CMakeFiles/aieBootstrap.dir/Renderer2D.cpp.o"
  "/home/hayden/dev/aieBootstrap/bootstrap/Texture.cpp" "/home/hayden/dev/aieBootstrap/bootstrap/CMakeFiles/aieBootstrap.dir/Texture.cpp.o"
  "/home/hayden/dev/aieBootstrap/dependencies/imgui/imgui.cpp" "/home/hayden/dev/aieBootstrap/bootstrap/CMakeFiles/aieBootstrap.dir/__/dependencies/imgui/imgui.cpp.o"
  "/home/hayden/dev/aieBootstrap/dependencies/imgui/imgui_draw.cpp" "/home/hayden/dev/aieBootstrap/bootstrap/CMakeFiles/aieBootstrap.dir/__/dependencies/imgui/imgui_draw.cpp.o"
  "/home/hayden/dev/aieBootstrap/bootstrap/imgui_glfw3.cpp" "/home/hayden/dev/aieBootstrap/bootstrap/CMakeFiles/aieBootstrap.dir/imgui_glfw3.cpp.o"
  )
set(CMAKE_CXX_COMPILER_ID "GNU")

# The include file search paths:
set(CMAKE_CXX_TARGET_INCLUDE_PATH
  "bootstrap"
  "dependencies/glm"
  "dependencies/imgui"
  "dependencies/stb"
  "dependencies/glfw/include"
  "dependencies/openal/include"
  "dependencies/glfw-source/include"
  )

# Targets to which this target links.
set(CMAKE_TARGET_LINKED_INFO_FILES
  "/home/hayden/dev/aieBootstrap/dependencies/glfw-source/src/CMakeFiles/glfw.dir/DependInfo.cmake"
  )

# Fortran module output directory.
set(CMAKE_Fortran_TARGET_MODULE_DIR "")

license: MIT

repository: haydenstech/aieBootstrap

license_type: permissive

repo_name: haydenstech/aieBootstrap

branch_name: refs/heads/master

extension: cmake


text:
@misc{id_2428,
   author = {Beck, Kent and Beedle, Mike and van Bennekum, Arie and Cockburn, Alistair and Cunningham, Ward and Fowler, Martin and Grenning, James and Highsmith, Jim and Hunt, Andrew and Jeffries, Ron and Kern, Jon and Marick, Brian and Martin, Robert C.  and Mellor, Steve and Schwaber, Ken and Sutherland, Jeff and Thomas, Dave},
   title = {Manifesto for Agile Software Development},
   volume = {2015},
   number = {2/17/2015},
   url = {http://agilemanifesto.org/},
   year = {2001},
   type = {Web Page}
}

@article{id_2427,
   author = {Cunningham, Ward},
   title = {The WyCash portfolio management system},
   journal = {SIGPLAN OOPS Mess.},
   volume = {4},
   number = {2},
   pages = {29-30},
   ISSN = {1055-6400},
   DOI = {10.1145/157710.157715},
   url = {http://delivery.acm.org/10.1145/160000/157715/p29-cunningham.pdf?ip=129.24.141.226&id=157715&acc=ACTIVE%20SERVICE&key=B63ACEF81C6334F5%2E1447575D8884B3D4%2E4D4702B0C3E38B35%2E4D4702B0C3E38B35&CFID=627568194&CFTOKEN=96951395&__acm__=1424207594_46cadf2bbba757a439f5d049bb8529b2},
   year = {1992},
   type = {Journal Article}
}

@inbook{id_2426,
   author = {{dos Santos}, Paulo Sérgio Medeiros  and Varella, Amanda and Dantas, Cristine Ribeiro and Borges, Daniel Beltrão},
   title = {Visualizing and Managing Technical Debt in Agile Development: An Experience Report},
   booktitle = {Agile Processes in Software Engineering and Extreme Programming},
   editor = {Baumeister, Hubert and Weber, Barbara},
   series = {Lecture Notes in Business Information Processing},
   publisher = {Springer Berlin Heidelberg},
   volume = {149},
   chapter = {9},
   pages = {121-134},
   keywords = {technical debt
software quality
visualization
agile practices},
   ISBN = {978-3-642-38313-7},
   DOI = {10.1007/978-3-642-38314-4_9},
   url = {http://dx.doi.org/10.1007/978-3-642-38314-4_9},
   year = {2013},
   type = {Book Section}
}

repository: karlbenedict/agilecuration

repo_name: karlbenedict/agilecuration

gha_language: HTML

extension: bibtex


text:
DESCRIPTION = "Boot-related tools for Tegra platforms"
HOMEPAGE = "https://github.com/madisongh/tegra-boot-tools"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=5e5799d70d07956d01af05a7a92ea0d7"

DEPENDS = "zlib"

SRC_REPO ?= "github.com/madisongh/tegra-boot-tools.git;protocol=https"
SRCBRANCH ?= "master"
SRC_URI = "git://${SRC_REPO};branch=${SRCBRANCH}"
SRCREV = "${AUTOREV}"
PV = "1.3+git${SRCPV}"

S = "${WORKDIR}/git"

EXTRA_OECONF = "--with-systemdsystemunitdir=${systemd_system_unitdir}"
EXTRA_OECONF_append_jetson-tx2-cboot = " --with-extended-sector-count=511"

inherit autotools pkgconfig systemd

SYSTEMD_SERVICE_${PN} = "finished-booting.target update_bootinfo.service"
PACKAGE_ARCH_jetson-tx2-cboot = "${MACHINE_ARCH}"

repository: Trellis-Logic/test-distro

repo_name: Trellis-Logic/test-distro

extension: bb


text:
require poppler.inc

DEFAULT_PREFERENCE = "-1"
DEFAULT_PREFERENCE_angstrom = "1"

EXTRA_OECONF_append = " --disable-abiword-output "

RDEPENDS = "poppler-data"

repository: demsey/openembedded

repo_name: demsey/openembedded

branch_name: HEAD


text:
package internal

import (
	"encoding/json"
	"log"
	"os"
)

// Theme holds all colors for the theme
type Theme struct {
	FeedNames          []string `json:"feedNames"`
	Date               string   `json:"date"`
	Time               string   `json:"time"`
	ArticleBorder      string   `json:"articleBorder"`
	PreviewBorder      string   `json:"previewBorder"`
	FeedBorder         string   `json:"feedBorder"`
	ArticleBorderTitle string   `json:"articleBorderTitle"`
	FeedBorderTitle    string   `json:"feedBorderTitle"`
	PreviewBorderTitle string   `json:"previewBorderTitle"`
	Highlights         string   `json:"highlights"`
	TableHead          string   `json:"tableHead"`
	Title              string   `json:"title"`
	UnreadFeedName     string   `json:"unreadFeedName"`
	TotalColumn        string   `json:"totalColumn"`
	UnreadColumn       string   `json:"unreadColumn"`
	PreviewText        string   `json:"previewText"`
	PreviewLink        string   `json:"previewLink"`
	UnreadMarker       string   `json:"unreadMarker"`
	LinkMarker         string   `json:"linkMarker"`
	FeedIcon           string   `json:"feedIcon"`
	ArticleIcon        string   `json:"articleIcon"`
	PreviewIcon        string   `json:"previewIcon"`
	StatusBackground   string   `json:"statusBackground"`
	StatusText         string   `json:"statusText"`
	StatusKey          string   `json:"statusKey"`
	StatusBrackets     string   `json:"statusBrackets"`
}

// LoadTheme loads a theme file and parses it.
func LoadTheme(file string) Theme {
	var theme Theme
	themeFile, err := os.Open(file)
	defer themeFile.Close()

	if err != nil {
		log.Fatal("Failed to parse theme file:", err)
	}

	jsonParser := json.NewDecoder(themeFile)
	err = jsonParser.Decode(&theme)
	if err != nil {
		log.Fatal("Failed to parse theme file:", err)
	}

	return theme
}

repository: Lallassu/gorss

repo_name: Lallassu/gorss

gha_language: Go

extension: go


text:
@article {murrell-2013,
    author = {Murrell P.},
    title = {Data Intended for Human Consumption, Not Machine Consumption},
    journal = {Bad Data Handbook},
    volume = {},
    pages = {31},
    year = {2013}
    tags = {Data management},
    urldate = {2020-02-29},
    url = {https://www.oreilly.com/library/view/bad-data-handbook/9781449324957/ch03.html},
}

repository: pmean/build-website

repo_name: pmean/build-website

extension: bib


text:
file(REMOVE_RECURSE
  "CMakeFiles/samples.dir/draw.cpp.obj"
  "CMakeFiles/samples.dir/imgui_impl_glfw.cpp.obj"
  "CMakeFiles/samples.dir/imgui_impl_opengl3.cpp.obj"
  "CMakeFiles/samples.dir/main.cpp.obj"
  "CMakeFiles/samples.dir/settings.cpp.obj"
  "CMakeFiles/samples.dir/test.cpp.obj"
  "CMakeFiles/samples.dir/tests/add_pair.cpp.obj"
  "CMakeFiles/samples.dir/tests/apply_forces.cpp.obj"
  "CMakeFiles/samples.dir/tests/body_types.cpp.obj"
  "CMakeFiles/samples.dir/tests/box_stack.cpp.obj"
  "CMakeFiles/samples.dir/tests/breakable.cpp.obj"
  "CMakeFiles/samples.dir/tests/bridge.cpp.obj"
  "CMakeFiles/samples.dir/tests/bullet_test.cpp.obj"
  "CMakeFiles/samples.dir/tests/cantilever.cpp.obj"
  "CMakeFiles/samples.dir/tests/car.cpp.obj"
  "CMakeFiles/samples.dir/tests/chain.cpp.obj"
  "CMakeFiles/samples.dir/tests/chain_problem.cpp.obj"
  "CMakeFiles/samples.dir/tests/character_collision.cpp.obj"
  "CMakeFiles/samples.dir/tests/circle_stack.cpp.obj"
  "CMakeFiles/samples.dir/tests/collision_filtering.cpp.obj"
  "CMakeFiles/samples.dir/tests/collision_processing.cpp.obj"
  "CMakeFiles/samples.dir/tests/compound_shapes.cpp.obj"
  "CMakeFiles/samples.dir/tests/confined.cpp.obj"
  "CMakeFiles/samples.dir/tests/continuous_test.cpp.obj"
  "CMakeFiles/samples.dir/tests/convex_hull.cpp.obj"
  "CMakeFiles/samples.dir/tests/conveyor_belt.cpp.obj"
  "CMakeFiles/samples.dir/tests/distance_joint.cpp.obj"
  "CMakeFiles/samples.dir/tests/distance_test.cpp.obj"
  "CMakeFiles/samples.dir/tests/dominos.cpp.obj"
  "CMakeFiles/samples.dir/tests/dump_loader.cpp.obj"
  "CMakeFiles/samples.dir/tests/dynamic_tree.cpp.obj"
  "CMakeFiles/samples.dir/tests/edge_shapes.cpp.obj"
  "CMakeFiles/samples.dir/tests/edge_test.cpp.obj"
  "CMakeFiles/samples.dir/tests/friction.cpp.obj"
  "CMakeFiles/samples.dir/tests/gear_joint.cpp.obj"
  "CMakeFiles/samples.dir/tests/heavy1.cpp.obj"
  "CMakeFiles/samples.dir/tests/heavy2.cpp.obj"
  "CMakeFiles/samples.dir/tests/mobile_balanced.cpp.obj"
  "CMakeFiles/samples.dir/tests/mobile_unbalanced.cpp.obj"
  "CMakeFiles/samples.dir/tests/motor_joint.cpp.obj"
  "CMakeFiles/samples.dir/tests/pinball.cpp.obj"
  "CMakeFiles/samples.dir/tests/platformer.cpp.obj"
  "CMakeFiles/samples.dir/tests/polygon_collision.cpp.obj"
  "CMakeFiles/samples.dir/tests/polygon_shapes.cpp.obj"
  "CMakeFiles/samples.dir/tests/prismatic_joint.cpp.obj"
  "CMakeFiles/samples.dir/tests/pulley_joint.cpp.obj"
  "CMakeFiles/samples.dir/tests/pyramid.cpp.obj"
  "CMakeFiles/samples.dir/tests/ray_cast.cpp.obj"
  "CMakeFiles/samples.dir/tests/restitution.cpp.obj"
  "CMakeFiles/samples.dir/tests/revolute_joint.cpp.obj"
  "CMakeFiles/samples.dir/tests/rope.cpp.obj"
  "CMakeFiles/samples.dir/tests/rope_joint.cpp.obj"
  "CMakeFiles/samples.dir/tests/sensor.cpp.obj"
  "CMakeFiles/samples.dir/tests/shape_cast.cpp.obj"
  "CMakeFiles/samples.dir/tests/shape_editing.cpp.obj"
  "CMakeFiles/samples.dir/tests/skier.cpp.obj"
  "CMakeFiles/samples.dir/tests/slider_crank_1.cpp.obj"
  "CMakeFiles/samples.dir/tests/slider_crank_2.cpp.obj"
  "CMakeFiles/samples.dir/tests/theo_jansen.cpp.obj"
  "CMakeFiles/samples.dir/tests/tiles.cpp.obj"
  "CMakeFiles/samples.dir/tests/time_of_impact.cpp.obj"
  "CMakeFiles/samples.dir/tests/tumbler.cpp.obj"
  "libsamples.dll.a"
  "samples.exe"
  "samples.exe.manifest"
  "samples.pdb"
)

# Per-language clean rules from dependency scanning.
foreach(lang CXX)
  include(CMakeFiles/samples.dir/cmake_clean_${lang}.cmake OPTIONAL)
endforeach()


text:
package manager

import (
	"fmt"

	codec "github.com/cosmos/cosmos-sdk/codec"
	sdk "github.com/cosmos/cosmos-sdk/types"

	linotypes "github.com/lino-network/lino/types"
	"github.com/lino-network/lino/utils"
	acc "github.com/lino-network/lino/x/account"
	dev "github.com/lino-network/lino/x/developer"
	global "github.com/lino-network/lino/x/global"
	"github.com/lino-network/lino/x/post/model"
	"github.com/lino-network/lino/x/post/types"
	price "github.com/lino-network/lino/x/price"
	rep "github.com/lino-network/lino/x/reputation"
	vote "github.com/lino-network/lino/x/vote"
)

const (
	exportVersion = 2
	importVersion = 2
)

type PostManager struct {
	postStorage model.PostStorage

	// deps
	am    acc.AccountKeeper
	gm    global.GlobalKeeper
	dev   dev.DeveloperKeeper
	rep   rep.ReputationKeeper
	vote  vote.VoteKeeper
	price price.PriceKeeper
}

// NewPostManager - create a new post manager
func NewPostManager(key sdk.StoreKey, am acc.AccountKeeper, gm global.GlobalKeeper, dev dev.DeveloperKeeper, rep rep.ReputationKeeper, price price.PriceKeeper, vote vote.VoteKeeper) PostManager {
	return PostManager{
		postStorage: model.NewPostStorage(key),
		am:          am,
		gm:          gm,
		dev:         dev,
		rep:         rep,
		vote:        vote,
		price:       price,
	}
}

// DoesPostExist - check if post exist
// 1. permlink kv exists.
// 2. post is not marked as deleted.
func (pm PostManager) DoesPostExist(ctx sdk.Context, permlink linotypes.Permlink) bool {
	if !pm.postStorage.HasPost(ctx, permlink) {
		return false
	}
	post, _ := pm.postStorage.GetPost(ctx, permlink)
	return !post.IsDeleted
}

// GetPost - return post.
// return err if post is deleted.
func (pm PostManager) GetPost(ctx sdk.Context, permlink linotypes.Permlink) (model.Post, sdk.Error) {
	post, err := pm.postStorage.GetPost(ctx, permlink)
	if err != nil {
		return model.Post{}, err
	}
	if post.IsDeleted {
		return model.Post{}, types.ErrPostDeleted(permlink)
	}
	return *post, nil
}

// CreatePost validate and handles CreatePostMsg
// stateful validation;
// 1. both author and post id exists.
// 2. if createdBy is not author, then it must be an app.
// 3. post's permlink does not exists.
func (pm PostManager) CreatePost(ctx sdk.Context, author linotypes.AccountKey, postID string, createdBy linotypes.AccountKey, content string, title string) sdk.Error {
	if !pm.am.DoesAccountExist(ctx, author) {
		return types.ErrAccountNotFound(author)
	}
	if !pm.am.DoesAccountExist(ctx, createdBy) {
		return types.ErrAccountNotFound(createdBy)
	}
	permlink := linotypes.GetPermlink(author, postID)
	if pm.postStorage.HasPost(ctx, permlink) {
		return types.ErrPostAlreadyExist(permlink)
	}
	if author != createdBy {
		// if created by app, then createdBy must either be the app or an affiliated account of app.
		dev := createdBy
		var err error
		createdBy, err = pm.dev.GetAffiliatingApp(ctx, createdBy)
		if err != nil {
			return types.ErrDeveloperNotFound(dev)
		}
	}

	createdAt := ctx.BlockHeader().Time.Unix()
	postInfo := &model.Post{
		PostID:    postID,
		Title:     title,
		Content:   content,
		Author:    author,
		CreatedBy: createdBy,
		CreatedAt: createdAt,
		UpdatedAt: createdAt,
	}
	pm.postStorage.SetPost(ctx, postInfo)
	return nil
}

// UpdatePost - update post title, content and links.
// stateful validation:
// 1. author exist.
// 2. post exist.
func (pm PostManager) UpdatePost(ctx sdk.Context, author linotypes.AccountKey, postID, title, content string) sdk.Error {
	permlink := linotypes.GetPermlink(author, postID)
	postInfo, err := pm.postStorage.GetPost(ctx, permlink)
	if err != nil {
		// post not exists
		return err
	}
	postInfo.Title = title
	postInfo.Content = content
	postInfo.UpdatedAt = ctx.BlockHeader().Time.Unix()
	pm.postStorage.SetPost(ctx, postInfo)
	return nil
}

// DeletePost - delete post by author or content censorship
// stateful validation:
// 1. permlink exists.
// 2. post not deleted.
// Delete does not delete the post in kv store, as that will make `permlink` not permanent.
// It is marked as deleted, then on deleted posts,
// 1. manager.DoesPostExist will return false.
// 2. manager.GetPost will return ErrPermlinkDeleted.
// 3. manager.CreatePost will return ErrPostAlreadyExist.
func (pm PostManager) DeletePost(ctx sdk.Context, permlink linotypes.Permlink) sdk.Error {
	post, err := pm.postStorage.GetPost(ctx, permlink)
	if err != nil {
		return err
	}
	if post.IsDeleted {
		return types.ErrPostDeleted(permlink)
	}
	post.IsDeleted = true
	post.Title = ""
	post.Content = ""
	pm.postStorage.SetPost(ctx, post)
	return nil
}

// LinoDonate handles donation using lino.
// stateful validation:
// 1. post exits
// 2. from/to account exists.
// 3. no self donation.
// 4. if app is not empty, then developer must exist.
// 5. amount positive > 0.
// 6. 9.9% of amount > 0 coin.
func (pm PostManager) LinoDonate(ctx sdk.Context, from linotypes.AccountKey, amount linotypes.Coin, author linotypes.AccountKey, postID string, app linotypes.AccountKey) sdk.Error {
	if err := pm.validateLinoDonation(ctx, from, amount, author, postID, app); err != nil {
		return err
	}
	// donation.
	rate := sdk.MustNewDecFromStr(linotypes.ConsumptionFrictionRate)
	frictionCoin := linotypes.DecToCoin(amount.ToDec().Mul(rate))
	if frictionCoin.IsZero() {
		return types.ErrDonateAmountTooLittle()
	}
	// friction goes to the friction pool for voters.
	err := pm.am.MoveToPool(ctx,
		linotypes.VoteFrictionPool, linotypes.NewAccOrAddrFromAcc(from), frictionCoin)
	if err != nil {
		return err
	}

	// rest goes to the author.
	err = pm.am.MoveCoin(ctx, linotypes.NewAccOrAddrFromAcc(from),
		linotypes.NewAccOrAddrFromAcc(author), amount.Minus(frictionCoin))
	if err != nil {
		return err
	}

	mdamount, err := pm.price.CoinToMiniDollar(ctx, amount)
	if err != nil {
		return err
	}
	return pm.afterDonation(ctx, author, postID, from, mdamount, frictionCoin, app)
}

// IDADonate - handle IDA donation.
func (pm PostManager) IDADonate(ctx sdk.Context, from linotypes.AccountKey, n linotypes.MiniIDA, author linotypes.AccountKey, postID string, app, signer linotypes.AccountKey) sdk.Error {
	if err := pm.validateIDADonate(ctx, from, n, author, postID, app); err != nil {
		return err
	}
	signerApp, err := pm.dev.GetAffiliatingApp(ctx, signer)
	if err != nil || signerApp != app {
		return types.ErrInvalidSigner()
	}
	idaPrice, err := pm.dev.GetMiniIDAPrice(ctx, app)
	if err != nil {
		return err
	}

	// amount = tax + dollarTransfer
	// tax: burned to lino
	// dollarTransfer: moved from sender to receipient.
	rate := sdk.MustNewDecFromStr(linotypes.ConsumptionFrictionRate)
	dollarAmount := linotypes.MiniIDAToMiniDollar(n, idaPrice) // unit conversion
	tax := linotypes.NewMiniDollarFromInt(dollarAmount.ToDec().Mul(rate).TruncateInt())

	// burn and check taxable coins.
	// tax will be subtracted from @p from's IDA account, and converted to coins and
	// saved in the account.
	taxcoins, err := pm.dev.BurnIDA(ctx, app, from, tax)
	if err != nil {
		return err
	}
	if !taxcoins.IsPositive() {
		return types.ErrDonateAmountTooLittle()
	}

	// friction goes to the friction pool for voters.
	err = pm.am.MoveToPool(ctx,
		linotypes.VoteFrictionPool, linotypes.NewAccOrAddrFromAcc(from), taxcoins)
	if err != nil {
		return err
	}

	// rest goes to the author
	if err := pm.dev.MoveIDA(ctx, app, from, author, dollarAmount.Minus(tax)); err != nil {
		return err
	}

	return pm.afterDonation(ctx, author, postID, from, dollarAmount, taxcoins, app)
}

func (pm PostManager) afterDonation(ctx sdk.Context, author linotypes.AccountKey, postID string, from linotypes.AccountKey, damount linotypes.MiniDollar, friction linotypes.Coin, app linotypes.AccountKey) sdk.Error {
	// impact is the evaluated consumption.
	impact, err := pm.rep.DonateAt(ctx, from, linotypes.GetPermlink(author, postID), damount)
	if err != nil {
		return err
	}

	// update consumptionm window
	consumptionWindow := pm.postStorage.GetConsumptionWindow(ctx)
	pm.postStorage.SetConsumptionWindow(ctx, consumptionWindow.Plus(impact))

	// record friction stats.
	err = pm.vote.RecordFriction(ctx, friction)
	if err != nil {
		return err
	}

	// add content bonus return event.
	rewardEvent := types.RewardEvent{
		PostAuthor: author,
		PostID:     postID,
		Consumer:   from,
		Evaluate:   impact,
		FromApp:    app,
	}
	eventTime := ctx.BlockHeader().Time.Unix() + linotypes.ConsumptionFreezingPeriodSec
	if err := pm.gm.RegisterEventAtTime(ctx, eventTime, rewardEvent); err != nil {
		return err
	}
	return nil
}

// donation stateful basic validation:
// 1. post exits
// 2. from/to account exists.
// 3. no self donation.
func (pm PostManager) validateDonationBasic(ctx sdk.Context, from linotypes.AccountKey, author linotypes.AccountKey, postID string) sdk.Error {
	if from == author {
		return types.ErrCannotDonateToSelf(from)
	}
	if !pm.am.DoesAccountExist(ctx, from) {
		return types.ErrAccountNotFound(from)
	}
	if !pm.am.DoesAccountExist(ctx, author) {
		return types.ErrAccountNotFound(author)
	}
	permlink := linotypes.GetPermlink(author, postID)
	if !pm.DoesPostExist(ctx, permlink) {
		return types.ErrPostNotFound(permlink)
	}
	return nil
}

// lino donation stateful.
// 1. basic validation
// 2. lino amount > 0.
// 3. if app is not empty, then developer must exist.
func (pm PostManager) validateLinoDonation(ctx sdk.Context, from linotypes.AccountKey, amount linotypes.Coin, author linotypes.AccountKey, postID string, app linotypes.AccountKey) sdk.Error {
	err := pm.validateDonationBasic(ctx, from, author, postID)
	if err != nil {
		return err
	}
	if app != "" && !pm.dev.DoesDeveloperExist(ctx, app) {
		return types.ErrDeveloperNotFound(app)
	}
	if !amount.IsPositive() {
		return types.ErrInvalidDonationAmount(amount)
	}
	return nil
}

// IDA donation stateful.
// 1. basic validation
// 2. lino amount > 0.
// 3. app cannot be empty and the developer must exist.
func (pm PostManager) validateIDADonate(ctx sdk.Context, from linotypes.AccountKey, n linotypes.MiniIDA, author linotypes.AccountKey, postID string, app linotypes.AccountKey) sdk.Error {
	err := pm.validateDonationBasic(ctx, from, author, postID)
	if err != nil {
		return err
	}
	if app == "" || !pm.dev.DoesDeveloperExist(ctx, app) {
		return types.ErrDeveloperNotFound(app)
	}
	if !n.IsPositive() {
		return types.ErrNonPositiveIDAAmount(n)
	}
	return nil
}

// ExecRewardEvent - execute reward events.
func (pm PostManager) ExecRewardEvent(ctx sdk.Context, event types.RewardEvent) sdk.Error {
	// check if post is deleted, Note that if post is deleted, it's ok to just
	// skip this event. It does not return an error because errors will panic in events.
	permlink := linotypes.GetPermlink(event.PostAuthor, event.PostID)
	if !pm.DoesPostExist(ctx, permlink) {
		return nil
	}

	// if developer exist, add to developer consumption
	if pm.dev.DoesDeveloperExist(ctx, event.FromApp) {
		// ignore report consumption err.
		_ = pm.dev.ReportConsumption(ctx, event.FromApp, event.Evaluate)
	}

	return pm.allocContentBonus(ctx, event.Evaluate, event.PostAuthor)
}

func (pm PostManager) allocContentBonus(ctx sdk.Context, impact linotypes.MiniDollar, author linotypes.AccountKey) sdk.Error {
	if impact.IsZero() {
		return nil
	}

	// get consumption window and update the window
	consumptionWindow := pm.postStorage.GetConsumptionWindow(ctx)
	pm.postStorage.SetConsumptionWindow(ctx, consumptionWindow.Minus(impact))

	// XXX(yumin): the ratio is zero when the window is zero, because the consumption window
	// as the sum of past donation impacts, shall be large than zero as the @p impact is nonzero.
	// consumptionRatio = (this consumption * penalty score) / (total consumption in 7 days window)
	consumptionRatio := sdk.ZeroDec()
	if !consumptionWindow.ToDec().IsZero() {
		consumptionRatio = impact.ToDec().Quo(consumptionWindow.ToDec())
	}
	rewardPool, err := pm.am.GetPool(ctx, linotypes.InflationConsumptionPool)
	if err != nil {
		return err
	}
	// reward = (consumption reward pool) * (consumptionRatio)
	reward := linotypes.DecToCoin(rewardPool.ToDec().Mul(consumptionRatio))
	return pm.am.MoveFromPool(ctx,
		linotypes.InflationConsumptionPool, linotypes.NewAccOrAddrFromAcc(author), reward)
}

func (pm PostManager) GetComsumptionWindow(ctx sdk.Context) linotypes.MiniDollar {
	return pm.postStorage.GetConsumptionWindow(ctx)
}

// Export - to file.
func (pm PostManager) ExportToFile(ctx sdk.Context, cdc *codec.Codec, filepath string) error {
	state := &model.PostTablesIR{
		Version: exportVersion,
	}
	storeList := pm.postStorage.PartialStoreMap(ctx)

	// export posts
	posts := make([]model.PostIR, 0)
	postSubStore := storeList[string(model.PostSubStore)]
	postSubStore.Iterate(func(key []byte, val interface{}) bool {
		post := val.(*model.Post)
		posts = append(posts, model.PostIR(*post))
		return false
	})
	state.Posts = posts

	// consumption window
	state.ConsumptionWindow = pm.postStorage.GetConsumptionWindow(ctx)

	return utils.Save(filepath, cdc, state)
}

// Import - from file
func (pm PostManager) ImportFromFile(ctx sdk.Context, cdc *codec.Codec, filepath string) error {
	rst, err := utils.Load(filepath, cdc, func() interface{} { return &model.PostTablesIR{} })
	if err != nil {
		return err
	}
	table := rst.(*model.PostTablesIR)

	if table.Version != importVersion {
		return fmt.Errorf("unsupported import version: %d", table.Version)
	}

	for _, v := range table.Posts {
		pm.postStorage.SetPost(ctx, &model.Post{
			PostID:    v.PostID,
			Title:     v.Title,
			Content:   v.Content,
			Author:    v.Author,
			CreatedBy: v.Author,
			CreatedAt: v.CreatedAt,
			UpdatedAt: v.UpdatedAt,
			IsDeleted: v.IsDeleted,
		})
	}

	pm.postStorage.SetConsumptionWindow(ctx, table.ConsumptionWindow)
	return nil
}

repository: lino-network/lino

repo_name: lino-network/lino


text:
DESCRIPTION = "GEGL (Generic Graphics Library) is a graph based image processing framework."
LICENSE = "LGPL"
DEPENDS = "babl librsvg glib-2.0 gtk+ pango cairo expat zlib libpng jpeg virtual/libsdl"

SRCREV = "2543"
PV = "0.0.19+svnr${SRCPV}"
PE = "1"
PR = "r1"

inherit gnome

SRC_URI = "svn://svn.gnome.org/svn/${PN};module=trunk \
           file://gegl-resilience.patch"

S = "${WORKDIR}/trunk"

EXTRA_OECONF = "--disable-docs "

FILES_${PN} += "${libdir}/gegl-0.0"
FILES_${PN}-dbg += "${libdir}/gegl-0.0/.debug"

repository: overo/overo-oe-natty

repo_name: overo/overo-oe-natty


text:
/*
 * Copyright 2018 - Present Okta, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package unit

import (
	"context"
	"fmt"
	"net/http"
	"testing"

	"github.com/jarcoal/httpmock"
	"github.com/okta/okta-sdk-golang/v2/okta"

	"github.com/okta/okta-sdk-golang/v2/tests"
	"github.com/stretchr/testify/assert"
)

func Test_error_on_empty_url(t *testing.T) {
	_, _, err := tests.NewClient(context.TODO(), okta.WithOrgUrl(""))
	assert.Error(t, err, "Does not error when org url is missing")
}

func Test_error_when_url_contains_yourOktaDomain(t *testing.T) {
	_, _, err := tests.NewClient(context.TODO(), okta.WithOrgUrl("https://{yourOktaDomain}"))
	assert.Error(t, err, "Does not error when org url contains {yourOktaDomain}")
}

func Test_error_when_url_contains_admin_okta_com(t *testing.T) {
	_, _, err := tests.NewClient(context.TODO(), okta.WithOrgUrl("https://test-admin.okta.com"))
	assert.Error(t, err, "Does not error when org url contains test-admin.okta.com")
}

func Test_error_when_url_contains_admin_oktapreview_com(t *testing.T) {
	_, _, err := tests.NewClient(context.TODO(), okta.WithOrgUrl("https://test-admin.oktapreview.com"))
	assert.Error(t, err, "Does not error when org url contains test-admin.oktapreview.com")
}

func Test_error_when_url_contains_admin_okta_emea_com(t *testing.T) {
	_, _, err := tests.NewClient(context.TODO(), okta.WithOrgUrl("https://test-admin.okta-emea.com"))
	assert.Error(t, err, "Does not error when org url contains test-admin.okta-emea.com")
}

func Test_error_when_url_contains_com_com(t *testing.T) {
	_, _, err := tests.NewClient(context.TODO(), okta.WithOrgUrl("https://test.okta.com.com"))
	assert.Error(t, err, "Does not error when org url contains .com.com")
}

func Test_error_when_url_does_not_begin_with_https(t *testing.T) {
	_, _, err := tests.NewClient(context.TODO(), okta.WithTestingDisableHttpsCheck(false), okta.WithOrgUrl("http://test.okta.com"))
	assert.Error(t, err, "Does not error when url contains only http")
}

func Test_error_when_api_token_is_empty(t *testing.T) {
	_, _, err := tests.NewClient(context.TODO(), okta.WithToken(""))
	assert.Error(t, err, "Does not error when api token is empty")
}

func Test_error_when_api_token_contains_placeholder(t *testing.T) {
	_, _, err := tests.NewClient(context.TODO(), okta.WithToken("{apiToken}"))
	assert.Error(t, err, "Does not error when api token contains {apiToken}")
}

func Test_error_when_authorization_mode_is_not_valid(t *testing.T) {
	_, _, err := tests.NewClient(context.TODO(), okta.WithAuthorizationMode("invalid"))
	assert.Error(t, err, "Does not error when authorization mode is invalid")
}

func Test_does_not_error_when_authorization_mode_is_valid(t *testing.T) {
	_, _, err := tests.NewClient(context.TODO(), okta.WithAuthorizationMode("SSWS"))
	assert.NoError(t, err, "Should not error when authorization mode is SSWS")
}

func Test_does_not_error_when_authorization_mode_is_brearer(t *testing.T) {
	_, _, err := tests.NewClient(context.TODO(), okta.WithAuthorizationMode("Bearer"))
	assert.NoError(t, err, "Should not error when authorization mode is Bearer")
}

func Test_will_error_if_private_key_authorization_type_with_missing_properties(t *testing.T) {
	_, _, err := tests.NewClient(context.TODO(), okta.WithAuthorizationMode("PrivateKey"), okta.WithClientId(""))
	assert.Error(t, err, "Does not error if private key selected with no other required options")
}

type InterceptingRoundTripperTest struct {
	Name                    string
	Blocking                bool
	Interceptor             func(*http.Request) error
	ExpectedTransportCalls  int
	ExpectInterceptorCalled bool
	ExpectSdkErrorThrown    bool
}

func Test_Intercepting_RoundTripper(t *testing.T) {
	interceptorCalled := false
	testsToRun := []InterceptingRoundTripperTest{
		{
			Name:     "Calls interceptor",
			Blocking: false,
			Interceptor: func(r *http.Request) error {
				interceptorCalled = true
				return nil
			},
			ExpectedTransportCalls:  1,
			ExpectInterceptorCalled: true,
			ExpectSdkErrorThrown:    false,
		},
		{
			Name:     "Does not call transport when interceptor panics when blocking",
			Blocking: true,
			Interceptor: func(r *http.Request) error {
				interceptorCalled = true
				panic("Some err")
			},
			ExpectedTransportCalls:  0,
			ExpectInterceptorCalled: true,
			ExpectSdkErrorThrown:    true,
		},
		{
			Name:     "Calls transport when interceptor panics when non blocking",
			Blocking: false,
			Interceptor: func(r *http.Request) error {
				interceptorCalled = true
				panic("Some err")
			},
			ExpectedTransportCalls:  1,
			ExpectInterceptorCalled: true,
			ExpectSdkErrorThrown:    false,
		},
		{
			Name:     "Does not call transport when interceptor throws err when blocking",
			Blocking: true,
			Interceptor: func(r *http.Request) error {
				interceptorCalled = true
				return fmt.Errorf("Some error")
			},
			ExpectedTransportCalls:  0,
			ExpectInterceptorCalled: true,
			ExpectSdkErrorThrown:    true,
		},
		{
			Name:     "Calls transport when interceptor throws err when not blocking",
			Blocking: false,
			Interceptor: func(r *http.Request) error {
				interceptorCalled = true
				return fmt.Errorf("Some error")
			},
			ExpectedTransportCalls:  1,
			ExpectInterceptorCalled: true,
			ExpectSdkErrorThrown:    false,
		},
	}

	for _, test := range testsToRun {
		t.Run(
			test.Name,
			func(t *testing.T) {
				mockHttpClient := http.DefaultClient
				mockTransport := httpmock.DefaultTransport
				mockTransport.RegisterNoResponder(func(r *http.Request) (*http.Response, error) {
					return &http.Response{StatusCode: 200}, nil
				})
				mockHttpClient.Transport = mockTransport

				_, oktaClient, err := tests.NewClient(
					context.TODO(),
					okta.WithHttpInterceptorAndHttpClientPtr(test.Interceptor, mockHttpClient, test.Blocking),
				)
				assert.NoError(t, err)

				_, _, err = oktaClient.IdentityProvider.ActivateIdentityProvider(context.TODO(), "Anything")

				if test.ExpectSdkErrorThrown {
					assert.Error(t, err)
				} else {
					assert.NoError(t, err)
				}

				assert.Equal(t, test.ExpectInterceptorCalled, interceptorCalled)

				callCount := mockTransport.GetTotalCallCount()

				assert.Equal(t, test.ExpectedTransportCalls, callCount)

				interceptorCalled = false
				mockTransport.ZeroCallCounters()
			},
		)
	}
}

repository: okta/okta-sdk-golang

repo_name: okta/okta-sdk-golang

gha_license_id: NOASSERTION


text:
SUMMARY = "OpenSwitch REST API rendering"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"

SRC_URI = "git://git.openswitch.net/openswitch/ops-restapi;protocol=http \
"

SRCREV = "87da644cefe798fe29ceb428e9153d377a4d1836"

# When using AUTOREV, we need to force the package version to the revision of git
# in order to avoid stale shared states.
PV = "git${SRCPV}"

S = "${WORKDIR}/git"
B = "${S}"

FILES_${PN} += "/srv/www/api"

do_install_append () {
    # Install Swagger-UI files with modification to point to OpenSwitch
    # REST API file
    install -d ${D}/srv/www/api
    cp -R ${S}/src/* ${D}/srv/www/api
}

repository: mabnhdev/ops-build

repo_name: mabnhdev/ops-build


text:
@article{MinionEtAl2015,
  author = {Minion, Michael L. and Speck, Robert and Bolten, Matthias and Emmett, Matthew and Ruprecht, Daniel},
  journal = {{SIAM} Journal on Scientific Computing},
  issue = {5},
  pages = {S244--S263},
  title = {{Interweaving {PFASST} and parallel multigrid}},
  url = {http://dx.doi.org/10.1137/14097536X},
  doi = {10.1137/14097536X},
  volume = {37},
  year = {2015}
}

repository: comp-maths/website

repo_name: comp-maths/website


text:
IF(ANDROID)
	RETURN()
ENDIF()
IF(IOS)
	RETURN()
ENDIF()
IF(IOSSIM)
	RETURN()
ENDIF()

dk_depend(rtmidi)
IF(HAVE_DKDuktape)
	dk_depend(DKDuktape)
ENDIF()
IF(HAVE_DKCef)
	dk_depend(DKCef)
ENDIF()

dk_generateCmake(DKMidi)
dk_assets(DKMidi)

repository: aquawicket/DigitalKnob

repo_name: aquawicket/DigitalKnob

branch_name: refs/heads/main


text:
SUMMARY = "Fixed-point decoder"
DESCRIPTION = "tremor is a fixed point implementation of the vorbis codec."
SECTION = "libs"
LICENSE = "BSD-3-Clause"
LIC_FILES_CHKSUM = "file://COPYING;md5=db1b7a668b2a6f47b2af88fb008ad555 \
                    file://os.h;beginline=3;endline=14;md5=5c0af5e1bedef3ce8178c89f48cd6f1f"
DEPENDS = "libogg"

SRC_URI = "git://gitlab.xiph.org/xiph/tremor.git;protocol=https;branch=master \
           file://obsolete_automake_macros.patch;striplevel=0 \
           file://tremor-arm-thumb2.patch \
"
SRCREV = "7c30a66346199f3f09017a09567c6c8a3a0eedc8"

S = "${WORKDIR}/git"

inherit autotools pkgconfig

EXTRA_OECONF = "--enable-shared"

ARM_INSTRUCTION_SET = "arm"

repository: openembedded/meta-openembedded

repo_name: openembedded/meta-openembedded

gha_language: BitBake


text:
@misc{santana2020marsgym,
      title={MARS-Gym: A Gym framework to model, train, and evaluate Recommender Systems for Marketplaces},
      author={Marlesson R. O. Santana and Luckeciano C. Melo and Fernando H. F. Camargo and Bruno Brandão and Anderson Soares and Renan M. Oliveira and Sandor Caetano},
      year={2020},
      eprint={2010.07035},
      archivePrefix={arXiv},
      primaryClass={cs.IR}
}


text:
package exit

import (
	"fmt"
	"os"
)

func Fatal(err error) {
	fmt.Printf("Fatal error occurred, exiting:\n==> %s", err)

	os.Exit(1)
}

func Fatalm(m string, err error) {
	fmt.Printf("%s\n==> %s", err)

	os.Exit(1)
}

func Ok(m string) {
	fmt.Println(m)
	os.Exit(0)
}

gha_language: JavaScript


text:
package types

// service module event types
const (
	EventTypeCreateDefinition        = "create_definition"
	EventTypeCreateBinding           = "create_binding"
	EventTypeUpdateBinding           = "update_binding"
	EventTypeDisableBinding          = "disable_binding"
	EventTypeEnableBinding           = "enable_binding"
	EventTypeRefundDeposit           = "refund_deposit"
	EventTypeSetWithdrawAddress      = "set_withdraw_address"
	EventTypeRespondService          = "respond_service"
	EventTypeCreateContext           = "create_context"
	EventTypePauseContext            = "pause_context"
	EventTypeStartContext            = "start_context"
	EventTypeKillContext             = "kill_context"
	EventTypeUpdateContext           = "update_context"
	EventTypeWithdrawEarnedFees      = "withdraw_earned_fees"
	EventTypeCompleteContext         = "complete_context"
	EventTypeNewBatch                = "new_batch"
	EventTypeNewBatchRequest         = "new_batch_request"
	EventTypeNewBatchRequestProvider = "new_batch_request_provider"
	EventTypeCompleteBatch           = "complete_batch"
	EventTypeServiceSlash            = "service_slash"
	EventTypeNoExchangeRate          = "no_exchange_rate"

	AttributeValueCategory = ModuleName

	AttributeKeyAuthor              = "author"
	AttributeKeyServiceName         = "service_name"
	AttributeKeyProvider            = "provider"
	AttributeKeyOwner               = "owner"
	AttributeKeyWithdrawAddress     = "withdraw_address"
	AttributeKeyConsumer            = "consumer"
	AttributeKeyModuleService       = "module_service"
	AttributeKeyRequestContextID    = "request_context_id"
	AttributeKeyRequestContextState = "request_context_state"
	AttributeKeyRequests            = "requests"
	AttributeKeyRequestID           = "request_id"
	AttributeKeyServiceFee          = "service_fee"
	AttributeKeyRequestHeight       = "request_height"
	AttributeKeyExpirationHeight    = "expiration_height"
	AttributeKeySlashedCoins        = "slashed_coins"
	AttributeKeyPriceDenom          = "price_denom"
)

type BatchState struct {
	BatchCounter           uint64                   `json:"batch_counter"`
	State                  RequestContextBatchState `json:"state"`
	BatchResponseThreshold uint32                   `json:"batch_response_threshold"`
	BatchRequestCount      uint32                   `json:"batch_request_count"`
	BatchResponseCount     uint32                   `json:"batch_response_count"`
}

// ActionTag appends action and all tagKeys
func ActionTag(action string, tagKeys ...string) string {
	tag := action
	for _, key := range tagKeys {
		tag = tag + "." + key
	}
	return tag
}

repository: catShaark/irismod

repo_name: catShaark/irismod


text:
package onpremise

import (
	"context"
	"fmt"
	"net/http"
)

// RequestService handles ServiceDesk customer requests for the Jira instance / API.
type RequestService service

// Request represents a ServiceDesk customer request.
type Request struct {
	IssueID       string              `json:"issueId,omitempty" structs:"issueId,omitempty"`
	IssueKey      string              `json:"issueKey,omitempty" structs:"issueKey,omitempty"`
	TypeID        string              `json:"requestTypeId,omitempty" structs:"requestTypeId,omitempty"`
	ServiceDeskID string              `json:"serviceDeskId,omitempty" structs:"serviceDeskId,omitempty"`
	Reporter      *Customer           `json:"reporter,omitempty" structs:"reporter,omitempty"`
	FieldValues   []RequestFieldValue `json:"requestFieldValues,omitempty" structs:"requestFieldValues,omitempty"`
	Status        *RequestStatus      `json:"currentStatus,omitempty" structs:"currentStatus,omitempty"`
	Links         *SelfLink           `json:"_links,omitempty" structs:"_links,omitempty"`
	Expands       []string            `json:"_expands,omitempty" structs:"_expands,omitempty"`
}

// RequestFieldValue is a request field.
type RequestFieldValue struct {
	FieldID string `json:"fieldId,omitempty" structs:"fieldId,omitempty"`
	Label   string `json:"label,omitempty" structs:"label,omitempty"`
	Value   string `json:"value,omitempty" structs:"value,omitempty"`
}

// RequestDate is the date format used in requests.
type RequestDate struct {
	ISO8601  string `json:"iso8601,omitempty" structs:"iso8601,omitempty"`
	Jira     string `json:"jira,omitempty" structs:"jira,omitempty"`
	Friendly string `json:"friendly,omitempty" structs:"friendly,omitempty"`
	Epoch    int64  `json:"epoch,omitempty" structs:"epoch,omitempty"`
}

// RequestStatus is the status for a request.
type RequestStatus struct {
	Status   string
	Category string
	Date     RequestDate
}

// RequestComment is a comment for a request.
type RequestComment struct {
	ID      string       `json:"id,omitempty" structs:"id,omitempty"`
	Body    string       `json:"body,omitempty" structs:"body,omitempty"`
	Public  bool         `json:"public" structs:"public"`
	Author  *Customer    `json:"author,omitempty" structs:"author,omitempty"`
	Created *RequestDate `json:"created,omitempty" structs:"created,omitempty"`
	Links   *SelfLink    `json:"_links,omitempty" structs:"_links,omitempty"`
	Expands []string     `json:"_expands,omitempty" structs:"_expands,omitempty"`
}

// Create creates a new request.
//
// https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-request/#api-rest-servicedeskapi-request-post
//
// TODO Double check this method if this works as expected, is using the latest API and the response is complete
// This double check effort is done for v2 - Remove this two lines if this is completed.
func (r *RequestService) Create(ctx context.Context, requester string, participants []string, request *Request) (*Request, *Response, error) {
	apiEndpoint := "rest/servicedeskapi/request"

	payload := struct {
		*Request
		FieldValues  map[string]string `json:"requestFieldValues,omitempty"`
		Requester    string            `json:"raiseOnBehalfOf,omitempty"`
		Participants []string          `json:"requestParticipants,omitempty"`
	}{
		Request:      request,
		FieldValues:  make(map[string]string),
		Requester:    requester,
		Participants: participants,
	}

	for _, field := range request.FieldValues {
		payload.FieldValues[field.FieldID] = field.Value
	}

	req, err := r.client.NewRequest(ctx, http.MethodPost, apiEndpoint, payload)
	if err != nil {
		return nil, nil, err
	}

	responseRequest := new(Request)
	resp, err := r.client.Do(req, responseRequest)
	if err != nil {
		return nil, resp, NewJiraError(resp, err)
	}

	return responseRequest, resp, nil
}

// CreateComment creates a comment on a request.
//
// https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-request/#api-rest-servicedeskapi-request-issueidorkey-comment-post
//
// TODO Double check this method if this works as expected, is using the latest API and the response is complete
// This double check effort is done for v2 - Remove this two lines if this is completed.
func (r *RequestService) CreateComment(ctx context.Context, issueIDOrKey string, comment *RequestComment) (*RequestComment, *Response, error) {
	apiEndpoint := fmt.Sprintf("rest/servicedeskapi/request/%v/comment", issueIDOrKey)

	req, err := r.client.NewRequest(ctx, http.MethodPost, apiEndpoint, comment)
	if err != nil {
		return nil, nil, err
	}

	responseComment := new(RequestComment)
	resp, err := r.client.Do(req, responseComment)
	if err != nil {
		return nil, resp, NewJiraError(resp, err)
	}

	return responseComment, resp, nil
}

repository: andygrunwald/go-jira

repo_name: andygrunwald/go-jira


text:
package finhand

import (
	"sort"
	"sync"

	"github.com/google/uuid"
)

const (
	// Version is package version
	Version = "0.1.0"
)

// Handler is Finalizer Handler Object
type Handler struct {
	name     string
	priority int
	f        func()
}

var (
	handlersLock sync.RWMutex
	handlers     map[string]*Handler
	once         sync.Once
)

// OnceInit initialize the handlers.
func OnceInit() {
	once.Do(ClearHandlers)
}

// ClearHandlers remove all handlers.
func ClearHandlers() {
	handlers = map[string]*Handler{}
}

// GetHandler gets the registered Handler
func GetHandler(name string) (*Handler, bool) {
	OnceInit()
	handlersLock.Lock()
	defer handlersLock.Unlock()
	hand, ok := handlers[name]
	return hand, ok
}

// AddHandler is adding new hander.
func AddHandler(f func()) string {
	return AddHandlerWithPriority(0, f)
}

// AddHandlerWithPriority is adding new hander with priority
func AddHandlerWithPriority(priority int, f func()) string {
	var name string
	for {
		uuid, _ := uuid.NewUUID()
		name = uuid.String()
		if _, ok := GetHandler(name); !ok {
			break
		}
	}
	AddHandlerWithNameAndPriority(name, priority, f)
	return name
}

// AddHandlerWithNameAndPriority is adding new hander. This will override any handler with the same name if it exists.
func AddHandlerWithNameAndPriority(name string, priority int, f func()) {
	OnceInit()
	handlersLock.Lock()
	defer handlersLock.Unlock()
	hand := Handler{name: name, priority: priority, f: f}
	handlers[name] = &hand
}

// RemoveHandler is removing handler. Do nothing if the specified handler does not exist.
func RemoveHandler(name string) {
	OnceInit()
	handlersLock.Lock()
	defer handlersLock.Unlock()
	delete(handlers, name)
}

// ExecuteHandlers is execute all handler and clear all handlers
func ExecuteHandlers() {
	OnceInit()
	handlersLock.Lock()
	defer handlersLock.Unlock()
	values := []*Handler{}
	for _, v := range handlers {
		values = append(values, v)
	}
	sort.SliceStable(values, func(i int, j int) bool {
		return values[i].priority > values[j].priority
	})
	for len(values) > 0 {
		hand := values[0]
		hand.f()
		values = values[1:]
	}
}

// RunHandlers is execute all handlers once.
func RunHandlers() {
	ExecuteHandlers()
	ClearHandlers()
}


text:
%% This BibTeX bibliography file was created using BibDesk.
%% http://bibdesk.sourceforge.net/

%% Created for Andrew Heiss at 2018-05-31 16:50:48 -0600

%% Saved with string encoding Unicode (UTF-8)

@article{GeddesWrightFrantz:2014,
	Author = {Barbara Geddes and Joseph Wright and Erica Frantz},
	Date-Added = {2018-05-31 21:45:28 +0000},
	Date-Modified = {2018-05-31 21:45:28 +0000},
	Doi = {10.1017/S1537592714000851},
	Journal = {Perspectives on Politics},
	Month = {6},
	Number = {2},
	Pages = {313--31},
	Read = {0},
	Title = {Autocratic Breakdown and Regime Transitions: A New Data Set},
	Volume = {12},
	Year = {2014},
	Bdsk-Url-1 = {http://dx.doi.org/10.1017/S1537592714000851}}

@article{MitchellSchmitz:2014,
	Author = {George E. Mitchell and Hans Peter Schmitz},
	Date-Added = {2018-05-24 06:51:24 +0000},
	Date-Modified = {2018-05-24 06:51:30 +0000},
	Doi = {10.1017/s0260210513000387},
	Journal = {Review of International Studies},
	Month = {7},
	Number = {3},
	Pages = {487--504},
	Rating = {0},
	Read = {0},
	Title = {Principled Instrumentalism: A Theory of Transnational {NGO} Behaviour},
	Volume = {40},
	Year = {2014},
	Bdsk-Url-1 = {http://dx.doi.org/10.1017/s0260210513000387}}

@article{MurdieDavis:2012,
	Author = {Amanda Murdie and David R. Davis},
	Date-Added = {2018-05-24 04:54:14 +0000},
	Date-Modified = {2018-05-24 04:54:30 +0000},
	Doi = {10.1111/j.1468-2478.2011.00694.x},
	Journal = {International Studies Quarterly},
	Month = {3},
	Number = {1},
	Pages = {1--16},
	Rating = {0},
	Read = {0},
	Title = {Shaming and Blaming: Using Events Data to Assess the Impact of Human Rights {INGO}s},
	Volume = {56},
	Year = {2012},
	Bdsk-Url-1 = {http://dx.doi.org/10.1111/j.1468-2478.2011.00694.x}}

@article{DupuyRonPrakash:2015,
	Author = {Kendra E. Dupuy and James Ron and Aseem Prakash},
	Date-Added = {2018-05-24 04:51:43 +0000},
	Date-Modified = {2018-05-24 04:51:43 +0000},
	Doi = {10.1080/09692290.2014.903854},
	Journal = {Review of International Political Economy},
	Number = {2},
	Pages = {419--56},
	Title = {Who Survived? {Ethiopia}'s Regulatory Crackdown on Foreign-Funded {NGO}s},
	Volume = {22},
	Year = {2015},
	Bdsk-Url-1 = {http://dx.doi.org/10.1080/09692290.2014.903854}}

@book{Carothers:2015,
	Address = {Washington, D. C.},
	Author = {Thomas Carothers},
	Date-Added = {2018-05-24 04:51:29 +0000},
	Date-Modified = {2018-05-24 04:51:32 +0000},
	Month = {11},
	Publisher = {Carnegie Endowment for International Peace},
	Title = {The Closing Space Challenge: How Are Funders Responding?},
	Year = {2015}}

@article{BloodgoodTremblay-BoirePrakash:2014,
	Author = {Elizabeth A. Bloodgood and Joannie Tremblay-Boire and Aseem Prakash},
	Date-Added = {2018-05-24 04:51:12 +0000},
	Date-Modified = {2018-05-24 04:51:12 +0000},
	Doi = {10.1177/0899764013481111},
	Journal = {Nonprofit and Voluntary Sector Quarterly},
	Number = {4},
	Pages = {716--36},
	Title = {National Styles of {NGO} Regulation},
	Volume = {43},
	Year = {2014},
	Bdsk-Url-1 = {http://dx.doi.org/10.1177/0899764013481111}}

@article{DietrichMurdie:2017,
	Author = {Simone Dietrich and Amanda Murdie},
	Date-Added = {2018-05-24 04:50:59 +0000},
	Date-Modified = {2018-05-24 04:50:59 +0000},
	Doi = {10.1007/s11558-015-9242-8},
	Journal = {Review of International Organizations},
	Month = {3},
	Number = {1},
	Pages = {95--120},
	Title = {Human Rights Shaming Through {INGO}s and Foreign Aid Delivery},
	Volume = {12},
	Year = {2017},
	Bdsk-Url-1 = {https://doi.org/10.1007/s11558-015-9242-8}}

@article{Murdie:2014,
	Author = {Amanda Murdie},
	Date-Added = {2018-05-24 04:50:54 +0000},
	Date-Modified = {2018-05-24 04:52:33 +0000},
	Doi = {10.1017/S0007123412000683},
	Journal = {British Journal of Political Science},
	Month = {1},
	Number = {1},
	Pages = {1--27},
	Rating = {0},
	Read = {0},
	Title = {The Ties that Bind: A Network Analysis of Human Rights International Nongovernmental Organizations},
	Volume = {44},
	Year = {2014},
	Bdsk-Url-1 = {http://dx.doi.org/10.1017/S0007123412000683}}

@article{BarryClayFlynn:2013,
	Author = {Colin M. Barry and K. Chad Clay and Michael E. Flynn},
	Date-Added = {2018-05-24 04:50:29 +0000},
	Date-Modified = {2018-05-24 04:53:23 +0000},
	Doi = {10.1111/isqu.12039},
	Journal = {International Studies Quarterly},
	Month = {9},
	Number = {3},
	Pages = {532--44},
	Rating = {0},
	Read = {0},
	Title = {Avoiding the Spotlight: Human Rights Shaming and Foreign Direct Investment},
	Volume = {57},
	Year = {2013},
	Bdsk-Url-1 = {http://dx.doi.org/10.1111/isqu.12039}}

@book{Platteau:2000,
	Address = {Amsterdam},
	Author = {Jean-Philippe Platteau},
	Date-Added = {2018-05-24 04:50:22 +0000},
	Date-Modified = {2018-05-24 04:50:22 +0000},
	Publisher = {Harwood},
	Rating = {3},
	Read = {1},
	Title = {Institutions, Social Norms, and Economic Development},
	Year = {2000},
	Bdsk-File-1 = {YnBsaXN0MDDUAQIDBAUGJCVYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3ASAAGGoKgHCBMUFRYaIVUkbnVsbNMJCgsMDxJXTlMua2V5c1pOUy5vYmplY3RzViRjbGFzc6INDoACgAOiEBGABIAFgAdccmVsYXRpdmVQYXRoWWFsaWFzRGF0YV8Qbi4uLy4uLy4uLy4uLy4uL0Ryb3Bib3gvUmVhZGluZ3MvUGFwZXJzL1BsYXR0ZWF1MjAwMCAtIEluc3RpdHV0aW9ucywgU29jaWFsIE5vcm1zLCBhbmQgRWNvbm9taWMgRGV2ZWxvcG1lbnQucGRm0hcLGBlXTlMuZGF0YU8RAkQAAAAAAkQAAgAADE1hY2ludG9zaCBIRAAAAAAAAAAAAAAAAAAAAAAAAABCRAAB/////x9QbGF0dGVhdTIwMDAgLSBJbnMjRkZGRkZGRkYucGRmAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAAAAAAAAAAAAAAUABAAACiBjdQAAAAAAAAAAAAAAAAAGUGFwZXJzAAIAbi86VXNlcnM6YW5kcmV3OkRyb3Bib3g6UmVhZGluZ3M6UGFwZXJzOlBsYXR0ZWF1MjAwMCAtIEluc3RpdHV0aW9ucywgU29jaWFsIE5vcm1zLCBhbmQgRWNvbm9taWMgRGV2ZWxvcG1lbnQucGRmAA4AkABHAFAAbABhAHQAdABlAGEAdQAyADAAMAAwACAALQAgAEkAbgBzAHQAaQB0AHUAdABpAG8AbgBzACwAIABTAG8AYwBpAGEAbAAgAE4AbwByAG0AcwAsACAAYQBuAGQAIABFAGMAbwBuAG8AbQBpAGMAIABEAGUAdgBlAGwAbwBwAG0AZQBuAHQALgBwAGQAZgAPABoADABNAGEAYwBpAG4AdABvAHMAaAAgAEgARAASAGxVc2Vycy9hbmRyZXcvRHJvcGJveC9SZWFkaW5ncy9QYXBlcnMvUGxhdHRlYXUyMDAwIC0gSW5zdGl0dXRpb25zLCBTb2NpYWwgTm9ybXMsIGFuZCBFY29ub21pYyBEZXZlbG9wbWVudC5wZGYAEwABLwAAFQACAA3//wAAgAbSGxwdHlokY2xhc3NuYW1lWCRjbGFzc2VzXU5TTXV0YWJsZURhdGGjHR8gVk5TRGF0YVhOU09iamVjdNIbHCIjXE5TRGljdGlvbmFyeaIiIF8QD05TS2V5ZWRBcmNoaXZlctEmJ1Ryb290gAEACAARABoAIwAtADIANwBAAEYATQBVAGAAZwBqAGwAbgBxAHMAdQB3AIQAjgD/AQQBDANUA1YDWwNmA28DfQOBA4gDkQOWA6MDpgO4A7sDwAAAAAAAAAIBAAAAAAAAACgAAAAAAAAAAAAAAAAAAAPC},
	Bdsk-File-2 = {YnBsaXN0MDDUAQIDBAUGJCVYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3ASAAGGoKgHCBMUFRYaIVUkbnVsbNMJCgsMDxJXTlMua2V5c1pOUy5vYmplY3RzViRjbGFzc6INDoACgAOiEBGABIAFgAdccmVsYXRpdmVQYXRoWWFsaWFzRGF0YV8Qby4uLy4uLy4uLy4uLy4uL0Ryb3Bib3gvUmVhZGluZ3MvUGFwZXJzL1BsYXR0ZWF1MjAwMCAtIEluc3RpdHV0aW9ucywgU29jaWFsIE5vcm1zLCBhbmQgRWNvbm9taWMgRGV2ZWxvcG1lbnQwLnBkZtIXCxgZV05TLmRhdGFPEQJKAAAAAAJKAAIAAAxNYWNpbnRvc2ggSEQAAAAAAAAAAAAAAAAAAAAAAAAAQkQAAf////8fUGxhdHRlYXUyMDAwIC0gSW5zI0ZGRkZGRkZGLnBkZgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////wAAAAAAAAAAAAAAAAAFAAQAAAogY3UAAAAAAAAAAAAAAAAABlBhcGVycwACAG8vOlVzZXJzOmFuZHJldzpEcm9wYm94OlJlYWRpbmdzOlBhcGVyczpQbGF0dGVhdTIwMDAgLSBJbnN0aXR1dGlvbnMsIFNvY2lhbCBOb3JtcywgYW5kIEVjb25vbWljIERldmVsb3BtZW50MC5wZGYAAA4AkgBIAFAAbABhAHQAdABlAGEAdQAyADAAMAAwACAALQAgAEkAbgBzAHQAaQB0AHUAdABpAG8AbgBzACwAIABTAG8AYwBpAGEAbAAgAE4AbwByAG0AcwAsACAAYQBuAGQAIABFAGMAbwBuAG8AbQBpAGMAIABEAGUAdgBlAGwAbwBwAG0AZQBuAHQAMAAuAHAAZABmAA8AGgAMAE0AYQBjAGkAbgB0AG8AcwBoACAASABEABIAbVVzZXJzL2FuZHJldy9Ecm9wYm94L1JlYWRpbmdzL1BhcGVycy9QbGF0dGVhdTIwMDAgLSBJbnN0aXR1dGlvbnMsIFNvY2lhbCBOb3JtcywgYW5kIEVjb25vbWljIERldmVsb3BtZW50MC5wZGYAABMAAS8AABUAAgAN//8AAIAG0hscHR5aJGNsYXNzbmFtZVgkY2xhc3Nlc11OU011dGFibGVEYXRhox0fIFZOU0RhdGFYTlNPYmplY3TSGxwiI1xOU0RpY3Rpb25hcnmiIiBfEA9OU0tleWVkQXJjaGl2ZXLRJidUcm9vdIABAAgAEQAaACMALQAyADcAQABGAE0AVQBgAGcAagBsAG4AcQBzAHUAdwCEAI4BAAEFAQ0DWwNdA2IDbQN2A4QDiAOPA5gDnQOqA60DvwPCA8cAAAAAAAACAQAAAAAAAAAoAAAAAAAAAAAAAAAAAAADyQ==},
	Bdsk-File-3 = {YnBsaXN0MDDUAQIDBAUGJCVYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3ASAAGGoKgHCBMUFRYaIVUkbnVsbNMJCgsMDxJXTlMua2V5c1pOUy5vYmplY3RzViRjbGFzc6INDoACgAOiEBGABIAFgAdccmVsYXRpdmVQYXRoWWFsaWFzRGF0YV8Qby4uLy4uLy4uLy4uLy4uL0Ryb3Bib3gvUmVhZGluZ3MvUGFwZXJzL1BsYXR0ZWF1MjAwMCAtIEluc3RpdHV0aW9ucywgU29jaWFsIE5vcm1zLCBhbmQgRWNvbm9taWMgRGV2ZWxvcG1lbnQxLnBkZtIXCxgZV05TLmRhdGFPEQJKAAAAAAJKAAIAAAxNYWNpbnRvc2ggSEQAAAAAAAAAAAAAAAAAAAAAAAAAQkQAAf////8fUGxhdHRlYXUyMDAwIC0gSW5zI0ZGRkZGRkZGLnBkZgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////wAAAAAAAAAAAAAAAAAFAAQAAAogY3UAAAAAAAAAAAAAAAAABlBhcGVycwACAG8vOlVzZXJzOmFuZHJldzpEcm9wYm94OlJlYWRpbmdzOlBhcGVyczpQbGF0dGVhdTIwMDAgLSBJbnN0aXR1dGlvbnMsIFNvY2lhbCBOb3JtcywgYW5kIEVjb25vbWljIERldmVsb3BtZW50MS5wZGYAAA4AkgBIAFAAbABhAHQAdABlAGEAdQAyADAAMAAwACAALQAgAEkAbgBzAHQAaQB0AHUAdABpAG8AbgBzACwAIABTAG8AYwBpAGEAbAAgAE4AbwByAG0AcwAsACAAYQBuAGQAIABFAGMAbwBuAG8AbQBpAGMAIABEAGUAdgBlAGwAbwBwAG0AZQBuAHQAMQAuAHAAZABmAA8AGgAMAE0AYQBjAGkAbgB0AG8AcwBoACAASABEABIAbVVzZXJzL2FuZHJldy9Ecm9wYm94L1JlYWRpbmdzL1BhcGVycy9QbGF0dGVhdTIwMDAgLSBJbnN0aXR1dGlvbnMsIFNvY2lhbCBOb3JtcywgYW5kIEVjb25vbWljIERldmVsb3BtZW50MS5wZGYAABMAAS8AABUAAgAN//8AAIAG0hscHR5aJGNsYXNzbmFtZVgkY2xhc3Nlc11OU011dGFibGVEYXRhox0fIFZOU0RhdGFYTlNPYmplY3TSGxwiI1xOU0RpY3Rpb25hcnmiIiBfEA9OU0tleWVkQXJjaGl2ZXLRJidUcm9vdIABAAgAEQAaACMALQAyADcAQABGAE0AVQBgAGcAagBsAG4AcQBzAHUAdwCEAI4BAAEFAQ0DWwNdA2IDbQN2A4QDiAOPA5gDnQOqA60DvwPCA8cAAAAAAAACAQAAAAAAAAAoAAAAAAAAAAAAAAAAAAADyQ==}}

@article{DupuyRonPrakash:2016,
	Author = {Kendra Dupuy and James Ron and Aseem Prakash},
	Date-Added = {2018-05-23 16:59:45 +0000},
	Date-Modified = {2018-05-23 16:59:45 +0000},
	Doi = {10.1016/j.worlddev.2016.02.001},
	Journal = {World Development},
	Month = {8},
	Pages = {299--311},
	Title = {Hands Off My Regime! Governments' Restrictions on Foreign Aid to Non-Governmental Organizations in Poor and Middle-Income Countries},
	Volume = {84},
	Year = {2016},
	Bdsk-Url-1 = {http://dx.doi.org/10.1016/j.worlddev.2016.02.001}}

@article{HeissKelley:2017,
	Author = {Andrew Heiss and Judith G. Kelley},
	Date-Added = {2018-05-23 16:59:17 +0000},
	Date-Modified = {2018-05-23 16:59:17 +0000},
	Doi = {10.1086/691218},
	Journal = {Journal of Politics},
	Month = {4},
	Number = {2},
	Pages = {732--41},
	Title = {Between a Rock and a Hard Place: International {NGOs} and the Dual Pressures of Donors and Host Governments},
	Volume = {79},
	Year = {2017},
	Bdsk-Url-1 = {http://dx.doi.org/10.1086/691218}}

@book{CarothersBrechenmacher:2014,
	Address = {Washington, D. C.},
	Author = {Thomas Carothers and Saskia Brechenmacher},
	Date-Added = {2018-05-23 16:58:50 +0000},
	Date-Modified = {2018-05-23 16:58:50 +0000},
	Publisher = {Carnegie Endowment for International Peace},
	Title = {Closing Space: Democracy and Human Rights Support Under Fire},
	Year = {2014}}

@phdthesis{Heiss:2017,
	Address = {Durham, NC},
	Author = {Andrew Heiss},
	Date-Added = {2018-05-23 16:58:19 +0000},
	Date-Modified = {2018-05-23 16:58:19 +0000},
	Month = {7},
	School = {Duke University},
	Title = {Amicable Contempt: {The} Strategic Balance between Dictators and International {NGO}s},
	Year = {2017}}

@unpublished{ChaudhryHeiss:2017,
	Author = {Suparna Chaudhry and Andrew Heiss},
	Date-Added = {2018-05-23 16:58:10 +0000},
	Date-Modified = {2018-05-23 16:58:10 +0000},
	Note = {Working paper},
	Title = {Are Funders Really Responding? Analyzing the Impact of Global Restrictions on {NGO}s},
	Year = {2017}}

@phdthesis{Chaudhry:2016,
	Address = {New Haven, Connecticut},
	Author = {Suparna Chaudhry},
	Date-Added = {2018-05-23 16:57:54 +0000},
	Date-Modified = {2018-05-23 16:57:54 +0000},
	School = {Yale University},
	Title = {The Assault on Democracy Assistance: Explaining State Repression of {NGO}s},
	Year = {2016}}

@article{ChristensenWeinstein:2013,
	Author = {Darin Christensen and Jeremy M. Weinstein},
	Date-Added = {2018-05-23 16:57:27 +0000},
	Date-Modified = {2018-05-23 16:57:27 +0000},
	Doi = {10.1353/jod.2013.0026},
	Journal = {Journal of Democracy},
	Month = {4},
	Number = {2},
	Pages = {77--91},
	Title = {Defunding Dissent: Restrictions on Aid to {NGOs}},
	Volume = {24},
	Year = {2013},
	Bdsk-Url-1 = {http://dx.doi.org/10.1353/jod.2013.0026}}

@unpublished{CoppedgeGerringLindberg:2018,
	Author = {Michael Coppedge and John Gerring and Carl Henrik Knutsen and Staffan I. Lindberg and Svend-Erik Skaaning and Jan Teorell and David Altman and Michael Bernhard and M. Steven Fish and Agnes Cornell and Sirianne Dahlum and Haakon Gjerl{\o}w and Adam Glynn and Allen Hicken and Joshua Krusell and Anna L{\"u}hrmann and Kyle L. Marquardt and Kelly McMann and Valeriya Mechkova and Juraj Medzihorsky and Moa Olin and Pamela Paxton and Daniel Pemstein and Josefine Pernes and Johannes von R{\"o}mer and Brigitte Seim and Rachel Sigman and Jeffrey Staton and Natalia Stepanova and Aksel Sundstr{\"o}m and Eitan Tzelgov and Yi-ting Wang and Tore Wig and Steven Wilson and Daniel Ziblatt},
	Date-Added = {2018-05-23 16:54:33 +0000},
	Date-Modified = {2018-05-23 17:01:21 +0000},
	Institution = {Varieties of Democracy (V-Dem) Project},
	Note = {Varieties of Democracy (V-Dem) Project},
	Title = {V-Dem [Country-Year/Country-Date] Dataset v8},
	Url = {https://www.v-dem.net},
	Urldate = {2018-05-20},
	Year = {2018},
	Bdsk-Url-1 = {https://www.v-dem.net}}

@book{PrakashGugerty:2010,
	Address = {Cambridge},
	Booktitle = {Advocacy Organizations and Collective Action},
	Date-Added = {2018-05-22 22:35:39 +0000},
	Date-Modified = {2018-05-22 22:36:27 +0000},
	Doi = {10.1017/CBO9780511762635},
	Editor = {Aseem Prakash and Mary Kay Gugerty},
	Publisher = {Cambridge University Press},
	Rating = {0},
	Read = {0},
	Year = {2010},
	Bdsk-Url-1 = {https://doi.org/10.1017/CBO9780511762635}}

@book{Kelley:2012,
	Address = {Princeton},
	Author = {Judith G. Kelley},
	Date-Added = {2018-05-22 22:31:16 +0000},
	Date-Modified = {2018-05-22 22:31:23 +0000},
	Publisher = {Princeton University Press},
	Rating = {0},
	Read = {0},
	Title = {Monitoring Democracy: When International Election Observation Works, and Why It Often Fails},
	Year = {2012}}

@incollection{Henderson:2010,
	Author = {Sarah L. Henderson},
	Chapter = {10},
	Crossref = {PrakashGugerty:2010},
	Date-Added = {2018-05-22 22:31:10 +0000},
	Date-Modified = {2018-05-31 22:47:47 +0000},
	Doi = {10.1017/cbo9780511762635.002},
	Pages = {252--79},
	Rating = {0},
	Read = {0},
	Title = {Shaping Civic Advocacy: International and Domestic Policies Toward Russia's {NGO} Sector},
	Bdsk-Url-1 = {https://doi.org/10.1017/cbo9780511762635.002}}

@article{Hawkins:1997,
	Author = {Darren G. Hawkins},
	Date-Added = {2018-05-22 22:31:01 +0000},
	Date-Modified = {2018-05-22 22:31:01 +0000},
	Doi = {10.1177/1354066197003004001},
	Journal = {European Journal of International Relations},
	Month = {12},
	Number = {4},
	Pages = {403--34},
	Title = {Domestic Responses to International Pressure: Human Rights in Authoritarian Chile},
	Volume = {3},
	Year = {1997},
	Bdsk-Url-1 = {http://dx.doi.org/10.1177/1354066197003004001}}

@book{RisseRoppSikkink:1999,
	Address = {Cambridge, UK},
	Booktitle = {The Power of Human Rights: International Norms and Domestic Change},
	Date-Added = {2018-05-22 22:30:44 +0000},
	Date-Modified = {2018-05-22 22:35:39 +0000},
	Doi = {10.1017/CBO9780511598777},
	Editor = {Thomas Risse and Stephen Ropp and Kathryn Sikkink},
	Publisher = {Cambridge University Press},
	Rating = {0},
	Read = {0},
	Year = {1999},
	Bdsk-Url-1 = {https://doi.org/10.1017/CBO9780511598777}}

@incollection{RisseSikkink:1999,
	Author = {Thomas Risse and Kathryn Sikkink},
	Chapter = {1},
	Crossref = {RisseRoppSikkink:1999},
	Date-Added = {2018-05-22 22:30:44 +0000},
	Date-Modified = {2018-05-22 22:34:01 +0000},
	Doi = {10.1017/cbo9780511598777.002},
	Pages = {1--38},
	Rating = {0},
	Read = {0},
	Title = {The Socialization of International Human Rights Norms into Domestic Practices: Introduction},
	Bdsk-Url-1 = {https://doi.org/10.1017/cbo9780511598777.002}}

@book{Kelley:2017,
	Address = {Cambridge},
	Author = {Judith G. Kelley},
	Date-Added = {2018-05-22 22:30:33 +0000},
	Date-Modified = {2018-05-22 22:30:33 +0000},
	Publisher = {Cambridge University Press},
	Title = {Scorecard Diplomacy: Grading States to Influence their Reputation and Behavior},
	Year = {2017}}

@article{KelleySimmons:2015,
	Author = {Judith G. Kelley and Beth A. Simmons},
	Date-Added = {2018-05-22 22:30:33 +0000},
	Date-Modified = {2018-05-22 22:30:33 +0000},
	Doi = {10.1111/ajps.12119},
	Journal = {American Journal of Political Science},
	Month = {1},
	Number = {1},
	Pages = {55--70},
	Title = {Politics by Number: {Indicators} as Social Pressure in International Relations},
	Volume = {59},
	Year = {2015},
	Bdsk-Url-1 = {http://dx.doi.org/10.1111/ajps.12119}}

@book{Slaughter:2004,
	Address = {Princeton},
	Author = {Anne-Marie Slaughter},
	Date-Added = {2018-05-22 22:30:22 +0000},
	Date-Modified = {2018-05-22 22:37:53 +0000},
	Publisher = {Princeton University Press},
	Rating = {0},
	Read = {0},
	Title = {A New World Order},
	Year = {2004}}

@book{Linos:2013,
	Address = {Oxford},
	Author = {Katerina Linos},
	Date-Added = {2018-05-22 22:30:14 +0000},
	Date-Modified = {2018-05-22 22:33:01 +0000},
	Doi = {10.1093/acprof:oso/9780199967865.001.0001},
	Publisher = {Oxford University Press},
	Rating = {0},
	Read = {0},
	Title = {The Democratic Foundations of Policy Diffusion: How Health, Family, and Employment Laws Spread Across Countries},
	Year = {2013},
	Bdsk-Url-1 = {https://doi.org/10.1093/acprof:oso/9780199967865.001.0001}}

@article{WalkerCooley:2013,
	Author = {Christopher Walker and Alexander Cooley},
	Date = {2013-10-31},
	Date-Added = {2018-05-22 22:18:03 +0000},
	Date-Modified = {2018-05-22 22:20:04 +0000},
	Entrysubtype = {magazine},
	Journal = {Foreign Policy},
	Title = {Vote of the Living Dead},
	Url = {http://foreignpolicy.com/2013/10/31/vote-of-the-living-dead/},
	Urldate = {2018-05-22},
	Bdsk-Url-1 = {http://foreignpolicy.com/2013/10/31/vote-of-the-living-dead/}}

@book{Stiles:2002,
	Address = {Westport, CT},
	Author = {Kendall W. Stiles},
	Date-Added = {2018-05-22 20:44:56 +0000},
	Date-Modified = {2018-05-22 20:50:36 +0000},
	Publisher = {Praeger},
	Rating = {0},
	Read = {0},
	Title = {Civil Society by Design: Donors, {NGOs}, and the Intermestic Development Circle in Bangladesh},
	Year = {2002}}

@book{Schuller:2012,
	Address = {New Brunswick, New Jersey},
	Author = {Mark Schuller},
	Date-Added = {2018-05-22 20:16:23 +0000},
	Date-Modified = {2018-05-22 20:16:29 +0000},
	Publisher = {Rutgers University Press},
	Rating = {0},
	Read = {0},
	Title = {Killing with Kindness: Haiti, International Aid, and {NGOs}},
	Year = {2012}}

@article{Haque:2002,
	Author = {M. Shamsul Haque},
	Date-Added = {2018-05-22 20:07:25 +0000},
	Date-Modified = {2018-05-22 20:49:57 +0000},
	Doi = {10.1177/0192512102023004006},
	Journal = {International Political Science Review},
	Month = {10},
	Number = {4},
	Pages = {411--35},
	Title = {The Changing Balance of Power between the Government and {NGOs} in Bangladesh},
	Volume = {23},
	Year = {2002},
	Bdsk-Url-1 = {https://doi.org/10.1177/0192512102023004006}}

@article{Bratton:1989,
	Author = {Michael Bratton},
	Date-Added = {2018-05-22 19:40:23 +0000},
	Date-Modified = {2018-05-22 20:49:22 +0000},
	Doi = {10.1016/0305-750x(89)90263-5},
	Journal = {World Development},
	Month = {4},
	Number = {4},
	Pages = {569--87},
	Title = {The Politics of Government--{NGO} Relations in Africa},
	Volume = {17},
	Year = {1989},
	Bdsk-Url-1 = {https://doi.org/10.1016/0305-750x(89)90263-5}}

@techreport{Martin:2002,
	Author = {Jay Martin},
	Date-Added = {2018-05-22 19:31:11 +0000},
	Date-Modified = {2018-05-22 19:34:59 +0000},
	Institution = {Australian National University Graduate Program in Public Policy},
	Number = {92},
	Title = {Can Magic Bullets Hurt You? NGOs and Governance in a Globalised Social Welfare World: A Case Study of Tajikistan},
	Type = {Discussion paper},
	Url = {http://hdl.handle.net/1885/41747},
	Year = {2002},
	Bdsk-Url-1 = {http://hdl.handle.net/1885/41747}}

@article{Brass:2012,
	Author = {Jennifer N. Brass},
	Date-Added = {2018-05-22 19:12:29 +0000},
	Date-Modified = {2018-05-22 20:49:12 +0000},
	Doi = {10.1111/j.1468-0491.2011.01553.x},
	Journal = {Governance},
	Month = {4},
	Number = {2},
	Pages = {209--35},
	Title = {Blurring Boundaries: The Integration of {NGOs} into Governance in Kenya},
	Volume = {25},
	Year = {2012},
	Bdsk-Url-1 = {http://dx.doi.org/10.1111/j.1468-0491.2011.01553.x}}

@article{Chege:1999,
	Author = {Sam Chege},
	Date-Added = {2018-05-22 18:51:11 +0000},
	Date-Modified = {2018-05-22 18:51:41 +0000},
	Journal = {Africa Recovery},
	Month = {6},
	Number = {1},
	Pages = {6},
	Title = {Donors shift more aid to {NGO}s},
	Volume = {13},
	Year = {1999}}

@book{KeckSikkink:1998,
	Address = {Ithaca},
	Author = {Margaret E. Keck and Kathryn Sikkink},
	Date-Added = {2018-05-22 18:32:03 +0000},
	Date-Modified = {2018-05-22 18:32:17 +0000},
	Publisher = {Cornell University Press},
	Rating = {0},
	Read = {0},
	Title = {Activists Beyond Borders: Advocacy Networks in International Politics},
	Year = {1998}}

@book{Ihonvbere:1996,
	Address = {Trenton, NJ},
	Author = {Julius O. Ihonvbere},
	Date-Added = {2018-05-22 17:49:12 +0000},
	Date-Modified = {2018-05-22 18:11:32 +0000},
	Publisher = {Africa World Press},
	Title = {Economic Crisis, Civil Society, and Democratization: The Case of Zambia},
	Year = {1996}}

@book{NefissaAbd-al-FattahHanafi:2005,
	Address = {Cairo},
	Booktitle = {{NGOs} and Governance in the {Arab} World},
	Date-Added = {2018-05-22 16:26:57 +0000},
	Date-Modified = {2018-05-22 16:27:09 +0000},
	Editor = {Sarah Ben N{\'e}fissa and Nabil {Abd al-Fattah} and Sari Hanafi and Carlos Milani},
	Publisher = {American University in Cairo Press},
	Rating = {0},
	Read = {0},
	Year = {2005}}

@book{HulmeEdwards:1997,
	Address = {New York},
	Booktitle = {NGOs, States, and Donors: Too Close for Comfort},
	Date-Added = {2018-05-22 16:26:30 +0000},
	Date-Modified = {2018-05-22 16:34:29 +0000},
	Editor = {David Hulme and Michael Edwards},
	Publisher = {Palgrave Macmillan},
	Rating = {0},
	Read = {0},
	Year = {1997}}

@incollection{Nefissa:2005,
	Author = {Sarah Ben N{\'e}fissa},
	Chapter = {Introduction},
	Crossref = {NefissaAbd-al-FattahHanafi:2005},
	Date-Added = {2018-05-22 16:25:29 +0000},
	Date-Modified = {2018-05-22 16:25:43 +0000},
	Pages = {1--18},
	Rating = {0},
	Read = {0},
	Title = {{NGO}s and Governance in the {Arab} World: A Question of Democracy}}

@incollection{Marzouk:1997,
	Author = {Mohsen Marzouk},
	Chapter = {12},
	Crossref = {HulmeEdwards:1997},
	Date-Added = {2018-05-22 16:25:23 +0000},
	Date-Modified = {2018-05-22 16:26:09 +0000},
	Pages = {191--201},
	Rating = {0},
	Read = {0},
	Title = {The Associative Phenomenon in the Arab World: Engine of Democratisation or Witness to the Crisis?}}

@book{Brass:2016,
	Address = {Cambridge, UK},
	Author = {Jennifer N. Brass},
	Date-Added = {2018-05-22 16:24:53 +0000},
	Date-Modified = {2018-05-22 16:24:53 +0000},
	Doi = {10.1017/cbo9781316678527},
	Publisher = {Cambridge University Press},
	Title = {Allies or Adversaries: {NGO}s and the State in {Africa}},
	Year = {2016},
	Bdsk-Url-1 = {http://dx.doi.org/10.1017/cbo9781316678527}}

@article{CrottyHallLjubownikow:2014,
	Author = {Jo Crotty and Sarah Marie Hall and Sergej Ljubownikow},
	Date-Added = {2018-05-22 16:22:56 +0000},
	Date-Modified = {2018-05-22 16:25:54 +0000},
	Doi = {10.1080/09668136.2014.941697},
	Journal = {Europe-Asia Studies},
	Month = {10},
	Number = {8},
	Pages = {1253--69},
	Rating = {0},
	Read = {0},
	Title = {Post-{Soviet} Civil Society Development in the {Russian Federation}: The Impact of the {NGO} Law},
	Volume = {66},
	Year = {2014},
	Bdsk-Url-1 = {http://dx.doi.org/10.1080/09668136.2014.941697}}

@article{Flikke:2015,
	Author = {Geir Flikke},
	Date-Added = {2018-05-22 16:22:39 +0000},
	Date-Modified = {2018-05-22 16:27:22 +0000},
	Doi = {10.1080/1060586X.2015.1034981},
	Journal = {Post-Soviet Affairs},
	Number = {2},
	Pages = {103--31},
	Rating = {0},
	Read = {0},
	Title = {Resurgent Authoritarianism: The Case of Russia's New {NGO} Legislation},
	Volume = {32},
	Year = {2015},
	Bdsk-Url-1 = {http://dx.doi.org/10.1080/1060586X.2015.1034981}}

@article{Hemment:2004,
	Author = {Julie Hemment},
	Date-Added = {2018-05-22 16:22:14 +0000},
	Date-Modified = {2018-05-22 16:22:14 +0000},
	Doi = {10.1353/anq.2004.0069},
	Issue = {Spring},
	Journal = {Anthropological Quarterly},
	Number = {2},
	Pages = {215--41},
	Title = {The Riddle of the Third Sector: Civil Society, International Aid, and {NGO}s in {R}ussia},
	Volume = {77},
	Year = {2004},
	Bdsk-Url-1 = {http://dx.doi.org/10.1353/anq.2004.0069}}

@book{Henderson:2003,
	Address = {Ithaca, New York},
	Author = {Sarah L. Henderson},
	Date-Added = {2018-05-22 16:22:06 +0000},
	Date-Modified = {2018-05-22 16:22:06 +0000},
	Publisher = {Cornell University Press},
	Title = {Building Democracy in Contemporary Russia: Western Support for Grassroots Organizations},
	Year = {2003}}

@book{Jamal:2007,
	Address = {Princeton, NJ},
	Author = {Amaney A. Jamal},
	Date-Added = {2018-05-22 16:21:59 +0000},
	Date-Modified = {2018-05-23 17:46:53 +0000},
	Doi = {10.1515/9781400830503},
	Publisher = {Princeton University Press},
	Rating = {0},
	Read = {0},
	Title = {Barriers to Democracy: {T}he Other Side of Social Capital in {P}alestine and the {A}rab {World}},
	Year = {2007},
	Bdsk-Url-1 = {http://dx.doi.org/10.1515/9781400830503}}

@book{Putnam:1994,
	Address = {Princeton},
	Author = {Robert D. Putnam and Robert Leonardi and Raffaella Y. Nanetti},
	Date-Added = {2018-05-22 16:21:52 +0000},
	Date-Modified = {2018-05-22 16:25:48 +0000},
	Publisher = {Princeton University Press},
	Rating = {0},
	Read = {0},
	Title = {Making Democracy Work: {C}ivic Traditions in Modern {I}taly},
	Year = {1994}}

@book{AhmedPotter:2006,
	Address = {Bloomfield, CT},
	Author = {Shamima Ahmed and David Potter},
	Date-Added = {2018-05-22 16:21:45 +0000},
	Date-Modified = {2018-05-22 16:27:26 +0000},
	Publisher = {Kumarian Press},
	Rating = {0},
	Read = {0},
	Title = {NGOs in International Politics},
	Year = {2006}}

@book{DeMars:2005,
	Address = {London},
	Author = {William DeMars},
	Date-Added = {2018-05-22 16:21:39 +0000},
	Date-Modified = {2018-05-22 16:35:29 +0000},
	Doi = {10.2307/j.ctt18fs3q9},
	Publisher = {Pluto Press},
	Rating = {0},
	Read = {0},
	Title = {NGOs and Transnational Networks: Wild Cards in World Politics},
	Year = {2005},
	Bdsk-Url-1 = {https://doi.org/10.2307/j.ctt18fs3q9}}

@book{FrantzEzrow:2011,
	Address = {Boulder, Colorado},
	Author = {Erica Frantz and Natasha Ezrow},
	Date-Added = {2018-05-22 16:21:19 +0000},
	Date-Modified = {2018-05-22 16:21:19 +0000},
	Publisher = {Lynne Rienner Publishers},
	Title = {The Politics of Dictatorship: Institutions and Outcomes in Authoritarian Regimes},
	Year = {2011}}

@book{Greitens:2016,
	Address = {Cambridge, UK},
	Author = {Sheena Chestnut Greitens},
	Date-Added = {2018-05-21 19:22:24 +0000},
	Date-Modified = {2018-05-21 19:22:24 +0000},
	Doi = {10.1017/cbo9781316489031},
	Publisher = {Cambridge University Press},
	Title = {Dictators and their Secret Police: Coercive Institutions and State Violence},
	Year = {2016},
	Bdsk-Url-1 = {https://doi.org/10.1017/cbo9781316489031}}

@article{Wintrobe:1990,
	Author = {Ronald Wintrobe},
	Date-Added = {2018-05-21 19:20:16 +0000},
	Date-Modified = {2018-05-21 19:27:12 +0000},
	Doi = {10.2307/1962769},
	Journal = {American Political Science Review},
	Month = {9},
	Number = {3},
	Pages = {849--72},
	Rating = {0},
	Read = {0},
	Title = {The Tinpot and the Totalitarian: An Economic Theory of Dictatorship},
	Volume = {84},
	Year = {1990},
	Bdsk-Url-1 = {http://dx.doi.org/10.2307/1962769}}

@article{MaleskySchulerTran:2012,
	Author = {Edmund Malesky and Paul Schuler and Anh Tran},
	Date-Added = {2018-05-21 19:20:05 +0000},
	Date-Modified = {2018-05-21 19:28:15 +0000},
	Doi = {10.1017/s0003055412000408},
	Journal = {American Political Science Review},
	Month = {11},
	Number = {4},
	Pages = {762--86},
	Rating = {0},
	Read = {0},
	Title = {The Adverse Effects of Sunshine: A Field Experiment on Legislative Transparency in an Authoritarian Assembly},
	Volume = {106},
	Year = {2012},
	Bdsk-Url-1 = {https://doi.org/10.1017/s0003055412000408}}

@article{Weiss:2013,
	Author = {Jessica Chen Weiss},
	Date-Added = {2018-05-21 19:19:57 +0000},
	Date-Modified = {2018-05-21 19:26:54 +0000},
	Doi = {10.1017/s0020818312000380},
	Issue = {Winter},
	Journal = {International Organization},
	Number = {1},
	Pages = {1--35},
	Rating = {0},
	Read = {0},
	Title = {Authoritarian Signaling, Mass Audiences, and Nationalist Protest in China},
	Volume = {67},
	Year = {2013},
	Bdsk-Url-1 = {http://dx.doi.org/10.1017/s0020818312000380}}

@book{Wickham:2002,
	Address = {New York},
	Author = {Carrie Rosefsky Wickham},
	Date-Added = {2018-05-21 19:19:49 +0000},
	Date-Modified = {2018-05-21 19:27:40 +0000},
	Publisher = {Columbia University Press},
	Rating = {0},
	Read = {0},
	Title = {Mobilizing Islam: Religion, Activism, and Political Change in Egypt},
	Year = {2002}}

@article{Beinin:2011,
	Author = {Joel Beinin},
	Date-Added = {2018-05-21 19:19:38 +0000},
	Date-Modified = {2018-05-21 19:26:01 +0000},
	Doi = {10.1017/s0147547911000123},
	Issue = {Fall},
	Journal = {International Labor and Working-Class History},
	Number = {1},
	Pages = {189--96},
	Title = {Workers and Egypt's January 25 Revolution},
	Volume = {80},
	Year = {2011},
	Bdsk-Url-1 = {https://doi.org/10.1017/s0147547911000123}}

@article{FrantzKendall-Taylor:2014,
	Author = {Erica Frantz and Andrea Kendall-Taylor},
	Date-Added = {2018-05-21 19:19:23 +0000},
	Date-Modified = {2018-05-21 19:26:22 +0000},
	Doi = {10.1177/0022343313519808},
	Journal = {Journal of Peace Research},
	Month = {5},
	Number = {3},
	Pages = {332--46},
	Title = {A Dictator's Toolkit: Understanding How Co-optation Affects Repression in Autocracies},
	Volume = {51},
	Year = {2014},
	Bdsk-Url-1 = {http://dx.doi.org/10.1177/0022343313519808}}

@book{Boylan:2001,
	Address = {Ann Arbor},
	Author = {Delia M. Boylan},
	Date-Added = {2018-05-21 19:19:10 +0000},
	Date-Modified = {2018-05-22 16:36:57 +0000},
	Doi = {10.3998/mpub.17319},
	Publisher = {University of Michigan Press},
	Rating = {0},
	Read = {0},
	Title = {Defusing Democracy: Central Bank Autonomy and the Transition from Authoritarian Rule},
	Year = {2001},
	Bdsk-Url-1 = {https://doi.org/10.3998/mpub.17319}}

@book{GinsburgMoustafa:2008,
	Address = {Cambridge, UK},
	Author = {Tom Ginsburg and Tamir Moustafa},
	Date-Added = {2018-05-21 19:19:04 +0000},
	Date-Modified = {2018-05-22 16:37:32 +0000},
	Doi = {10.1017/cbo9780511814822},
	Publisher = {Cambridge University Press},
	Title = {Rule by Law: The Politics of Courts in Authoritarian Regimes},
	Year = {2008},
	Bdsk-Url-1 = {https://doi.org/10.1017/cbo9780511814822}}

@book{Blaydes:2011,
	Address = {Cambridge},
	Author = {Lisa Blaydes},
	Date-Added = {2018-05-21 19:18:55 +0000},
	Date-Modified = {2018-05-22 16:32:30 +0000},
	Doi = {10.1017/cbo9780511976469},
	Publisher = {Cambridge University Press},
	Rating = {0},
	Read = {0},
	Title = {Elections and Distributive Politics in {M}ubarak's {E}gypt},
	Year = {2011},
	Bdsk-Url-1 = {https://doi.org/10.1017/cbo9780511976469}}

@article{Kendall-TaylorFrantz:2014a,
	Author = {Andrea Kendall-Taylor and Erica Frantz},
	Date-Added = {2018-05-21 19:18:37 +0000},
	Date-Modified = {2018-05-21 19:27:01 +0000},
	Doi = {10.1080/0163660x.2014.1002155},
	Issue = {Winter},
	Journal = {The Washington Quarterly},
	Number = {4},
	Pages = {71--84},
	Rating = {0},
	Read = {0},
	Title = {Mimicking Democracy to Prolong Autocracies},
	Volume = {37},
	Year = {2014},
	Bdsk-Url-1 = {http://dx.doi.org/10.1080/0163660x.2014.1002155}}

@article{Brumberg:2002,
	Author = {Daniel Brumberg},
	Date-Added = {2018-05-21 19:18:05 +0000},
	Date-Modified = {2018-05-21 19:28:08 +0000},
	Doi = {10.1353/jod.2002.0064},
	Journal = {Journal of Democracy},
	Month = {10},
	Number = {4},
	Pages = {56--68},
	Rating = {0},
	Read = {0},
	Title = {Democratization in the {A}rab World? {T}he Trap of Liberalized Autocracy},
	Volume = {13},
	Year = {2002},
	Bdsk-Url-1 = {http://dx.doi.org/10.1353/jod.2002.0064}}

@book{Cook:2007,
	Address = {Baltimore},
	Author = {Steven A. Cook},
	Date-Added = {2018-05-21 19:17:54 +0000},
	Date-Modified = {2018-05-21 19:27:52 +0000},
	Publisher = {The Johns Hopkins University Press},
	Rating = {0},
	Read = {0},
	Title = {Ruling But Not Governing: The Military and Political Development in {E}gypt, {A}lgeria, and {T}urkey},
	Year = {2007}}

@article{Gandhi:2006,
	Author = {Jennifer Gandhi and Adam Przeworski},
	Date-Added = {2018-05-21 19:17:48 +0000},
	Date-Modified = {2018-05-21 19:27:33 +0000},
	Doi = {10.1111/j.1468-0343.2006.00160.x},
	Journal = {Economics \& Politics},
	Month = {3},
	Number = {1},
	Pages = {1--26},
	Rating = {0},
	Read = {0},
	Title = {Cooperation, Cooptation, and Rebellion Under Dictatorships},
	Volume = {18},
	Year = {2006},
	Bdsk-Url-1 = {http://dx.doi.org/10.1111/j.1468-0343.2006.00160.x}}

@article{GandhiPrzeworski:2007,
	Author = {Jennifer Gandhi and Adam Przeworski},
	Date-Added = {2018-05-21 19:17:48 +0000},
	Date-Modified = {2018-05-21 19:27:28 +0000},
	Doi = {10.1177/0010414007305817},
	Journal = {Comparative Political Studies},
	Month = {11},
	Number = {11},
	Pages = {1279--1301},
	Rating = {0},
	Read = {0},
	Title = {Authoritarian Institutions and the Survival of Autocrats},
	Volume = {40},
	Year = {2007},
	Bdsk-Url-1 = {http://dx.doi.org/10.1177/0010414007305817}}

@book{Brownlee:2007,
	Address = {Cambridge},
	Author = {Jason Brownlee},
	Date-Added = {2018-05-21 19:17:37 +0000},
	Date-Modified = {2018-05-21 19:27:46 +0000},
	Doi = {10.1017/cbo9780511802348},
	Publisher = {Cambridge University Press},
	Rating = {0},
	Read = {0},
	Title = {Authoritarianism in an Age of Democratization},
	Year = {2007},
	Bdsk-Url-1 = {http://dx.doi.org/10.1017/cbo9780511802348}}

@article{Svolik:2009,
	Author = {Milan W. Svolik},
	Date-Added = {2018-05-21 19:17:28 +0000},
	Date-Modified = {2018-05-21 19:27:23 +0000},
	Doi = {10.1111/j.1540-5907.2009.00382.x},
	Journal = {American Journal of Political Science},
	Month = {4},
	Number = {2},
	Pages = {477--94},
	Rating = {0},
	Read = {0},
	Title = {Power Sharing and Leadership Dynamics in Authoritarian Regimes},
	Volume = {53},
	Year = {2009},
	Bdsk-Url-1 = {http://dx.doi.org/10.1111/j.1540-5907.2009.00382.x}}

@article{Heiss:2012,
	Author = {Andrew Heiss},
	Date-Added = {2018-05-21 19:17:22 +0000},
	Date-Modified = {2018-05-21 19:26:28 +0000},
	Issue = {Spring},
	Journal = {Journal of Third World Studies},
	Number = {1},
	Pages = {155-171},
	Title = {The Failed Management of a Dying Regime: {Hosni Mubarak}, {Egypt's National Democratic Party}, and the {January} 25 Revolution},
	Volume = {28},
	Year = {2012}}

@book{LevitskyWay:2010,
	Address = {Cambridge, MA},
	Author = {Steven Levitsky and Lucan A. Way},
	Date-Added = {2018-05-21 19:17:16 +0000},
	Date-Modified = {2018-05-22 16:39:08 +0000},
	Doi = {10.1017/cbo9780511781353},
	Publisher = {Cambridge University Press},
	Rating = {0},
	Read = {0},
	Title = {Competitive Authoritarianism: Hybrid Regimes After the Cold War},
	Year = {2010},
	Bdsk-Url-1 = {https://doi.org/10.1017/cbo9780511781353}}

@book{Stacher:2012,
	Address = {Stanford},
	Author = {Joshua Stacher},
	Date-Added = {2018-05-21 19:17:10 +0000},
	Date-Modified = {2018-05-21 19:28:02 +0000},
	Publisher = {Stanford University Press},
	Rating = {0},
	Read = {0},
	Title = {Adaptable Autocrats: Regime Power in Egypt and Syria},
	Year = {2012}}

@article{Shieh:2017,
	Author = {Shawn Shieh},
	Date = {2017-01-31},
	Date-Added = {2018-05-08 22:07:49 +0000},
	Date-Modified = {2018-05-08 22:07:54 +0000},
	Entrysubtype = {magazine},
	Journal = {ChinaFile},
	Title = {The Origins of China's New Law on Foreign {NGOs}},
	Url = {http://www.chinafile.com/reporting-opinion/viewpoint/origins-of-chinas-new-law-foreign-ngos},
	Urldate = {2017-08-02},
	Bdsk-Url-1 = {http://www.chinafile.com/reporting-opinion/viewpoint/origins-of-chinas-new-law-foreign-ngos}}

@report{CIVICUS:2017,
	Author = {{CIVICUS}},
	Date = {2017-04-04},
	Date-Added = {2018-05-08 20:43:37 +0000},
	Date-Modified = {2018-05-08 20:44:20 +0000},
	Title = {People Power Under Attack: Findings from the {CIVICUS} {Monitor}},
	Url = {http://www.civicus.org/images/People_Power_Under_Attack_Findings_from_the_CIVICUS_Monitor.pdf},
	Bdsk-Url-1 = {http://www.civicus.org/images/People_Power_Under_Attack_Findings_from_the_CIVICUS_Monitor.pdf}}

@article{Batke:2018,
	Author = {Jessica Batke},
	Date = {2018-05-03},
	Date-Added = {2018-05-08 19:17:51 +0000},
	Date-Modified = {2018-05-08 22:10:14 +0000},
	Entrysubtype = {magazine},
	Journal = {ChinaFile},
	Title = {Visually Understanding the Data on Foreign {NGO} Representative Offices and Temporary Activities},
	Url = {http://www.chinafile.com/ngo/analysis/visually-understanding-data-foreign-ngo-representative-offices-and-temporary-activities},
	Bdsk-Url-1 = {http://www.chinafile.com/ngo/analysis/visually-understanding-data-foreign-ngo-representative-offices-and-temporary-activities}}

@article{ChinaFile:2018,
	Author = {{ChinaFile}},
	Date = {2018-04-18},
	Date-Added = {2018-05-08 18:59:45 +0000},
	Date-Modified = {2018-05-08 22:10:09 +0000},
	Entrysubtype = {magazine},
	Journal = {ChinaFile},
	Title = {Government Cartoon Portrays 'Foreign {NGO}s' as National Security Concern},
	Url = {http://www.chinafile.com/ngo/latest/government-cartoon-portrays-foreign-ngos-national-security-concern},
	Bdsk-Url-1 = {http://www.chinafile.com/ngo/latest/government-cartoon-portrays-foreign-ngos-national-security-concern}}

@book{Teets:2014,
	Address = {New York},
	Author = {Jessica C. Teets},
	Date-Added = {2018-05-08 18:56:28 +0000},
	Date-Modified = {2018-05-08 18:58:10 +0000},
	Doi = {10.1017/cbo9781139839396},
	Publisher = {Cambridge University Press},
	Rating = {0},
	Read = {0},
	Title = {Civil Society under Authoritarianism: The China Model},
	Year = {2014},
	Bdsk-Url-1 = {http://dx.doi.org/10.1017/cbo9781139839396}}

@book{Wheeler:2013,
	Address = {London},
	Author = {Norton Wheeler},
	Date-Added = {2018-05-08 18:30:42 +0000},
	Date-Modified = {2018-05-08 22:09:59 +0000},
	Doi = {10.4324/9780203100011},
	Publisher = {Routledge},
	Title = {The Role of American {NGO}s in China's Modernization: Invited Influence},
	Year = {2013},
	Bdsk-Url-1 = {https://doi.org/10.4324/9780203100011}}

repository: andrewheiss/ngos-authoritarianism

repo_name: andrewheiss/ngos-authoritarianism